inmem

package
v0.10.117 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2026 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Overview

Package inmem provides an in-memory workqueue implementation intended for testing.

The in-memory workqueue is not suitable for production use — it does not persist state across restarts and does not support distributed deployments. Use it in tests alongside the conformance package to verify workqueue consumer behavior.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWorkQueue

func NewWorkQueue(limit int, opts ...Option) workqueue.Interface

NewWorkQueue creates a new in-memory workqueue. This is intended for testing, and is not suitable for production use.

Example

ExampleNewWorkQueue demonstrates creating an in-memory workqueue and performing basic queue and enumerate operations.

package main

import (
	"context"
	"fmt"

	"chainguard.dev/driftlessaf/workqueue"
	"chainguard.dev/driftlessaf/workqueue/inmem"
)

func main() {
	wq := inmem.NewWorkQueue(5)
	ctx := context.Background()

	if err := wq.Queue(ctx, "my-key", workqueue.Options{}); err != nil {
		panic(err)
	}

	_, queued, _, err := wq.Enumerate(ctx)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Queued keys: %d\n", len(queued))
}
Output:
Queued keys: 1

Types

type Option added in v0.10.19

type Option func(*wq)

Option configures an in-memory workqueue created by NewWorkQueue.

func WithIdentity added in v0.10.19

func WithIdentity(identity string) Option

WithIdentity sets the identity recorded on each in-progress key this queue starts. Defaults to "", which records nothing.

Jump to

Keyboard shortcuts

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