Documentation
¶
Overview ¶
Package ops is the console's operations on the stack behind the services (§8, §9, §11): events and their streams, consumers and dead letters in NATS JetStream; workflows, runs and schedules in Temporal; calling a hook or an activity by hand. It serves backplane.console.v1.EventService, WorkflowService, ScheduleService and CallService on the console's /ws.
backplane is a service on its own SDK, and ops uses the SDK's clients: event.JetStream for NATS (BACKPLANE_NATS_URL), workflows.Client for Temporal (BACKPLANE_TEMPORAL_ADDR). Without one the calls it backs fail with UNAVAILABLE. Hook and activity calls run as short workflows on backplane's own task queue (RegisterWorkflows, through workflows.Register): the run is in Temporal like any other, with memo source = console:<session>.
What the console declares — events, subscriptions, workflows, schedules, hooks, activities — comes from the latest manifest of each service (registry). Mutating calls are logged with their author (the console session): "console action".
Index ¶
- Constants
- Variables
- func HookWorkflowID(service, name, key string) string
- func RegisterWorkflows(r worker.Registry)
- func RunsQuery(req *consolev1.ListRunsRequest, console string) (string, error)
- type ActivityRun
- type CallAPI
- type EventAPI
- func (a EventAPI) GetStream(ctx context.Context, req *consolev1.GetStreamRequest) (*consolev1.GetStreamResponse, error)
- func (a EventAPI) ListDeadLetters(ctx context.Context, req *consolev1.ListDeadLettersRequest) (*consolev1.ListDeadLettersResponse, error)
- func (a EventAPI) ListEvents(ctx context.Context, req *consolev1.ListEventsRequest) (*consolev1.ListEventsResponse, error)
- func (a EventAPI) PeekMessages(ctx context.Context, req *consolev1.PeekMessagesRequest) (*consolev1.PeekMessagesResponse, error)
- func (a EventAPI) PublishTestEvent(ctx context.Context, req *consolev1.PublishTestEventRequest) (*consolev1.PublishTestEventResponse, error)
- func (a EventAPI) PurgeDeadLetters(ctx context.Context, req *consolev1.PurgeDeadLettersRequest) (*consolev1.PurgeDeadLettersResponse, error)
- func (a EventAPI) RedriveDeadLetters(ctx context.Context, req *consolev1.RedriveDeadLettersRequest) (*consolev1.RedriveDeadLettersResponse, error)
- type JetStreamFunc
- type Ops
- type Option
- type ScheduleAPI
- func (a ScheduleAPI) CreateSchedule(ctx context.Context, req *consolev1.CreateScheduleRequest) (*consolev1.CreateScheduleResponse, error)
- func (a ScheduleAPI) DeleteSchedule(ctx context.Context, req *consolev1.DeleteScheduleRequest) (*consolev1.DeleteScheduleResponse, error)
- func (a ScheduleAPI) GetSchedule(ctx context.Context, req *consolev1.GetScheduleRequest) (*consolev1.GetScheduleResponse, error)
- func (a ScheduleAPI) ListSchedules(ctx context.Context, req *consolev1.ListSchedulesRequest) (*consolev1.ListSchedulesResponse, error)
- func (a ScheduleAPI) PauseSchedule(ctx context.Context, req *consolev1.PauseScheduleRequest) (*consolev1.PauseScheduleResponse, error)
- func (a ScheduleAPI) TriggerSchedule(ctx context.Context, req *consolev1.TriggerScheduleRequest) (*consolev1.TriggerScheduleResponse, error)
- func (a ScheduleAPI) UnpauseSchedule(ctx context.Context, req *consolev1.UnpauseScheduleRequest) (*consolev1.UnpauseScheduleResponse, error)
- func (a ScheduleAPI) UpdateSchedule(ctx context.Context, req *consolev1.UpdateScheduleRequest) (*consolev1.UpdateScheduleResponse, error)
- type TemporalFunc
- type WorkflowAPI
- func (a WorkflowAPI) CancelRun(ctx context.Context, req *consolev1.CancelRunRequest) (*consolev1.CancelRunResponse, error)
- func (a WorkflowAPI) GetRun(ctx context.Context, req *consolev1.GetRunRequest) (*consolev1.GetRunResponse, error)
- func (a WorkflowAPI) ListRuns(ctx context.Context, req *consolev1.ListRunsRequest) (*consolev1.ListRunsResponse, error)
- func (a WorkflowAPI) ListWorkflows(ctx context.Context, req *consolev1.ListWorkflowsRequest) (*consolev1.ListWorkflowsResponse, error)
- func (a WorkflowAPI) SignalRun(ctx context.Context, req *consolev1.SignalRunRequest) (*consolev1.SignalRunResponse, error)
- func (a WorkflowAPI) StartWorkflow(ctx context.Context, req *consolev1.StartWorkflowRequest) (*consolev1.StartWorkflowResponse, error)
- func (a WorkflowAPI) TerminateRun(ctx context.Context, req *consolev1.TerminateRunRequest) (*consolev1.TerminateRunResponse, error)
Constants ¶
const ( // CallHookWorkflow raises a hook: the Nexus operation of the hook's // service, input HookCall, output HookResult. CallHookWorkflow = "backplane.console.CallHook.v1" // RunActivityWorkflow executes an activity by name on its service's // queue: input ActivityRun, output ActivityResult. RunActivityWorkflow = "backplane.console.RunActivity.v1" )
Workflows of the calls, on backplane's task queue. The version is in the name, as with backplane.CallHook.v1: a change that is not replay-compatible is a new name.
const SessionMetadata = "bp-console-session"
SessionMetadata is the gRPC metadata the console puts the operator's session in (§11.1).
Variables ¶
var ( // ErrNotSynced: the registry has no snapshot yet. ErrNotSynced = errors.New("ops: registry not synced yet") // ErrNoService: no service of that name. ErrNoService = errors.New("ops: no such service") // ErrNotDeclared: the latest manifest does not declare it. ErrNotDeclared = errors.New("ops: not declared") // ErrInput: the request is malformed. ErrInput = errors.New("ops: invalid request") // ErrPrecondition: the stack is not in a state the call needs. ErrPrecondition = errors.New("ops: failed precondition") // ErrExists: what the call would create exists (a running workflow id). ErrExists = errors.New("ops: already exists") ErrUnavailable = errors.New("ops: unavailable") )
Errors.
var ErrNotSettled = errors.New("schedule change not applied yet")
ErrNotSettled: the schedule did not reach the requested state in time.
Functions ¶
func HookWorkflowID ¶
HookWorkflowID is the run of a console hook call: with a key the same id as the service's own call with hook.Key(key), else a fresh one.
func RegisterWorkflows ¶
RegisterWorkflows adds the call workflows to backplane's worker (give it to workflows.Register).
Types ¶
type ActivityRun ¶
type ActivityRun struct {
Service string `json:"service"`
Name string `json:"name"`
Workflow bool `json:"workflow"` // kind WORKFLOW: a child workflow
Payload []byte `json:"payload"`
Step string `json:"step"`
StartToClose time.Duration `json:"start_to_close"`
Heartbeat time.Duration `json:"heartbeat"`
MaxAttempts int32 `json:"max_attempts"`
}
ActivityRun is the input of RunActivityWorkflow.
type CallAPI ¶
type CallAPI struct {
consolev1.UnimplementedCallServiceServer
// contains filtered or unexported fields
}
CallAPI is backplane.console.v1.CallService.
func (CallAPI) CallHook ¶
func (a CallAPI) CallHook(ctx context.Context, req *consolev1.CallHookRequest) (*consolev1.CallHookResponse, error)
CallHook implements CallService.
func (CallAPI) RunActivity ¶
func (a CallAPI) RunActivity( ctx context.Context, req *consolev1.RunActivityRequest, ) (*consolev1.RunActivityResponse, error)
RunActivity implements CallService.
type EventAPI ¶
type EventAPI struct {
consolev1.UnimplementedEventServiceServer
// contains filtered or unexported fields
}
EventAPI is backplane.console.v1.EventService.
func (EventAPI) GetStream ¶
func (a EventAPI) GetStream( ctx context.Context, req *consolev1.GetStreamRequest, ) (*consolev1.GetStreamResponse, error)
GetStream implements EventService.
func (EventAPI) ListDeadLetters ¶
func (a EventAPI) ListDeadLetters( ctx context.Context, req *consolev1.ListDeadLettersRequest, ) (*consolev1.ListDeadLettersResponse, error)
ListDeadLetters implements EventService.
func (EventAPI) ListEvents ¶
func (a EventAPI) ListEvents( ctx context.Context, req *consolev1.ListEventsRequest, ) (*consolev1.ListEventsResponse, error)
ListEvents implements EventService.
func (EventAPI) PeekMessages ¶
func (a EventAPI) PeekMessages( ctx context.Context, req *consolev1.PeekMessagesRequest, ) (*consolev1.PeekMessagesResponse, error)
PeekMessages implements EventService.
func (EventAPI) PublishTestEvent ¶
func (a EventAPI) PublishTestEvent( ctx context.Context, req *consolev1.PublishTestEventRequest, ) (*consolev1.PublishTestEventResponse, error)
PublishTestEvent implements EventService. The event is the service's: ce-source is the service and ce-type its full name, as its emitter would publish it, so subscribers read it as any other; ce-instance is "backplane", ce-bptest "true" and ce-bpauthor the console session mark it as the console's.
func (EventAPI) PurgeDeadLetters ¶
func (a EventAPI) PurgeDeadLetters( ctx context.Context, req *consolev1.PurgeDeadLettersRequest, ) (*consolev1.PurgeDeadLettersResponse, error)
PurgeDeadLetters implements EventService.
func (EventAPI) RedriveDeadLetters ¶
func (a EventAPI) RedriveDeadLetters( ctx context.Context, req *consolev1.RedriveDeadLettersRequest, ) (*consolev1.RedriveDeadLettersResponse, error)
RedriveDeadLetters implements EventService. Each dead letter is published back to its reactor alone — to the reactor's redrive subject bp.<source>._redrive.<subscriber>.<consumer> in the source stream, which the reactor's consumer filters on next to its event (§8) — and then removed from the dead-letter stream. The reactor handles it as a new delivery (attempt 1, its full MaxDeliver again; ce-id unchanged, so an idempotent handler recognizes it); failing again, it becomes a new dead letter. Nats-Msg-Id redrive:<durable>:<seq> keeps a retried redrive of the same dead letter single within the dedup window.
type JetStreamFunc ¶
JetStreamFunc gives the NATS client; TemporalFunc the Temporal one.
type Ops ¶
Ops is the component. Every call reads the registry snapshot and asks NATS or Temporal; the one thing it remembers is whether Temporal's visibility refused ORDER BY.
func Detached ¶
Detached is Ops without a node of the tree — it logs nowhere — for tests and tools: give it WithJetStream and WithTemporal, else the calls they back fail with UNAVAILABLE.
func (*Ops) Register ¶
func (o *Ops) Register(r grpc.ServiceRegistrar)
Register registers the console services on r.
type Option ¶
type Option func(*Ops)
Option configures New.
func Author ¶
Author names who made a call from its context; default: the console session in SessionMetadata as console:<id>, else "admin".
func Namespace ¶
Namespace is the Temporal namespace of the client (default "default"): the calls that go to Temporal's API directly name it.
func WithJetStream ¶
func WithJetStream(fn JetStreamFunc) Option
WithJetStream replaces the SDK's NATS client (tests).
func WithTemporal ¶
func WithTemporal(fn TemporalFunc, queue string) Option
WithTemporal replaces the SDK's Temporal client and backplane's task queue the call workflows run on (tests).
type ScheduleAPI ¶
type ScheduleAPI struct {
consolev1.UnimplementedScheduleServiceServer
// contains filtered or unexported fields
}
ScheduleAPI is backplane.console.v1.ScheduleService.
func (ScheduleAPI) CreateSchedule ¶
func (a ScheduleAPI) CreateSchedule(ctx context.Context, req *consolev1.CreateScheduleRequest) (*consolev1.CreateScheduleResponse, error, )
CreateSchedule uses a declared workflow and the platform's queue convention.
func (ScheduleAPI) DeleteSchedule ¶
func (a ScheduleAPI) DeleteSchedule(ctx context.Context, req *consolev1.DeleteScheduleRequest) (*consolev1.DeleteScheduleResponse, error, )
DeleteSchedule does not cancel running workflow executions.
func (ScheduleAPI) GetSchedule ¶
func (a ScheduleAPI) GetSchedule(ctx context.Context, req *consolev1.GetScheduleRequest) (*consolev1.GetScheduleResponse, error, )
GetSchedule reads from Temporal without requiring a currently running service.
func (ScheduleAPI) ListSchedules ¶
func (a ScheduleAPI) ListSchedules( ctx context.Context, req *consolev1.ListSchedulesRequest, ) (*consolev1.ListSchedulesResponse, error)
ListSchedules implements ScheduleService.
func (ScheduleAPI) PauseSchedule ¶
func (a ScheduleAPI) PauseSchedule( ctx context.Context, req *consolev1.PauseScheduleRequest, ) (*consolev1.PauseScheduleResponse, error)
PauseSchedule implements ScheduleService.
func (ScheduleAPI) TriggerSchedule ¶
func (a ScheduleAPI) TriggerSchedule( ctx context.Context, req *consolev1.TriggerScheduleRequest, ) (*consolev1.TriggerScheduleResponse, error)
TriggerSchedule implements ScheduleService.
func (ScheduleAPI) UnpauseSchedule ¶
func (a ScheduleAPI) UnpauseSchedule( ctx context.Context, req *consolev1.UnpauseScheduleRequest, ) (*consolev1.UnpauseScheduleResponse, error)
UnpauseSchedule implements ScheduleService.
func (ScheduleAPI) UpdateSchedule ¶
func (a ScheduleAPI) UpdateSchedule(ctx context.Context, req *consolev1.UpdateScheduleRequest) (*consolev1.UpdateScheduleResponse, error, )
UpdateSchedule preserves state and advanced action settings. Temporal checks the conflict token atomically, across all platform replicas and external tools.
type TemporalFunc ¶
JetStreamFunc gives the NATS client; TemporalFunc the Temporal one.
type WorkflowAPI ¶
type WorkflowAPI struct {
consolev1.UnimplementedWorkflowServiceServer
// contains filtered or unexported fields
}
WorkflowAPI is backplane.console.v1.WorkflowService.
func (WorkflowAPI) CancelRun ¶
func (a WorkflowAPI) CancelRun( ctx context.Context, req *consolev1.CancelRunRequest, ) (*consolev1.CancelRunResponse, error)
CancelRun implements WorkflowService.
func (WorkflowAPI) GetRun ¶
func (a WorkflowAPI) GetRun(ctx context.Context, req *consolev1.GetRunRequest) (*consolev1.GetRunResponse, error)
GetRun implements WorkflowService.
func (WorkflowAPI) ListRuns ¶
func (a WorkflowAPI) ListRuns( ctx context.Context, req *consolev1.ListRunsRequest, ) (*consolev1.ListRunsResponse, error)
ListRuns implements WorkflowService.
func (WorkflowAPI) ListWorkflows ¶
func (a WorkflowAPI) ListWorkflows( ctx context.Context, req *consolev1.ListWorkflowsRequest, ) (*consolev1.ListWorkflowsResponse, error)
ListWorkflows implements WorkflowService. Declarations come from the manifests; the pollers of each task queue from Temporal when it answers.
func (WorkflowAPI) SignalRun ¶
func (a WorkflowAPI) SignalRun( ctx context.Context, req *consolev1.SignalRunRequest, ) (*consolev1.SignalRunResponse, error)
SignalRun implements WorkflowService.
func (WorkflowAPI) StartWorkflow ¶
func (a WorkflowAPI) StartWorkflow( ctx context.Context, req *consolev1.StartWorkflowRequest, ) (*consolev1.StartWorkflowResponse, error)
StartWorkflow implements WorkflowService.
func (WorkflowAPI) TerminateRun ¶
func (a WorkflowAPI) TerminateRun( ctx context.Context, req *consolev1.TerminateRunRequest, ) (*consolev1.TerminateRunResponse, error)
TerminateRun implements WorkflowService.