From 02123df8cc15896f97c1580e49d8e2a991e37ddd Mon Sep 17 00:00:00 2001 From: sangtran Date: Thu, 3 Sep 2026 23:10:33 +0700 Subject: Moving all legacy quacker source code from github to cgit --- pipeline/options.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 pipeline/options.go (limited to 'pipeline/options.go') diff --git a/pipeline/options.go b/pipeline/options.go new file mode 100644 index 0000000..c8c616e --- /dev/null +++ b/pipeline/options.go @@ -0,0 +1,34 @@ +package pipeline + +// StageObserver receives callbacks for stage lifecycle events. +type StageObserver interface { + OnItem() + OnDrop() + OnDone() +} + +// StageOption configures a stage's behavior. +type StageOption func(*stageConfig) + +type stageConfig struct { + observer StageObserver + bufferSize int +} + +// WithObserver attaches an observer to a stage. +func WithObserver(obs StageObserver) StageOption { + return func(cfg *stageConfig) { cfg.observer = obs } +} + +// WithBufferSize sets the output channel buffer size for a stage. +func WithBufferSize(size int) StageOption { + return func(cfg *stageConfig) { cfg.bufferSize = size } +} + +func applyOpts(opts []StageOption) stageConfig { + var cfg stageConfig + for _, opt := range opts { + opt(&cfg) + } + return cfg +} -- cgit v1.3.1