Documentation
¶
Overview ¶
Package flowresult handles the side effects of flow execution: response persistence, execution state tracking, and event publishing.
Index ¶
- type EventPublisher
- type ExecutionStateTracker
- type ExecutionStateTrackerOpts
- type NoopResultProcessor
- func (n *NoopResultProcessor) GraphQLResponseChan() chan ngraphql.NodeGraphQLSideResp
- func (n *NoopResultProcessor) HTTPResponseChan() chan nrequest.NodeRequestSideResp
- func (n *NoopResultProcessor) NodeStateChan() chan runner.FlowNodeStatus
- func (n *NoopResultProcessor) Start()
- func (n *NoopResultProcessor) Wait()
- type ResponseDrain
- type ResponseDrainOpts
- type ResultProcessor
- type ServerResultProcessor
- func (p *ServerResultProcessor) GraphQLResponseChan() chan ngraphql.NodeGraphQLSideResp
- func (p *ServerResultProcessor) HTTPResponseChan() chan nrequest.NodeRequestSideResp
- func (p *ServerResultProcessor) NodeStateChan() chan runner.FlowNodeStatus
- func (p *ServerResultProcessor) Start()
- func (p *ServerResultProcessor) Wait()
- type ServerResultProcessorOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventPublisher ¶
type EventPublisher interface {
PublishHTTPResponse(response mhttp.HTTPResponse, workspaceID idwrap.IDWrap)
PublishHTTPResponseHeader(header mhttp.HTTPResponseHeader, workspaceID idwrap.IDWrap)
PublishHTTPResponseAssert(assert mhttp.HTTPResponseAssert, workspaceID idwrap.IDWrap)
PublishGraphQLResponse(response mgraphql.GraphQLResponse, workspaceID idwrap.IDWrap)
PublishGraphQLResponseHeader(header mgraphql.GraphQLResponseHeader, workspaceID idwrap.IDWrap)
PublishGraphQLResponseAssert(assert mgraphql.GraphQLResponseAssert, workspaceID idwrap.IDWrap)
PublishExecution(eventType string, execution mflow.NodeExecution, flowID idwrap.IDWrap)
PublishNodeState(flowID, originalNodeID idwrap.IDWrap, state mflow.NodeState, info string)
PublishEdgeState(edge mflow.Edge)
PublishLog(flowID idwrap.IDWrap, status runner.FlowNodeStatus)
}
EventPublisher abstracts the event stream publishing that happens during flow execution. The rflowv2 package provides the concrete implementation backed by eventstream.SyncStreamer.
type ExecutionStateTracker ¶
type ExecutionStateTracker struct {
// contains filtered or unexported fields
}
ExecutionStateTracker handles node execution lifecycle events: - Persists NodeExecution records (with dedup via execution cache) - Updates node and edge states in the database - Waits for response signals from ResponseDrain before publishing execution events - Publishes node state, edge state, and log events
type ExecutionStateTrackerOpts ¶
type ExecutionStateTrackerOpts struct {
FlowID idwrap.IDWrap
BufSize int
NodeKindMap map[idwrap.IDWrap]mflow.NodeKind
EdgesBySource map[idwrap.IDWrap][]mflow.Edge
InverseNodeIDMap map[string]idwrap.IDWrap
Drain *ResponseDrain
NodeExecutionService *sflow.NodeExecutionService
NodeService *sflow.NodeService
EdgeService *sflow.EdgeService
Publisher EventPublisher
Logger *slog.Logger
}
ExecutionStateTrackerOpts configures an ExecutionStateTracker.
type NoopResultProcessor ¶
type NoopResultProcessor struct {
// contains filtered or unexported fields
}
NoopResultProcessor discards all execution results. Used for testing and CLI where persistence/events are not needed.
func NewNoopResultProcessor ¶
func NewNoopResultProcessor(nodeCount int) *NoopResultProcessor
func (*NoopResultProcessor) GraphQLResponseChan ¶
func (n *NoopResultProcessor) GraphQLResponseChan() chan ngraphql.NodeGraphQLSideResp
func (*NoopResultProcessor) HTTPResponseChan ¶
func (n *NoopResultProcessor) HTTPResponseChan() chan nrequest.NodeRequestSideResp
func (*NoopResultProcessor) NodeStateChan ¶
func (n *NoopResultProcessor) NodeStateChan() chan runner.FlowNodeStatus
func (*NoopResultProcessor) Start ¶
func (n *NoopResultProcessor) Start()
func (*NoopResultProcessor) Wait ¶
func (n *NoopResultProcessor) Wait()
type ResponseDrain ¶
type ResponseDrain struct {
// contains filtered or unexported fields
}
ResponseDrain persists HTTP and GraphQL responses produced during flow execution. It runs two goroutines (one per protocol) that consume from channels, persist to the database, publish events, and signal completion via per-response channels.
The signal mechanism allows the ExecutionStateTracker to wait for a response to be published before publishing the execution event that references it, ensuring correct event ordering for frontends.
func (*ResponseDrain) WaitForResponse ¶
func (d *ResponseDrain) WaitForResponse(respID string)
WaitForResponse blocks until the response with the given ID has been persisted and its event published. Call this before publishing an execution event that references the response.
type ResponseDrainOpts ¶
type ResponseDrainOpts struct {
WorkspaceID idwrap.IDWrap
BufSize int
HTTPResponseService shttp.HttpResponseService
GraphQLResponseService sgraphql.GraphQLResponseService
Publisher EventPublisher
Logger *slog.Logger
}
ResponseDrainOpts configures a ResponseDrain.
type ResultProcessor ¶
type ResultProcessor interface {
// HTTPResponseChan returns the channel for HTTP response side-effects.
// Pass this to the node builder so request nodes can send responses.
HTTPResponseChan() chan nrequest.NodeRequestSideResp
// GraphQLResponseChan returns the channel for GraphQL response side-effects.
// Pass this to the node builder so GraphQL nodes can send responses.
GraphQLResponseChan() chan ngraphql.NodeGraphQLSideResp
// NodeStateChan returns the channel for node execution status events.
// Pass this to the FlowRunner via FlowEventChannels.NodeStates.
NodeStateChan() chan runner.FlowNodeStatus
// Start begins the drain goroutines that process responses and status events.
// Must be called before the flow runner starts.
Start()
// Wait blocks until all processing is complete.
// The runner must have finished (closing NodeStateChan) before Wait returns.
// Wait also closes the response channels and waits for their drains.
Wait()
}
ResultProcessor handles the side effects of flow execution: response persistence, execution state tracking, and event publishing.
Channel accessors are exposed because local execution requires wiring channels between the node builder (producer) and the processor (consumer). In a distributed scenario, remote workers would use their own channels locally and send results back via RPC to a different ResultProcessor implementation that doesn't need these channels.
type ServerResultProcessor ¶
type ServerResultProcessor struct {
// contains filtered or unexported fields
}
ServerResultProcessor coordinates response persistence (ResponseDrain) and execution state tracking (ExecutionStateTracker) during flow execution.
func NewServerResultProcessor ¶
func NewServerResultProcessor(opts ServerResultProcessorOpts) *ServerResultProcessor
NewServerResultProcessor creates a processor that persists execution results and publishes real-time events for connected clients.
func (*ServerResultProcessor) GraphQLResponseChan ¶
func (p *ServerResultProcessor) GraphQLResponseChan() chan ngraphql.NodeGraphQLSideResp
func (*ServerResultProcessor) HTTPResponseChan ¶
func (p *ServerResultProcessor) HTTPResponseChan() chan nrequest.NodeRequestSideResp
func (*ServerResultProcessor) NodeStateChan ¶
func (p *ServerResultProcessor) NodeStateChan() chan runner.FlowNodeStatus
func (*ServerResultProcessor) Start ¶
func (p *ServerResultProcessor) Start()
func (*ServerResultProcessor) Wait ¶
func (p *ServerResultProcessor) Wait()
Wait blocks until all processing completes. Order: state tracker finishes (nodeStateChan closed by runner) → close response channels → response drains finish.
type ServerResultProcessorOpts ¶
type ServerResultProcessorOpts struct {
FlowID idwrap.IDWrap
WorkspaceID idwrap.IDWrap
// Flow data — maps are built internally from these
Nodes []mflow.Node
Edges []mflow.Edge
NodeIDMapping map[string]idwrap.IDWrap // original → versioned node ID mapping
// Services for persistence
HTTPResponseService shttp.HttpResponseService
GraphQLResponseService sgraphql.GraphQLResponseService
NodeExecutionService *sflow.NodeExecutionService
NodeService *sflow.NodeService
EdgeService *sflow.EdgeService
// Event publishing
Publisher EventPublisher
Logger *slog.Logger
}
ServerResultProcessorOpts configures a ServerResultProcessor.