monitor

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: Apache-2.0 Imports: 4 Imported by: 10

Documentation

Overview

Package monitor implements common plumbing for implementations of the blob.Store interface based on storage with a flat key space.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config[DB any, KV blob.KV] struct {
	// DB represents the initial state of the monitor.
	DB DB

	// Prefix gives the initial storage prefix of the root.
	Prefix dbkey.Prefix

	// NewKV construts a KV instance from the current state.
	NewKV func(context.Context, DB, dbkey.Prefix, string) (KV, error)

	// NewSub constructs a sub-DB state from the current state.
	// If nil, the existing state is copied.
	NewSub func(context.Context, DB, dbkey.Prefix, string) (DB, error)
}

Config carries settings for construction of an M.

type M

type M[DB any, KV blob.KV] struct {
	DB DB
	// contains filtered or unexported fields
}

A M value manages keyspace and substore allocations for the specified database and KV implementations. The resulting value implements blob.Store.

func New

func New[DB any, KV blob.KV](cfg Config[DB, KV]) *M[DB, KV]

New constructs a new empty store using the specified database, prefix, and KV constructor function. New will panic if newKV == nil.

func (*M[DB, KV]) CAS added in v0.9.0

func (d *M[DB, KV]) CAS(ctx context.Context, name string) (blob.CAS, error)

CAS implements a method of blob.Store.

func (*M[DB, KV]) KV added in v0.9.0

func (d *M[DB, KV]) KV(ctx context.Context, name string) (blob.KV, error)

KV implements a method of blob.Store. A successful result has concrete type [KV]. This method never reports an error.

func (*M[DB, KV]) Sub

func (d *M[DB, KV]) Sub(ctx context.Context, name string) (blob.Store, error)

Sub implements a method of blob.Store. This method never reports an error.

Jump to

Keyboard shortcuts

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