aboutsummaryrefslogtreecommitdiff
path: root/README
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 /README
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 'README')
-rw-r--r--README125
1 files changed, 125 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..c758b17
--- /dev/null
+++ b/README
@@ -0,0 +1,125 @@
1QUACKER
2=======
3
4Type-safe, composable concurrency patterns with backpressure for Go.
5
6Quacker provides composable, channel-native concurrency primitives.
7Backpressure propagates naturally through Go's channel semantics —
8no custom protocols, no framework lock-in.
9
10
11INSTALLATION
12------------
13
14 go get git.sangtran.io.vn/quacker.git
15
16Requirements: Go 1.25+
17
18
19PACKAGES
20--------
21
22pipeline
23 Stream processing with backpressure. Compose stages into pipelines.
24 Each stage transforms a channel into a channel.
25
26 Example:
27 ctx, cancel := context.WithCancelCause(ctx)
28
29 out := pipeline.Run(ctx, input,
30 pipeline.Map(3, func(ctx context.Context, e Event) (Event, bool) {
31 enriched, err := enrich(ctx, e)
32 if err != nil {
33 cancel(err)
34 return e, false
35 }
36 return enriched, true
37 }),
38 pipeline.Filter(func(e Event) bool { return e.Priority > 0 }),
39 pipeline.Sink(5, func(ctx context.Context, e Event) {
40 store(ctx, e)
41 }),
42 )
43
44 for range out {}
45 if err := context.Cause(ctx); err != nil {
46 log.Fatal(err)
47 }
48
49 Stages: Map, Filter, ForEach, Buffer, Tee, Take, Sink, Batch.
50
51fanout
52 1-to-N distribution. Distribute a single stream to multiple
53 consumers. RoundRobin for load balancing, Broadcast for pub/sub.
54
55 Example:
56 fo, _ := fanout.NewFanOut[int](
57 fanout.WithWorkerCount(3),
58 fanout.WithStrategy(fanout.Broadcast),
59 )
60 fo.Run(ctx, input)
61
62 for _, ch := range fo.Outputs() {
63 go consume(ch)
64 }
65
66fanin
67 N-to-1 merge. Merge multiple channels into a single stream.
68
69 Example:
70 fi, _ := fanin.NewFanIn[int]()
71 fi.Add(stream1)
72 fi.Add(stream2)
73 fi.Add(stream3)
74 merged := fi.Run(ctx)
75
76workerpool
77 Fixed-size worker pool with push-based task queuing, metrics,
78 and graceful shutdown.
79
80 Example:
81 pool, _ := workerpool.NewWorkerPool[MyTask](ctx,
82 workerpool.WithNumWorkers(4),
83 workerpool.WithTaskQueueSize(100),
84 )
85 pool.Start()
86 pool.Push(task)
87 pool.StopAndWait()
88
89
90HOW THEY COMPOSE
91----------------
92
93The primitives connect through channels — Go's universal connector:
94
95 +-- pipeline --+
96 source --> fanout --+-- pipeline --+-- fanin --> pipeline --> sink
97 +-- pipeline --+
98
99 Example:
100 fo.Run(ctx, source)
101
102 fast := pipeline.Run(ctx, fo.Outputs()[0], pipeline.Map(10, enrichFast))
103 slow := pipeline.Run(ctx, fo.Outputs()[1], pipeline.Map(2, enrichSlow))
104
105 fi.Add(fast)
106 fi.Add(slow)
107 merged := fi.Run(ctx)
108
109 out := pipeline.Run(ctx, merged, pipeline.Sink(5, store))
110
111
112DESIGN
113------
114
115- Backpressure is free. Channels block when full. No custom protocol.
116- Errors use stdlib. context.WithCancelCause + context.Cause.
117- Shutdown is clear. Close input for drain; cancel context for stop.
118- Small interfaces. Observer interfaces are 2-3 methods, optional.
119- Zero dependencies. Core logic is stdlib only (golang.org/x/sync).
120
121
122LICENSE
123-------
124
125MIT (see LICENSE)