suffixed

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package suffixed implements a blob.Store interface that delegates to another Store, with keys namespaced by a fixed suffix concatenated with each key.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CAS

type CAS struct {
	Store
	// contains filtered or unexported fields
}

CAS implements a suffixed wrapper around a blob.CAS instance.

func NewCAS

func NewCAS(cas blob.CAS) CAS

NewCAS creates a new suffixed Store associated with the specified cas. Suffixes do not nest: If cas is already a suffixed.CAS, it is returned as-is.

func (CAS) Base

func (c CAS) Base() blob.CAS

Base returns the underlying store associated with c.

func (CAS) CASKey

func (c CAS) CASKey(ctx context.Context, opts blob.CASPutOptions) (string, error)

CASKey implements part of the blob.CAS interface.

func (CAS) CASPut

func (c CAS) CASPut(ctx context.Context, opts blob.CASPutOptions) (string, error)

CASPut implements part of the blob.CAS interface.

func (CAS) Derive

func (c CAS) Derive(suffix string) CAS

Derive creates a clone of c that delegates to the same underlying store, but using a different suffix. If suffix == "", Derive returns a CAS that is equivalent to the underlying base store.

type Store

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

Store implements the blob.Store interface by delegating to an underlying store, but with each key suffixed by a fixed non-empty string. This allows multiple consumers to share non-overlapping namespaces within a single storage backend.

func New

func New(s blob.Store) Store

New creates a Store associated with the specified s. The initial store is exactly equivalent to the underlying store; use Derive to create clones that use a different suffix.

Suffixes do not nest: If s is already a suffixed.Store, it is returned as-is.

func (Store) Base

func (s Store) Base() blob.Store

Base returns the underlying store associated with s.

func (Store) Close

func (s Store) Close(ctx context.Context) error

Close implements the optional blob.Closer interface. It delegates to the underlying store if possible.

func (Store) Delete

func (s Store) Delete(ctx context.Context, key string) error

Delete implements part of blob.Store by delegation.

func (Store) Derive

func (s Store) Derive(suffix string) Store

Derive creates a clone of s that delegates to the same underlying store, but using a different suffix. If suffix == "", Derive returns a store that is equivalent to the underlying base store.

func (Store) Get

func (s Store) Get(ctx context.Context, key string) ([]byte, error)

Get implements part of blob.Store by delegation.

func (Store) Len

func (s Store) Len(ctx context.Context) (int64, error)

Len implements part of blob.Store by delegation. It reports only the number of keys matching the current suffix.

func (Store) List

func (s Store) List(ctx context.Context, start string, f func(string) error) error

List implements part of blob.Store by delegation. It filters the underlying list results to include only keys suffixed for this store.

func (Store) Put

func (s Store) Put(ctx context.Context, opts blob.PutOptions) error

Put implements part of blob.Store by delegation.

func (Store) Suffix

func (s Store) Suffix() string

Suffix returns the key suffix associated with s.

Jump to

Keyboard shortcuts

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