priorityflow

package
v1.37.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Hostname = priorityflowapi.Hostname
	Version  = 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Intermediate

type Intermediate struct {
	*connector.Connector
	ToDo
}

Intermediate extends and customizes the generic base connector.

func NewIntermediate

func NewIntermediate(impl ToDo) *Intermediate

NewIntermediate creates a new instance of the intermediate.

type Mock

type Mock struct {
	*Intermediate
	// contains filtered or unexported fields
}

Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.

func NewMock

func NewMock() *Mock

NewMock creates a new mockable version of the microservice.

func (*Mock) MockPriority

func (svc *Mock) MockPriority(handler func(ctx context.Context, flow *workflow.Flow, tag string, delayMs int) (recorded bool, err error)) *Mock

MockPriority sets up a mock handler for the Priority workflow. The handler receives typed inputs from the workflow's state and returns typed outputs. A nil handler clears the mock.

func (*Mock) MockRecord

func (svc *Mock) MockRecord(handler func(ctx context.Context, flow *workflow.Flow) (recorded bool, err error)) *Mock

MockRecord sets up a mock handler for Record.

func (*Mock) OnShutdown

func (svc *Mock) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Mock) OnStartup

func (svc *Mock) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Mock) Priority

func (svc *Mock) Priority(ctx context.Context) (graph *workflow.Graph, err error)

Priority returns the workflow graph, or a mocked graph if MockPriority was called.

func (*Mock) Record

func (svc *Mock) Record(ctx context.Context, flow *workflow.Flow) (recorded bool, err error)

Record executes the mock handler.

type Service

type Service struct {
	*Intermediate // IMPORTANT: Do not remove
	// contains filtered or unexported fields
}

Service implements priorityflow.verify, exercising priority-based dispatch and starvation by design.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) Init

func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service

Init enables a single-statement pattern for initializing the microservice.

func (*Service) OnShutdown

func (svc *Service) OnShutdown(ctx context.Context) (err error)

OnShutdown is called when the microservice is shut down.

func (*Service) OnStartup

func (svc *Service) OnStartup(ctx context.Context) (err error)

OnStartup is called when the microservice is started up.

func (*Service) Order

func (svc *Service) Order() []string

Order returns the tags in the order their flows were dispatched, oldest first.

func (*Service) Priority

func (svc *Service) Priority(ctx context.Context) (graph *workflow.Graph, err error)

Priority defines the single-task graph (record -> END) used to observe dispatch order under saturation. The graph carries no timing or priority; priority is a per-flow option supplied at Create.

func (*Service) Record

func (svc *Service) Record(ctx context.Context, flow *workflow.Flow) (recorded bool, err error)

Record sleeps for the requested delay, then appends its tag to the completion order. The delay forces saturation so the order in which a single worker picks up flows reflects the foreman's selection, not arrival timing.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	Record(ctx context.Context, flow *workflow.Flow) (recorded bool, err error) // MARKER: Record
	Priority(ctx context.Context) (graph *workflow.Graph, err error)            // MARKER: Priority
}

ToDo is implemented by the service or mock.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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