inmem

package
v0.11.115 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 7 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func WithTenant added in v0.11.63

func WithTenant(fn workqueue.TenantFunc) Option

WithTenant orders the keys of each priority fairly across the tenants fn assigns them to (see workqueue.TenantSelector), and makes the keys this queue enumerates implement workqueue.TenantKey.

Jump to

Keyboard shortcuts

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