package registrar

import "github.com/docker/docker/pkg/registrar"

Package registrar provides name registration. It reserves a name to a given key.

Index

Variables

var (
	// ErrNameReserved is an error which is returned when a name is requested to be reserved that already is reserved
	ErrNameReserved = errors.New("name is reserved")
	// ErrNameNotReserved is an error which is returned when trying to find a name that is not reserved
	ErrNameNotReserved = errors.New("name is not reserved")
	// ErrNoSuchKey is returned when trying to find the names for a key which is not known
	ErrNoSuchKey = errors.New("provided key does not exist")
)

Types

type Registrar

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

Registrar stores indexes a list of keys and their registered names as well as indexes names and the key that they are registered to Names must be unique. Registrar is safe for concurrent access.

func NewRegistrar

func NewRegistrar() *Registrar

NewRegistrar creates a new Registrar with the an empty index

func (*Registrar) Delete

func (r *Registrar) Delete(key string)

Delete removes all reservations for the passed in key. All names reserved to this key are released.

func (*Registrar) Get

func (r *Registrar) Get(name string) (string, error)

Get returns the key that the passed in name is reserved to

func (*Registrar) GetAll

func (r *Registrar) GetAll() map[string][]string

GetAll returns all registered names

func (*Registrar) GetNames

func (r *Registrar) GetNames(key string) ([]string, error)

GetNames lists all the reserved names for the given key

func (*Registrar) Release

func (r *Registrar) Release(name string)

Release releases the reserved name Once released, a name can be reserved again

func (*Registrar) Reserve

func (r *Registrar) Reserve(name, key string) error

Reserve registers a key to a name Reserve is idempotent Attempting to reserve a key to a name that already exists results in an `ErrNameReserved` A name reservation is globally unique

Source Files

registrar.go

Version
v1.12.0
Published
Jul 28, 2016
Platform
js/wasm
Imports
2 packages
Last checked
1 hour ago

Tools for package owners.