Documentation
¶
Overview ¶
Package hyperqueue provides a sharded WorkqueueService implementation that consistently distributes keys across N backend workqueue services using consistent hashing.
Hyperqueue acts as a transparent router that implements the WorkqueueService gRPC interface. It takes a slice of backend WorkqueueServiceClients and routes incoming requests to the appropriate shard based on the request key.
Keys are assigned to shards using FNV-1a hashing:
hash(key) % len(backends) -> shard index
This ensures:
- Deterministic routing: the same key always routes to the same shard
- Even distribution: keys are roughly evenly distributed across shards
- Fast computation: FNV-1a is a fast non-cryptographic hash
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New(backends []workqueue.WorkqueueServiceClient) (workqueue.WorkqueueServiceServer, error)
New creates a sharded WorkqueueServiceServer from the provided backend clients. The shard count is determined by len(backends). Keys are consistently routed to shards using hash(key) % len(backends).
Example ¶
ExampleNew demonstrates creating a hyperqueue server from a set of backend WorkqueueServiceClient instances.
package main
import (
"fmt"
"chainguard.dev/driftlessaf/workqueue/hyperqueue"
)
func main() {
// In production, pass real gRPC clients connected to backend workqueue
// services. New returns an error if no backends are provided.
_, err := hyperqueue.New(nil)
fmt.Println("error with no backends:", err)
}
Output: error with no backends: at least one backend is required
Types ¶
This section is empty.