protocol

package
v1.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DebugNone disables all debug messages.
	DebugNone = iota

	// DebugNormal renders all messages into console.
	DebugNormal

	// DebugHumanized enables color highlights for messages.
	DebugHumanized
)

Variables

This section is empty.

Functions

func NewDataConverter

func NewDataConverter(fallback converter.DataConverter) converter.DataConverter

NewDataConverter creates new data converter.

Types

type ActivityInfo

type ActivityInfo struct {
	// Name describes public activity name.
	Name string `json:"name"`
}

ActivityInfo describes single worker activity.

type Cancel

type Cancel struct {
	// CommandIDs to be canceled.
	CommandIDs []uint64 `json:"ids"`
}

Cancel one or multiple internal promises (activities, local activities, timers, child workflows).

type CancelExternalWorkflow

type CancelExternalWorkflow struct {
	Namespace  string `json:"namespace"`
	WorkflowID string `json:"workflowID"`
	RunID      string `json:"runID"`
}

CancelExternalWorkflow canceller external workflow.

type CancelWorkflow

type CancelWorkflow struct {
	// RunID workflow run id.
	RunID string `json:"runId"`
}

CancelWorkflow asks worker to gracefully stop workflow, if possible (signal).

type Codec

type Codec interface {
	// WithLogger creates new codes instance with attached logger.
	WithLogger(logger.Logger) Codec

	// GetName returns codec name.
	GetName() string

	// Execute sends message to worker and waits for the response.
	Execute(e Endpoint, ctx Context, msg ...Message) ([]Message, error)
}

Codec manages payload encoding and decoding while communication with underlying worker.

func NewJSONCodec

func NewJSONCodec(level DebugLevel, logger logger.Logger) Codec

NewJSONCodec creates new Json communication codec.

func NewProtoCodec

func NewProtoCodec() Codec

NewProtoCodec creates new Proto communication codec.

type CompleteWorkflow

type CompleteWorkflow struct{}

CompleteWorkflow sent by worker to complete workflow. Might include additional error as part of the payload.

type Context

type Context struct {
	// TaskQueue associates message batch with the specific task queue in underlying worker.
	TaskQueue string `json:"taskQueue,omitempty"`

	// TickTime associated current or historical time with message batch.
	TickTime string `json:"tickTime,omitempty"`

	// Replay indicates that current message batch is historical.
	Replay bool `json:"replay,omitempty"`
}

Context provides worker information about currently. Context can be empty for server level commands.

func (Context) IsEmpty

func (ctx Context) IsEmpty() bool

IsEmpty only check if task queue set.

type ContinueAsNew

type ContinueAsNew struct {
	// Result defines workflow execution result.
	Name string `json:"name"`

	// Options for continued as new workflow.
	Options struct {
		TaskQueueName            string
		WorkflowExecutionTimeout time.Duration
		WorkflowRunTimeout       time.Duration
		WorkflowTaskTimeout      time.Duration
	} `json:"options"`
}

ContinueAsNew restarts workflow with new running instance.

type DataConverter

type DataConverter struct {
	// contains filtered or unexported fields
}

DataConverter wraps Temporal data converter to enable direct access to the payloads.

func (*DataConverter) FromPayload

func (r *DataConverter) FromPayload(payload *commonpb.Payload, valuePtr interface{}) error

FromPayload converts single value from payload.

func (*DataConverter) FromPayloads

func (r *DataConverter) FromPayloads(payloads *commonpb.Payloads, valuePtrs ...interface{}) error

FromPayloads converts to a list of values of different types. Useful for deserializing arguments of function invocations.

func (*DataConverter) ToPayload

func (r *DataConverter) ToPayload(value interface{}) (*commonpb.Payload, error)

ToPayload converts single value to payload.

func (*DataConverter) ToPayloads

func (r *DataConverter) ToPayloads(values ...interface{}) (*commonpb.Payloads, error)

ToPayloads converts a list of values.

func (*DataConverter) ToString

func (r *DataConverter) ToString(input *commonpb.Payload) string

ToString converts payload object into human readable string.

func (*DataConverter) ToStrings

func (r *DataConverter) ToStrings(input *commonpb.Payloads) []string

ToStrings converts payloads object into human readable strings.

type DebugLevel

type DebugLevel int

DebugLevel configures debug level.

type DestroyWorkflow

type DestroyWorkflow struct {
	// RunID workflow run id.
	RunID string `json:"runId"`
}

DestroyWorkflow asks worker to offload workflow from memory.

type Endpoint

type Endpoint interface {
	// Exec used to execute payload on the worker
	Exec(p *payload.Payload) (*payload.Payload, error)
}

Endpoint provides the ability to send and receive messages.

type ExecuteActivity

type ExecuteActivity struct {
	// Name defines activity name.
	Name string `json:"name"`
	// Options to run activity.
	Options bindings.ExecuteActivityOptions `json:"options,omitempty"`
}

ExecuteActivity command by workflow worker.

func (ExecuteActivity) ActivityParams

ActivityParams maps activity command to activity params.

type ExecuteChildWorkflow

type ExecuteChildWorkflow struct {
	// Name defines workflow name.
	Name string `json:"name"`
	// Options to run activity.
	Options bindings.WorkflowOptions `json:"options,omitempty"`
}

ExecuteChildWorkflow executes child workflow.

func (ExecuteChildWorkflow) WorkflowParams

WorkflowParams maps workflow command to workflow params.

type GetChildWorkflowExecution

