distributedbackpressureflow

package
v1.38.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	Hostname = distributedbackpressureflowapi.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) Bounded

func (svc *Mock) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)

Bounded executes the mock handler.

func (*Mock) DistributedBackpressure

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

DistributedBackpressure returns the workflow graph, or a mocked graph if MockDistributedBackpressure was called.

func (*Mock) MockBounded

func (svc *Mock) MockBounded(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock

MockBounded sets up a mock handler for Bounded.

func (*Mock) MockDistributedBackpressure

func (svc *Mock) MockDistributedBackpressure(handler func(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)) *Mock

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

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.

type Service

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

Service implements distributedbackpressureflow.verify, exercising adaptive concurrency under multi-replica and multi-shard deployment.

func NewService

func NewService() *Service

NewService creates a new instance of the microservice.

func (*Service) Bounded

func (svc *Service) Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error)

Bounded self-emits http.StatusTooManyRequests above its cap. Both replicas of this fixture share the same Service singleton (registered once in the test app), so the cap is genuinely cluster-wide.

func (*Service) DistributedBackpressure

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

DistributedBackpressure is a single-task graph routing through Bounded.

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) Observed

func (svc *Service) Observed() (peak int, rejections int, completions int)

Observed returns (peak in-flight, total rejections, total completions).

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) SetCap

func (svc *Service) SetCap(cap int) *Service

SetCap configures the task's self-limit.

func (*Service) SetDwell

func (svc *Service) SetDwell(d time.Duration) *Service

SetDwell configures the task's per-execution sleep.

type ToDo

type ToDo interface {
	OnStartup(ctx context.Context) (err error)
	OnShutdown(ctx context.Context) (err error)
	Bounded(ctx context.Context, flow *workflow.Flow, tag string) (tallied bool, err error) // MARKER: Bounded
	DistributedBackpressure(ctx context.Context) (graph *workflow.Graph, err error)         // MARKER: DistributedBackpressure
}

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