Documentation
¶
Overview ¶
package roster provides interfaces and methods for defining internal lookup tables for registering and instantiatinge custom interfaces with multiple implementations. The expectation is that these (roster) interfaces will never be seen by user-facing code.
Index ¶
- type DefaultRoster
- func (dr *DefaultRoster) Driver(ctx context.Context, name string) (interface{}, error)
- func (dr *DefaultRoster) Drivers(ctx context.Context) []string
- func (dr *DefaultRoster) NormalizeName(ctx context.Context, name string) string
- func (dr *DefaultRoster) Register(ctx context.Context, name string, i interface{}) error
- func (dr *DefaultRoster) UnregisterAll(ctx context.Context) error
- type Roster
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DefaultRoster ¶
type DefaultRoster struct { Roster // contains filtered or unexported fields }
DefaultRoster implements the the `Roster` interface mapping scheme names to arbitrary interface values.
func (*DefaultRoster) Driver ¶
func (dr *DefaultRoster) Driver(ctx context.Context, name string) (interface{}, error)
Driver returns the value associated with the key for the normalized value of 'name' in the list of registered drivers available to 'dr'.
func (*DefaultRoster) Drivers ¶
func (dr *DefaultRoster) Drivers(ctx context.Context) []string
Drivers returns the list of registered schemes for all the drivers available to 'dr'.
func (*DefaultRoster) NormalizeName ¶
func (dr *DefaultRoster) NormalizeName(ctx context.Context, name string) string
NormalizeName returns a normalized (upper-cased) version of 'name'.
func (*DefaultRoster) Register ¶
func (dr *DefaultRoster) Register(ctx context.Context, name string, i interface{}) error
Registers creates a new entry in the list of drivers available to 'dr' mapping the normalized version of 'name' to 'i'.
func (*DefaultRoster) UnregisterAll ¶
func (dr *DefaultRoster) UnregisterAll(ctx context.Context) error
UnregisterAll removes all the registers drivers from 'dr'.
type Roster ¶
type Roster interface { // Driver returns the value associated with a name or scheme from the list of drivers that have been registered. Driver(context.Context, string) (interface{}, error) // Drivers returns the list of names or schemes for the list of drivers that have been registered. Drivers(context.Context) []string // UnregisterAll removes all the registered drivers from an instance implementing the Roster interfave. UnregisterAll(context.Context) error // NormalizeName returns a normalized version of a string. NormalizeName(context.Context, string) string // Register associated a name or scheme with an arbitrary interface. Register(context.Context, string, interface{}) error }
type Roster is an interface for defining internal lookup tables (or "rosters") for registering and instantiatinge custom interfaces with multiple implementations.
func NewDefaultRoster ¶
NewDefaultRoster returns a new `DefaultRoster` instance.