MCPcopy Create free account
hub / github.com/HyBuildNet/quic-relay / Submit

Method Submit

internal/proxy/pool.go:80–92  ·  view source on GitHub ↗

Submit adds a packet to the appropriate shard's queue. Uses client address hash for affinity (same client -> same worker). Returns false if queue is full (backpressure).

(item WorkItem)

Source from the content-addressed store, hash-verified

78// Uses client address hash for affinity (same client -> same worker).
79// Returns false if queue is full (backpressure).
80func (p *WorkerPool) Submit(item WorkItem) bool {
81 idx := hashAddr(item.ClientAddr) % uint32(p.workers)
82 select {
83 case p.queues[idx] <- item:
84 return true
85 default:
86 atomic.AddUint64(&p.dropped[idx], 1)
87 if item.Buffer != nil {
88 handler.PutBuffer(item.Buffer)
89 }
90 return false
91 }
92}
93
94// Dropped returns total dropped packets across all shards.
95func (p *WorkerPool) Dropped() uint64 {

Callers 6

TestWorkerPool_SubmitFunction · 0.95
TestWorkerPool_StopFunction · 0.95
TestWorkerPool_QueueSizeFunction · 0.95
RunMethod · 0.80

Calls 2

PutBufferFunction · 0.92
hashAddrFunction · 0.85

Tested by 5

TestWorkerPool_SubmitFunction · 0.76
TestWorkerPool_StopFunction · 0.76
TestWorkerPool_QueueSizeFunction · 0.76