type GetChildWorkflowExecution struct {
	// ID of child workflow command.
	ID uint64 `json:"id"`
}

GetChildWorkflowExecution returns the WorkflowID and RunId of child workflow.

type GetStackTrace

type GetStackTrace struct {
	// RunID workflow run id.
	RunID string `json:"runId"`
}

GetStackTrace asks worker to offload workflow from memory.

type GetVersion

type GetVersion struct {
	ChangeID     string `json:"changeID"`
	MinSupported int    `json:"minSupported"`
	MaxSupported int    `json:"maxSupported"`
}

GetVersion requests version marker.

type GetWorkerInfo

type GetWorkerInfo struct{}

GetWorkerInfo reads worker information.

type InvokeActivity

type InvokeActivity struct {
	// Name defines activity name.
	Name string `json:"name"`

	// Info contains execution context.
	Info activity.Info `json:"info"`

	// HeartbeatDetails indicates that the payload also contains last heartbeat details.
	HeartbeatDetails int `json:"heartbeatDetails,omitempty"`
}

InvokeActivity invokes activity.

type InvokeQuery

type InvokeQuery struct {
	// RunID workflow run id.
	RunID string `json:"runId"`
	// Name of the query.
	Name string `json:"name"`
}

InvokeQuery invokes query with a set of arguments.

type InvokeSignal

type InvokeSignal struct {
	// RunID workflow run id.
	RunID string `json:"runId"`

	// Name of the signal.
	Name string `json:"name"`
}

InvokeSignal invokes signal with a set of arguments.

type JSONCodec

type JSONCodec struct {
	// contains filtered or unexported fields
}

JSONCodec can be used for debugging and log capturing reasons.

func (*JSONCodec) Execute

func (c *JSONCodec) Execute(e Endpoint, ctx Context, msg ...Message) ([]Message, error)

Execute exchanges commands with worker.

func (*JSONCodec) GetName

func (c *JSONCodec) GetName() string

GetName returns codec name.

func (*JSONCodec) WithLogger

func (c *JSONCodec) WithLogger(logger logger.Logger) Codec

WithLogger creates new codes instance with attached logger.

type Message

type Message struct {
	// ID contains ID of the command, response or error.
	ID uint64 `json:"id"`

	// Command of the message in unmarshalled form. Pointer.
	Command interface{} `json:"command,omitempty"`

	// Failure associated with command id.
	Failure *failure.Failure `json:"failure,omitempty"`

	// Payloads contains message specific payloads in binary format.
	Payloads *commonpb.Payloads `json:"payloads,omitempty"`
}

Message used to exchange the send commands and receive responses from underlying workers.

func (Message) IsCommand

func (msg Message) IsCommand() bool

IsCommand returns true if message carries request.

type NewTimer

type NewTimer struct {
	// Milliseconds defines timer duration.
	Milliseconds int `json:"ms"`
}

NewTimer starts new timer.

func (NewTimer) ToDuration

func (cmd NewTimer) ToDuration() time.Duration

ToDuration converts timer command to time.Duration.

type Panic

type Panic struct {
	// Message to include into the error.
	Message string `json:"message"`
}

Panic triggers panic in workflow process.

type ProtoCodec

type ProtoCodec struct{}

ProtoCodec uses protobuf to exchange messages with underlying workers.

func (*ProtoCodec) Execute

func (c *ProtoCodec) Execute(e Endpoint, ctx Context, msg ...Message) ([]Message, error)

Execute exchanges commands with worker.

func (*ProtoCodec) GetName

func (c *ProtoCodec) GetName() string

GetName returns codec name.

func (*ProtoCodec) WithLogger

func (c *ProtoCodec) WithLogger(logger logger.Logger) Codec

WithLogger creates new codes instance with attached logger.

type SideEffect

type SideEffect struct{}

SideEffect to be recorded into the history.

type SignalExternalWorkflow

type SignalExternalWorkflow struct {
	Namespace         string `json:"namespace"`
	WorkflowID        string `json:"workflowID"`
	RunID             string `json:"runID"`
	Signal            string `json:"signal"`
	ChildWorkflowOnly bool   `json:"childWorkflowOnly"`
}

SignalExternalWorkflow sends signal to external workflow.

type StartWorkflow

type StartWorkflow struct {
	// Info to define workflow context.
	Info *workflow.Info `json:"info"`

	// LastCompletion contains offset of last completion results.
	LastCompletion int `json:"lastCompletion,omitempty"`
}

StartWorkflow sends worker command to start workflow.

type WorkerInfo

type WorkerInfo struct {
	// TaskQueue assigned to the worker.
	TaskQueue string `json:"taskQueue"`

	// Options describe worker options.
	Options worker.Options `json:"options,omitempty"`

	// Workflows provided by the worker.
	Workflows []WorkflowInfo

	// Activities provided by the worker.
	Activities []ActivityInfo
}

WorkerInfo lists available task queues, workflows and activities.

func FetchWorkerInfo

func FetchWorkerInfo(c Codec, e Endpoint, dc converter.DataConverter) ([]WorkerInfo, error)

FetchWorkerInfo fetches information about all underlying workers (can be multiplexed inside single process).

type WorkflowInfo

type WorkflowInfo struct {
	// Name of the workflow.
	Name string `json:"name"`

	// Queries pre-defined for the workflow type.
	Queries []string `json:"queries"`

	// Signals pre-defined for the workflow type.
	Signals []string `json:"signals"`
}

WorkflowInfo describes single worker workflow.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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