{"modulePath":"github.com/onflow/flow-go","version":"v0.42.3","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pipeline\n\n## Types\n\n```go\ntype Core interface {\n\t// Download retrieves all necessary data for processing.\n\tDownload(ctx context.Context) error\n\n\t// Index processes the downloaded data and creates in-memory indexes.\n\tIndex(ctx context.Context) error\n\n\t// Persist stores the indexed data in permanent storage.\n\tPersist(ctx context.Context) error\n}\n```\nCore defines the interface for pipeline processing steps. Each implementation should handle an execution data and implement the three-phase processing: download, index, and persist.\n\n```go\ntype Pipeline struct {\n\t// contains filtered or unexported fields\n}\n```\nPipeline represents a generic processing pipeline with state transitions. It processes data through sequential states: Ready -\u003e Downloading -\u003e Indexing -\u003e WaitingPersist -\u003e Persisting -\u003e Complete, with conditions for each transition.\n\n```go\nfunc NewPipeline(\n\tlogger zerolog.Logger,\n\tisSealed bool,\n\texecutionResult *flow.ExecutionResult,\n\tcore Core,\n\tstateUpdatePublisher StateUpdatePublisher,\n) *Pipeline\n```\nNewPipeline creates a new processing pipeline. Pipelines must only be created for ExecutionResults that descend from the latest persisted sealed result. The pipeline is initialized in the Ready state.\n\nParameters:\n\n  - logger: the logger to use for the pipeline\n  - isSealed: indicates if the pipeline's ExecutionResult is sealed\n  - executionResult: processed execution result\n  - core: implements the processing logic for the pipeline\n  - stateUpdatePublisher: called when the pipeline needs to broadcast state updates\n\nReturns:\n\n  - new pipeline object\n\n```go\nfunc (p *Pipeline) GetState() State\n```\nGetState returns the current state of the pipeline.\n\n```go\nfunc (p *Pipeline) Run(parentCtx context.Context) error\n```\nRun starts the pipeline processing and blocks until completion or context cancellation.\n\nThis function handles the progression through the pipeline states, executing the appropriate processing functions at each step.\n\nWhen the pipeline reaches a terminal state (StateComplete or StateCanceled), the function returns. The function will also return if the provided context is canceled.\n\nReturns an error if any processing step fails with an irrecoverable error. Returns nil if processing completes successfully, reaches a terminal state, or if either the parent or pipeline context is canceled.\n\n```go\nfunc (p *Pipeline) SetSealed()\n```\nSetSealed marks the data as sealed, which enables transitioning from StateWaitingPersist to StatePersisting.\n\n```go\nfunc (p *Pipeline) UpdateState(update StateUpdate)\n```\nUpdateState updates the pipeline's state based on the provided state update.\n\n```go\ntype State int\n```\nState represents the state of the processing pipeline\n\n```go\nconst (\n\t// StateReady is the initial state after instantiation and before downloading has begun\n\tStateReady State = iota\n\t// StateDownloading represents the state where data download is in progress\n\tStateDownloading\n\t// StateIndexing represents the state where data is being indexed\n\tStateIndexing\n\t// StateWaitingPersist represents the state where all data is indexed, but conditions to persist are not met\n\tStateWaitingPersist\n\t// StatePersisting represents the state where the indexed data is being persisted to storage\n\tStatePersisting\n\t// StateComplete represents the state where all data is persisted to storage\n\tStateComplete\n\t// StateCanceled represents the state where processing was aborted\n\tStateCanceled\n)\n```\n\n```go\nfunc (s State) String() string\n```\nString representation of states for logging\n\n```go\ntype StateUpdate struct {\n\t// DescendsFromLastPersistedSealed indicates if this pipeline descends from\n\t// the last persisted sealed result\n\tDescendsFromLastPersistedSealed bool\n\t// ParentState contains the state information from the parent pipeline\n\tParentState State\n}\n```\nStateUpdate contains state update information\n\n```go\ntype StateUpdatePublisher func(update StateUpdate)\n```\nStateUpdatePublisher is a function that publishes state updates\n\n","path":"github.com/onflow/flow-go/module/executiondatasync/optimistic_syncing","name":"pipeline","synopsis":"","isRedistributable":true}
