Documentation ¶
Index ¶
- func AOrB(flag bool, a string, b string) string
- func CompleteWithin(ch <-chan bool, delay time.Duration) bool
- func CompleteWithinInterface(ch <-chan interface{}, delay time.Duration) interface{}
- func ContextHasTick(ctx context.Context) bool
- func ContextWithTick(ctx context.Context, tick int64) context.Context
- func Decode(keywords []string, source string) ([]bool, error)
- func DoNotCompleteWithin(ch <-chan bool, delay time.Duration) bool
- func DoNotCompleteWithinInterface(ch <-chan interface{}, delay time.Duration) interface{}
- func MaxInt(a int, b int) int
- func MaxInt64(a int64, b int64) int64
- func TickFromContext(ctx context.Context) int64
- func URLPrefix(r *http.Request) string
- type Guarded
- type MultiMap
- type MultiMapEntry
- type MultiMapImpl
- func (m *MultiMapImpl) Add(entry MultiMapEntry) bool
- func (m *MultiMapImpl) Clear()
- func (m *MultiMapImpl) Count() int
- func (m *MultiMapImpl) ForEach(action func(item MultiMapEntry))
- func (m *MultiMapImpl) ForEachSecondary(index int, action func(key SecondaryKey, items []PrimaryKey))
- func (m *MultiMapImpl) Get(key PrimaryKey) (MultiMapEntry, bool)
- func (m *MultiMapImpl) GetPrimaryKeysFromSecondary(index int, key SecondaryKey) ([]PrimaryKey, bool)
- func (m *MultiMapImpl) Remove(key PrimaryKey) (MultiMapEntry, bool)
- func (m *MultiMapImpl) SecondaryCount(index int) int
- type PrimaryKey
- type Range
- type SecondaryKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AOrB ¶
AOrB is a simple helper function that returns either the 'a' string if the supplied flag is true, or the 'b' string. This simplifies trace format calls by removing inline if-then sequences.
func CompleteWithin ¶
CompleteWithin ensures that a channel either produces a result within the specified time, or it times out.
func CompleteWithinInterface ¶
CompleteWithinInterface ensures that a channel either produces a result within the specified time, or it times out.
func ContextHasTick ¶
ContextHasTick verifies whether the supplied context has a simulated time tick in its set of values.
func ContextWithTick ¶
ContextWithTick returns a new context with the current simulated time added.
func Decode ¶
Decode is a function that finds all occurences of the source string in the keyword array.
- It returns an error if no occurence of the source string is found in the keyword array.
- When there is no error, the boolean array describes which keywords were matched . An element in that array is true if the element with the same index in the keywords array was matched.
func DoNotCompleteWithin ¶
DoNotCompleteWithin ensures that the channel does not produce a result before the specified time. When this function returns with success no value will have been read from the supplied channel.
func DoNotCompleteWithinInterface ¶
DoNotCompleteWithinInterface ensures that the channel does not produce a result before the specified time. When this function returns with success no value will have been read from the supplied channel.
func TickFromContext ¶
TickFromContext extracts the simulated time from the supplied context.
Types ¶
type Guarded ¶
type Guarded struct { // Guard is the last sequence number used Guard int64 }
Guarded provides basic support for access gated by last sequence value. It maintains the last sequence number used, and has functions that can be used to refuse access based on out of order sequencing, as well as the maintenance of the guard value itself.
func (*Guarded) AdvanceGuard ¶
AdvanceGuard updates the guard value if the new value is greater than the value the object already holds.
func (*Guarded) Pass ¶
Pass checks that the provided check value is not earlier than the guard. If it passes, the guard is updated with supplied current sequence value from the at parameter. This allows for checks based on values the caller last saw, and for updates to provide something close to a linear sequence across guarded objects. Pass returns true if the check passes, and false if it didn't.
type MultiMap ¶
type MultiMap interface { // Get returns the instance associated with the supplied primary key, or // nil, if it was not found. The second return value is true, if it was // found, or false, if it was not. Get(key PrimaryKey) (MultiMapEntry, bool) // GetPrimaryKeysFromSecondary returns the primary keys for entries that // match the supplied value for the secondary key at the index. The second // return value is true, if it was found, or false, if it was not. GetPrimaryKeysFromSecondary(index int, key SecondaryKey) ([]PrimaryKey, bool) // Add attempts to add the supplied entry to the MultiMap instance. It // returns true if the new entry was inserted; false, if it was not. The // reason for insertion failing would be due to the primary key value for // this new entry matching one already in the MultiMap instance. Add(entry MultiMapEntry) bool // Remove attempts to remove the entry identified by the supplied primary // key. It returns the current entry, if it was found, and true, if the // entry was found and removed, or false, if no such entry was found. Remove(key PrimaryKey) (MultiMapEntry, bool) // ForEach calls the supplied action function with each entry held in the // MultiMap instance, in random order. ForEach(action func(item MultiMapEntry)) // ForEachSecondary processes each entry for the specified secondary key. // It calls the supplied action function for each key value, passing that // value and the set of primary keys associated with it. ForEachSecondary(index int, action func(key SecondaryKey, items []PrimaryKey)) // Count returns the number of entries held in this MultiMap instance. Count() int // SecondaryCount returns the number of unique secondary keys held in this // MultiMap instance for the specified secondary key index. SecondaryCount(index int) int // Clear removes all existing entries and resets all secondary keys indices. Clear() }
MultiMap is the interface callers use for accessing a MultiMap instance.
func NewMultiMap ¶
NewMultiMap creates a new MultiMap instance. It requires that the caller supply the number of secondary key indices.
type MultiMapEntry ¶
type MultiMapEntry interface { // Primary returns the primary key value for this entry. Primary() PrimaryKey // Secondary returns the key value for the secondary key specified by the // index parameter. If the entry does not support that secondary key, it // must return nil. Secondary(index int) SecondaryKey }
MultiMapEntry is the interface that an entry instance is required to support in order to be placed in a MultiMap.
type MultiMapImpl ¶
type MultiMapImpl struct {
// contains filtered or unexported fields
}
MultiMapImpl is an implementation of the MultiMap interface. This implementation uses multiple maps and slice for the indices.
func (*MultiMapImpl) Add ¶
func (m *MultiMapImpl) Add(entry MultiMapEntry) bool
func (*MultiMapImpl) Clear ¶
func (m *MultiMapImpl) Clear()
func (*MultiMapImpl) Count ¶
func (m *MultiMapImpl) Count() int
func (*MultiMapImpl) ForEach ¶
func (m *MultiMapImpl) ForEach(action func(item MultiMapEntry))
func (*MultiMapImpl) ForEachSecondary ¶
func (m *MultiMapImpl) ForEachSecondary( index int, action func(key SecondaryKey, items []PrimaryKey))
func (*MultiMapImpl) Get ¶
func (m *MultiMapImpl) Get(key PrimaryKey) (MultiMapEntry, bool)
func (*MultiMapImpl) GetPrimaryKeysFromSecondary ¶
func (m *MultiMapImpl) GetPrimaryKeysFromSecondary( index int, key SecondaryKey) ([]PrimaryKey, bool)
func (*MultiMapImpl) Remove ¶
func (m *MultiMapImpl) Remove(key PrimaryKey) (MultiMapEntry, bool)
func (*MultiMapImpl) SecondaryCount ¶
func (m *MultiMapImpl) SecondaryCount(index int) int
type Range ¶
Range contains a pair of values that form a range of acceptable int64 values, low to high, inclusive.
type SecondaryKey ¶
type SecondaryKey interface{}
SecondaryKey is the abstract type for each of the secondary keys for an entry