Documentation
¶
Overview ¶
Package container implements the Flow "container" block (Design B / #43 PoC).
Operator model: a pipeline stage whose implementation is a Docker image. Transport is HTTP request/response (not upstream AMQP). Lifecycle is tied to the flow: the container is started at Instantiate (flow start) and removed on Stopper.Stop (flow stop).
Index ¶
- Constants
- func Constructor(name string, config map[string]any, deps flow.Deps) (flow.Block, error)
- func New(name string, config map[string]any, deps flow.Deps, runner Runner) (flow.Block, error)
- func SetDefaultRunner(r Runner) (restore func())
- type Block
- type Bridge
- type CLIRunner
- type Config
- type Instance
- type Runner
- type Spec
- type Waiter
Constants ¶
const Type = "container"
Type is the pipeline block_type string.
Variables ¶
This section is empty.
Functions ¶
func Constructor ¶
Constructor is the catalog entry point (uses defaultRunner).
func SetDefaultRunner ¶
func SetDefaultRunner(r Runner) (restore func())
SetDefaultRunner replaces the Docker runner used by the catalog constructor. Prefer New in unit tests. Returns a restore function.
Types ¶
type Block ¶
type Block struct {
// contains filtered or unexported fields
}
Block is a transform that round-trips each Message through a container.
type Bridge ¶
Bridge POSTs FlowMessages to a container HTTP endpoint.
type CLIRunner ¶
type CLIRunner struct {
// Docker is the docker binary name or path (default "docker").
Docker string
// Run is optional; when set, tests can intercept command execution.
// argv[0] is the docker binary. Returns stdout, stderr, error.
Run func(ctx context.Context, name string, args ...string) (stdout, stderr string, err error)
}
CLIRunner shells out to the docker CLI. Suitable for PoC; MVP may switch to the Engine API client for cancel/cleanup.
type Config ¶
type Config struct {
Image string
Nested map[string]any // opaque JSON for ASTRATE_FLOW_CONFIG
ContainerPort int
Timeout time.Duration
ReadyTimeout time.Duration
}
Config is the parsed block configuration.
type Instance ¶
type Instance interface {
// BaseURL is the host URL to POST messages to (e.g. http://127.0.0.1:49152).
BaseURL() string
// ID is the docker container id (or a test fake id).
ID() string
// Stop stops and removes the container (best-effort).
Stop(ctx context.Context) error
}
Instance is a running container that serves the HTTP bridge.
type Spec ¶
type Spec struct {
Image string
// ContainerPort is the HTTP port inside the container (default 8080).
ContainerPort int
// FlowConfigJSON is passed as ASTRATE_FLOW_CONFIG.
FlowConfigJSON string
// Labels are applied to the container (astrate.*).
Labels map[string]string
// Name is an optional docker container name (must be unique).
Name string
}
Spec describes a container to start for a flow block.
type Waiter ¶
type Waiter interface {
// Wait blocks until the container exits (or ctx is cancelled) and returns
// its exit code.
Wait(ctx context.Context) (exitCode int, err error)
}
Waiter is implemented by Instances that can block until their container exits. The block's exit watcher uses it to detect unexpected death (#45).