Lifecycle
Audience: application developers working with pipeline startup, publishing, and shutdown behavior.
What This Covers
Build()StartPipelineAsync()PublishAsync(...)CompleteAsync()Completion
Basic Lifecycle
var pipeline = Pipeline<MyRecord>.New("orders")
.WithInMemorySource(new object())
.WithInMemoryDestination("config")
.Build();
await pipeline.StartPipelineAsync();
await pipeline.PublishAsync(new MyRecord());
await pipeline.CompleteAsync();
await pipeline.Completion;
Lifecycle Phases
- Build the pipeline.
- Start the pipeline.
- Publish records or let the configured source run.
- Complete the pipeline when no more records should enter.
- Await
Completionfor full shutdown.
Important Behaviors
StartPipelineAsync()is async and should be awaited.PublishAsync(...)before start throws.CompleteAsync()before start throws.- starting twice throws.
Completionrepresents the full pipeline run, not just one internal block.CompleteAsync()waits for downstream work to finish rather than only stopping ingress.- when the pipeline faults,
OnPipelineFaultedis raised beforeCompletionfaults.
Manual Publish With Flow Control
var result = await pipeline.PublishAsync(
new MyRecord(),
new PipelinePublishOptions
{
Timeout = TimeSpan.FromSeconds(2)
});
if (!result.Accepted)
{
Console.WriteLine(result.Reason);
}