Skip to content

Commit

Permalink
Merge branch 'main' into object-ref-compatibility-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredoconnell committed Oct 20, 2023
2 parents de2e4d2 + 9573909 commit a6e7a9c
Show file tree
Hide file tree
Showing 9 changed files with 1,035 additions and 298 deletions.
450 changes: 336 additions & 114 deletions atp/client.go

Large diffs are not rendered by default.

35 changes: 25 additions & 10 deletions atp/protocol.go
Original file line number Diff line number Diff line change
@@ -1,55 +1,70 @@
package atp

import (
"fmt"
"github.com/fxamacker/cbor/v2"
"go.flow.arcalot.io/pluginsdk/schema"
)

const ProtocolVersion int64 = 2
const ProtocolVersion int64 = 3

type HelloMessage struct {
Version int64 `cbor:"version"`
Schema any `cbor:"schema"`
}

type StartWorkMessage struct {
type WorkStartMessage struct {
StepID string `cbor:"id"`
Config any `cbor:"config"`
}

// All messages that can be contained in a RuntimeMessage struct.
const (
MessageTypeWorkDone uint32 = 1
MessageTypeSignal uint32 = 2
MessageTypeClientDone uint32 = 3
MessageTypeWorkStart uint32 = 1
MessageTypeWorkDone uint32 = 2
MessageTypeSignal uint32 = 3
MessageTypeClientDone uint32 = 4
MessageTypeError uint32 = 5
)

type RuntimeMessage struct {
MessageID uint32 `cbor:"id"`
RunID string `cbor:"run_id"`
MessageData any `cbor:"data"`
}

type DecodedRuntimeMessage struct {
MessageID uint32 `cbor:"id"`
RunID string `cbor:"run_id"`
RawMessageData cbor.RawMessage `cbor:"data"`
}

type workDoneMessage struct {
type WorkDoneMessage struct {
StepID string `cbor:"step_id"`
OutputID string `cbor:"output_id"`
OutputData any `cbor:"output_data"`
DebugLogs string `cbor:"debug_logs"`
}

type signalMessage struct {
StepID string `cbor:"step_id"`
type SignalMessage struct {
SignalID string `cbor:"signal_id"`
Data any `cbor:"data"`
}

func (s signalMessage) ToInput() schema.Input {
return schema.Input{ID: s.SignalID, InputData: s.Data}
func (s SignalMessage) ToInput(runID string) schema.Input {
return schema.Input{RunID: runID, ID: s.SignalID, InputData: s.Data}
}

type clientDoneMessage struct {
// Empty for now.
}

type ErrorMessage struct {
Error string `cbor:"error"`
StepFatal bool `cbor:"step_fatal"`
ServerFatal bool `cbor:"server_fatal"`
}

func (e ErrorMessage) ToString(runID string) string {
return fmt.Sprintf("RunID: %s, err: %s, step fatal: %t, server fatal: %t", runID, e.Error, e.StepFatal, e.ServerFatal)
}
Loading

0 comments on commit a6e7a9c

Please sign in to comment.