inmem

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package inmem provides a non-durable, in-process queue.Service.

Jobs live in two per-topic structures: a min-heap of delayed jobs (keyed by run_at) and a priority queue of ready jobs (keyed by -priority, then FIFO sequence). A timer goroutine moves jobs from delayed to ready as their run_at arrives. Workers wait on a sync.Cond and pop from the ready queue.

**Not durable across process restarts.** Use the sqlite backend for embedded durability without an external server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the in-memory queue.Service implementation.

func New

func New(opts ...queue.QueueOption) *Service

New creates an in-memory queue service.

func (*Service) Close

func (s *Service) Close(_ context.Context) error

Close closes all consumers and marks the service as closed.

func (*Service) Enqueue

func (s *Service) Enqueue(_ context.Context, topicName string, payload []byte, opts ...queue.EnqueueOption) error

Enqueue places a job onto the queue. The "topic" argument is the user-facing short name; it is formatted with app/namespace before storage.

func (*Service) Subscribe

func (s *Service) Subscribe(ctx context.Context, topicName string, h queue.Handler, opts ...queue.SubscribeOption) (queue.Consumer, error)

Subscribe registers a worker pool against a topic.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL