operatortest

package
v0.109.2 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package operatortest holds a sample contract operator for tests. Echo is written against pkg/operator only, so the same handler is opened through the in-process host in unit tests and through the gRPC host in the operator end-to-end suite; that both work is the rule the contract exists for.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Echo

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

Echo completes every START_STEP_RUN it is handed with the task's input as its output. It reports STARTED at once and COMPLETED from a goroutine, the way an operator whose work takes time would, and tracks the goroutines so Drain can wait for them.

func (*Echo) Drain

func (e *Echo) Drain(ctx context.Context)

Drain implements operator.Operator: it waits for every report in flight, or for ctx.

func (*Echo) HandleAction

func (e *Echo) HandleAction(_ context.Context, action *contracts.AssignedAction) error

HandleAction implements operator.ActionHandler.

func (*Echo) Handled

func (e *Echo) Handled() int

Handled is the number of start actions received.

func (*Echo) Start

func (e *Echo) Start(_ context.Context, s operator.Session) error

Start implements operator.Operator: the session is what the echo reports through.

type Session

type Session struct {

	// PauseErr, when set, fails Pause.
	PauseErr error
	// contains filtered or unexported fields
}

Session is a recording operator.Session for tests of operators and hosts' callers: events, deltas, flushes, pauses and the close are recorded in order; durable channels and workflows are not supported.

func NewSession

func NewSession(tenantId, operatorId uuid.UUID) *Session

NewSession builds a session registered for the given tenant, operator and a fresh worker.

func (*Session) AddActions

func (s *Session) AddActions(_ context.Context, ids []string) error

func (*Session) Added

func (s *Session) Added() [][]string

Added returns the add deltas issued so far, in order.

func (*Session) Close

func (s *Session) Close(context.Context) error

func (*Session) Closed

func (s *Session) Closed() bool

Closed reports whether Close was called.

func (*Session) Done

func (s *Session) Done() <-chan struct{}

Done implements operator.Session; it closes with Close.

func (*Session) Err

func (s *Session) Err() error

Err implements operator.Session; the recording session never gives up on its own.

func (*Session) Events

func (s *Session) Events() []*contracts.StepActionEvent

Events returns the step action events reported so far, in order.

func (*Session) Flush

func (s *Session) Flush(context.Context) error

func (*Session) Flushes

func (s *Session) Flushes() int

Flushes is the number of flushes so far.

func (*Session) OpenDurable

func (*Session) Ops

func (s *Session) Ops() []string

Ops returns the lifecycle calls (pause, close) in order.

func (*Session) Pause

func (s *Session) Pause(context.Context) error

func (*Session) PutWorkflow

func (*Session) Registration

func (s *Session) Registration() operator.Registration

func (*Session) RemoveActions

func (s *Session) RemoveActions(_ context.Context, ids []string) error

func (*Session) Removed

func (s *Session) Removed() [][]string

Removed returns the remove deltas issued so far, in order.

func (*Session) SendStepActionEvent

func (s *Session) SendStepActionEvent(_ context.Context, ev *contracts.StepActionEvent) error

Jump to

Keyboard shortcuts

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