mirror of
https://github.com/cirruslabs/orchard.git
synced 2026-10-20 09:39:01 +02:00
Supporting reconnecting to /exec socket (#434)
This commit is contained in:
@@ -10,18 +10,24 @@ import (
|
||||
type FrameType string
|
||||
|
||||
const (
|
||||
FrameTypeStdin FrameType = "stdin"
|
||||
FrameTypeStdout FrameType = "stdout"
|
||||
FrameTypeStderr FrameType = "stderr"
|
||||
FrameTypeExit FrameType = "exit"
|
||||
FrameTypeError FrameType = "error"
|
||||
FrameTypeStdin FrameType = "stdin"
|
||||
FrameTypeStdout FrameType = "stdout"
|
||||
FrameTypeStderr FrameType = "stderr"
|
||||
FrameTypeExit FrameType = "exit"
|
||||
FrameTypeError FrameType = "error"
|
||||
FrameTypeHistory FrameType = "history"
|
||||
FrameTypeNoMoreHistory FrameType = "no_more_history"
|
||||
FrameTypeAck FrameType = "ack"
|
||||
FrameTypeDetach FrameType = "detach"
|
||||
FrameTypeClose FrameType = "close"
|
||||
)
|
||||
|
||||
type Frame struct {
|
||||
Type FrameType `json:"type"`
|
||||
Data []byte `json:"data,omitempty"`
|
||||
Exit *Exit `json:"exit,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Type FrameType `json:"type"`
|
||||
Data []byte `json:"data,omitempty"`
|
||||
Exit *Exit `json:"exit,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
Watermark uint64 `json:"watermark,omitempty"`
|
||||
}
|
||||
|
||||
type Exit struct {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package execstream
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestFrameRoundTripsWatermark(t *testing.T) {
|
||||
frame := Frame{
|
||||
Type: FrameTypeHistory,
|
||||
Watermark: 42,
|
||||
}
|
||||
|
||||
payload, err := json.Marshal(frame)
|
||||
require.NoError(t, err)
|
||||
|
||||
var decoded Frame
|
||||
err = json.Unmarshal(payload, &decoded)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, frame, decoded)
|
||||
}
|
||||
Reference in New Issue
Block a user