aboutsummaryrefslogtreecommitdiff
path: root/pipeline/options.go
diff options
context:
space:
mode:
authorsangtran <tranquangsang12.7@gmail.com>2026-09-03 23:10:33 +0700
committersangtran <tranquangsang12.7@gmail.com>2026-09-03 23:10:33 +0700
commit02123df8cc15896f97c1580e49d8e2a991e37ddd (patch)
treed0c00bc3f65e5f5493a9dff8034c80640cb12960 /pipeline/options.go
signatureVerified sangtran <tranquangsang12.7@gmail.com> Key: 8DD79823D235E1BB ultimate trust
downloadquacker-main.tar.gz
quacker-main.zip
Verified Moving all legacy quacker source code from github to cgitHEADmain
Diffstat (limited to 'pipeline/options.go')
-rw-r--r--pipeline/options.go34
1 files changed, 34 insertions, 0 deletions
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 @@
1package pipeline
2
3// StageObserver receives callbacks for stage lifecycle events.
4type StageObserver interface {
5 OnItem()
6 OnDrop()
7 OnDone()
8}
9
10// StageOption configures a stage's behavior.
11type StageOption func(*stageConfig)
12
13type stageConfig struct {
14 observer StageObserver
15 bufferSize int
16}
17
18// WithObserver attaches an observer to a stage.
19func WithObserver(obs StageObserver) StageOption {
20 return func(cfg *stageConfig) { cfg.observer = obs }
21}
22
23// WithBufferSize sets the output channel buffer size for a stage.
24func WithBufferSize(size int) StageOption {
25 return func(cfg *stageConfig) { cfg.bufferSize = size }
26}
27
28func applyOpts(opts []StageOption) stageConfig {
29 var cfg stageConfig
30 for _, opt := range opts {
31 opt(&cfg)
32 }
33 return cfg
34}