atp

package
v0.12.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package atp provides a client and server implementation of the Arcaflow Transport Protocol, which transports schema information and calls plugins.

Index

Constants

View Source
const (
	MessageTypeWorkStart  uint32 = 1
	MessageTypeWorkDone   uint32 = 2
	MessageTypeSignal     uint32 = 3
	MessageTypeClientDone uint32 = 4
	MessageTypeError      uint32 = 5
)

All messages that can be contained in a RuntimeMessage struct.

View Source
const ProtocolVersion int64 = 3

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// ReadSchema reads the schema from the ATP server.
	ReadSchema() (*schema.SchemaSchema, error)
	// Execute executes a step with a given context and returns the resulting output. Assumes you called ReadSchema first.
	Execute(input schema.Input, receivedSignals chan schema.Input, emittedSignals chan<- schema.Input) ExecutionResult
	Close() error
	Encoder() *cbor.Encoder
	Decoder() *cbor.Decoder
}

Client is the way to read information from the ATP server and then send a task to it in the form of a step. A step can only be sent once, but signals can be sent until the step is over. It is a single session.

func NewClient

func NewClient(
	channel ClientChannel,
) Client

NewClient creates a new ATP client (part of the engine code).

func NewClientWithLogger

func NewClientWithLogger(
	channel ClientChannel,
	logger log.Logger,
) Client

NewClientWithLogger creates a new ATP client (part of the engine code) with a logger.

type ClientChannel

type ClientChannel interface {
	io.Reader
	io.Writer
	io.Closer
}

ClientChannel holds the methods to talking to an ATP server (plugin).

type DecodedRuntimeMessage added in v0.4.1

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

type ErrorMessage added in v0.5.0

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

func (ErrorMessage) ToString added in v0.5.0

func (e ErrorMessage) ToString(runID string) string

type ExecutionResult added in v0.5.0

type ExecutionResult struct {
	OutputID   string
	OutputData any
	Error      error
}

func NewErrorExecutionResult added in v0.5.0

func NewErrorExecutionResult(err error) ExecutionResult

type HelloMessage added in v0.2.0

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

type RuntimeMessage added in v0.4.1

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

type ServerError added in v0.5.0

type ServerError struct {
	RunID       string
	Err         error
	StepFatal   bool
	ServerFatal bool
}

func RunATPServer

func RunATPServer(
	ctx context.Context,
	stdin io.ReadCloser,
	stdout io.WriteCloser,
	pluginSchema *schema.CallableSchema,
) []*ServerError

RunATPServer runs an ArcaflowTransportProtocol server with a given schema.

func (ServerError) String added in v0.5.0

func (e ServerError) String() string

type SignalMessage added in v0.5.0

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

func (SignalMessage) ToInput added in v0.5.0

func (s SignalMessage) ToInput(runID string) schema.Input

type WorkDoneMessage added in v0.5.0

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

type WorkStartMessage added in v0.5.0

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL