{"modulePath":"github.com/kernel/hypeman","version":"v0.4.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package queue\n\nPackage queue provides a minimal in-memory bounded queue for keyed work with dedup: jobs are identified by a key, and enqueueing a key that is already active or pending returns its position instead of re-enqueueing.\n\n## Types\n\n```go\ntype Queue struct {\n\t// contains filtered or unexported fields\n}\n```\nQueue runs jobs with a configurable concurrency limit. Queue state is in-memory; callers persist their own job metadata and recover on startup.\n\n```go\nfunc New(maxConcurrent int) *Queue\n```\nNew creates a Queue with the given concurrency limit (minimum 1).\n\n```go\nfunc (q *Queue) Enqueue(key string, startFn func(), done func()) int\n```\nEnqueue adds a job keyed by key. Returns the queue position: 0 if it started immediately, \u003e0 if queued behind other jobs. If the key is already active or pending, Enqueue dedups and returns its current position without re-enqueueing. A completion hook may be provided; when non-nil it runs after the key leaves the active set (so a caller's bookkeeping for the key is torn down only once the queue is done with it), but only when this call actually started the job — a dedup'd enqueue does not run it.\n\n```go\nfunc (q *Queue) EnqueueSuccessor(key string, startFn func(), done func()) int\n```\nEnqueueSuccessor queues a new job behind an active job with the same key. If a successor is already pending, it is replaced by the new job. This is useful when the caller has replaced the persisted work for a key while the previous job is finishing.\n\n```go\nfunc (q *Queue) GetPosition(key string) *int\n```\nGetPosition returns nil if the key is unknown or active without a successor, otherwise its 1-based position in the pending queue.\n\n```go\nfunc (q *Queue) QueueLength() int\n```\nQueueLength returns the number of tracked jobs (active + pending).\n\n","path":"github.com/kernel/hypeman/lib/queue","name":"queue","synopsis":"Package queue provides a minimal in-memory bounded queue for keyed work with dedup: jobs are identified by a key, and enqueueing a key that is already active or pending returns its position instead of re-enqueueing.","isRedistributable":true}
