Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

streamer

An in-memory fan-out server in Go: accept many client connections, take work items on an input queue, and dispatch each item to every connection through a bounded worker pool — all coordinated over channels, no locks on the hot path.

Model

In(packet) ─► works channel ─► dispatch loop ─► idle worker ─► every connection.Channel
  • Server (pkg/server) — owns the works queue, the worker slice, and the connection registry. Subscribe/Unsubscribe register connections (mutex-guarded); In wraps a packet as a Work with a UUID and enqueues it. The dispatch loop pulls a work item, waits for a worker to advertise itself on workerChannel, and hands the item over.
  • Worker (internal/worker) — each worker loops: publish its own channel to workerChannel, receive a Work, then push it to every current connection's channel. Worker count is fixed at construction and bounds concurrency.
  • Connectors (pkg/connection) — slice of connections; unsubscribe is O(n) swap-delete (order doesn't matter).
  • Sizing: fewer workers for CPU-bound packets, more for I/O-bound.

Use

s := server.NewServer(/* workerSize */ 4, /* workQueueSize */ 128)
s.Start()
c := s.Subscribe()
go func() { for w := range c.Channel { /* send w.Data to the client */ } }()
s.In("hello")
s.Status() // { Connections, WorkerSize, WorkQueueSize, Works }
s.Stop()
go test ./...

Go 1.13 · google/uuid. Covered by server and connection tests.


Built 2020 to work through channel-based fan-out and worker-pool patterns in Go. Not maintained.

About

In-memory fan-out streaming server in Go — worker pool + connection registry over channels

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages