-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into object-ref-compatibility-fix
- Loading branch information
Showing
9 changed files
with
1,035 additions
and
298 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
Oops, something went wrong.