registrar

package
v1.12.4-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2016 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
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")
)

Functions

This section is empty.

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

Jump to

Keyboard shortcuts

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