nametoidx

package
v2.0.0-alpha+incompatible Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package nametoidx is an in-memory implementation of the name-to-index mapping registry.

Index

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

func ConfigFromFile(fpath string) (*Config, error)

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 Given

func Given(t *testing.T) *GivenKW

Given prepares 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.

func (*GivenKW) When

func (given *GivenKW) When() *When

When starts when-clause.

type MappingIdx

type MappingIdx uint32

MappingIdx defines type for indexes in the mappings.

type MappingName

type MappingName string

MappingName defines type for names in the mappings.

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) And

func (thenName *ThenName) And() *Then

And connects two then-clauses.

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

func (thenName *ThenName) MapsToNothing() *ThenName

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.

func (*ThenName) When

func (thenName *ThenName) When() *When

When starts a when-clause.

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

func (when *When) NameToIdxIsReloaded() *When

NameToIdxIsReloaded simulates a full registry reload.

func (*When) Then

func (when *When) Then() *Then

Then starts a then-clause.

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) And

func (whenName *WhenName) And() *When

And connects two when-clauses.

func (*WhenName) IsRegistered

func (whenName *WhenName) IsRegistered(idx MappingIdx) *WhenName

IsRegistered registers a given name-index pair into the registry.

func (*WhenName) IsUnRegistered

func (whenName *WhenName) IsUnRegistered() *WhenName

IsUnRegistered un-registers a given name from the registry.

func (*WhenName) Then

func (whenName *WhenName) Then() *Then

Then starts a then-clause.

Jump to

Keyboard shortcuts

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