Documentation ¶
Overview ¶
Package nametoidx is an in-memory implementation of the name-to-index mapping registry.
Index ¶
- func NewNameToIdx(logger logging.Logger, title string, ...) idxvpp.NameToIdxRW
- func ToChan(ch chan idxvpp.NameToIdxDto) func(dto idxvpp.NameToIdxDto)
- type Config
- type DelWriteEnum
- type Factory
- type GivenKW
- type MappingIdx
- type MappingName
- type PersistentStorageConfig
- type Then
- type ThenName
- type ThenNotification
- type When
- type WhenName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNameToIdx ¶
func NewNameToIdx(logger logging.Logger, title string, indexFunction func(interface{}) map[string][]string) idxvpp.NameToIdxRW
NewNameToIdx creates a new instance implementing NameToIdxRW. Argument indexFunction may be nil if you do not want to use secondary indexes.
func ToChan ¶
func ToChan(ch chan idxvpp.NameToIdxDto) func(dto idxvpp.NameToIdxDto)
ToChan is an utility that allows to receive notification through a channel. If a notification can not be delivered until timeout, it is dropped.
Types ¶
type Config ¶
type Config struct {
PersistentStorage PersistentStorageConfig `json:"persistent-storage"`
}
Config defines configuration for index-to-name maps.
func ConfigFromFile ¶
ConfigFromFile loads the idxmap configuration from the specified file. If the specified file exists and contains valid configuration, the parsed configuration is returned. In case of an error, the default configuration is returned instead.
type DelWriteEnum ¶
type DelWriteEnum bool
DelWriteEnum defines type for the flag used to tell if a mapping was removed or not.
const Del DelWriteEnum = true
Del defines the value of a notification flag used when a mapping was removed.
const Write DelWriteEnum = false
Write defines the value of a notification flag used when a mapping was created.
type Factory ¶
type Factory func(reloaded bool) (idxvpp.NameToIdxRW, error)
Factory defines type of a function used to create new instances of a name-to-index mapping.
type GivenKW ¶
type GivenKW struct {
// contains filtered or unexported fields
}
GivenKW defines the initial state of a testing scenario.
func (*GivenKW) NameToIdx ¶
func (given *GivenKW) NameToIdx(idxMapFactory Factory, reg map[MappingName]MappingIdx) *GivenKW
NameToIdx sets up a given registry for the tested scenario.
type PersistentStorageConfig ¶
type PersistentStorageConfig struct { Location string `json:"location"` SyncInterval time.Duration `json:"sync-interval"` MaxSyncStartDelay time.Duration `json:"max-sync-start-delay"` }
PersistentStorageConfig defines the configuration section dedicated for persistent storage.
type Then ¶
type Then struct {
// contains filtered or unexported fields
}
Then defines the actions/changes expected from the tested registry.
func (*Then) Name ¶
func (then *Then) Name(name MappingName) *ThenName
Name associates then-clause with a given name in the registry.
func (*Then) Notification ¶
func (then *Then) Notification(name MappingName, del DelWriteEnum) *ThenNotification
Notification starts a section of then-clause referring to a given notification.
type ThenName ¶
type ThenName struct {
// contains filtered or unexported fields
}
ThenName defines actions/changes expected from the registry for a given name.
func (*ThenName) MapsTo ¶
func (thenName *ThenName) MapsTo(expectedIdx MappingIdx) *ThenName
MapsTo asserts the response of LookupIdx, LookupName and message in the channel.
func (*ThenName) MapsToNothing ¶
MapsToNothing verifies that a given name really maps to nothing.
func (*ThenName) Name ¶
func (thenName *ThenName) Name(name MappingName) *ThenName
Name associates then-clause with a given name in the registry.
type ThenNotification ¶
type ThenNotification struct {
// contains filtered or unexported fields
}
ThenNotification defines notification parameters for a then-clause.
func (*ThenNotification) And ¶
func (thenNotif *ThenNotification) And() *Then
And connects two then-clauses.
func (*ThenNotification) IsExpectedFor ¶
func (thenNotif *ThenNotification) IsExpectedFor(idx MappingIdx) *ThenNotification
IsExpectedFor verifies that a given notification was really received.
func (*ThenNotification) IsNotExpected ¶
func (thenNotif *ThenNotification) IsNotExpected() *ThenNotification
IsNotExpected verifies that a given notification was indeed NOT received.
func (*ThenNotification) When ¶
func (thenNotif *ThenNotification) When() *When
When starts a when-clause.
type When ¶
type When struct {
// contains filtered or unexported fields
}
When defines the actions/changes done to the tested registry.
func (*When) Name ¶
func (when *When) Name(name MappingName) *WhenName
Name associates when-clause with a given name in the registry.
func (*When) NameToIdxIsReloaded ¶
NameToIdxIsReloaded simulates a full registry reload.
type WhenName ¶
type WhenName struct {
// contains filtered or unexported fields
}
WhenName defines the actions/changes done to a registry for a given name.
func (*WhenName) IsRegistered ¶
func (whenName *WhenName) IsRegistered(idx MappingIdx) *WhenName
IsRegistered registers a given name-index pair into the registry.
func (*WhenName) IsUnRegistered ¶
IsUnRegistered un-registers a given name from the registry.