Documentation
¶
Index ¶
- type AgentMap
- func (tm *AgentMap) Close()
- func (tm *AgentMap) CompareAndSwap(key string, old, new *manager.AgentInfo) bool
- func (tm *AgentMap) Delete(key string)
- func (tm *AgentMap) Load(key string) (value *manager.AgentInfo, ok bool)
- func (tm *AgentMap) LoadAll() map[string]*manager.AgentInfo
- func (tm *AgentMap) LoadAndDelete(key string) (value *manager.AgentInfo, loaded bool)
- func (tm *AgentMap) LoadOrStore(key string, val *manager.AgentInfo) (value *manager.AgentInfo, loaded bool)
- func (tm *AgentMap) Store(key string, val *manager.AgentInfo)
- func (tm *AgentMap) Subscribe(ctx context.Context) <-chan AgentMapSnapshot
- func (tm *AgentMap) SubscribeSubset(ctx context.Context, include func(string, *manager.AgentInfo) bool) <-chan AgentMapSnapshot
- type AgentMapSnapshot
- type AgentMapUpdate
- type ClientMap
- func (tm *ClientMap) Close()
- func (tm *ClientMap) CompareAndSwap(key string, old, new *manager.ClientInfo) bool
- func (tm *ClientMap) Delete(key string)
- func (tm *ClientMap) Load(key string) (value *manager.ClientInfo, ok bool)
- func (tm *ClientMap) LoadAll() map[string]*manager.ClientInfo
- func (tm *ClientMap) LoadAndDelete(key string) (value *manager.ClientInfo, loaded bool)
- func (tm *ClientMap) LoadOrStore(key string, val *manager.ClientInfo) (value *manager.ClientInfo, loaded bool)
- func (tm *ClientMap) Store(key string, val *manager.ClientInfo)
- func (tm *ClientMap) Subscribe(ctx context.Context) <-chan ClientMapSnapshot
- func (tm *ClientMap) SubscribeSubset(ctx context.Context, include func(string, *manager.ClientInfo) bool) <-chan ClientMapSnapshot
- type ClientMapSnapshot
- type ClientMapUpdate
- type InterceptMap
- func (tm *InterceptMap) Close()
- func (tm *InterceptMap) CompareAndSwap(key string, old, new *manager.InterceptInfo) bool
- func (tm *InterceptMap) Delete(key string)
- func (tm *InterceptMap) Load(key string) (value *manager.InterceptInfo, ok bool)
- func (tm *InterceptMap) LoadAll() map[string]*manager.InterceptInfo
- func (tm *InterceptMap) LoadAndDelete(key string) (value *manager.InterceptInfo, loaded bool)
- func (tm *InterceptMap) LoadOrStore(key string, val *manager.InterceptInfo) (value *manager.InterceptInfo, loaded bool)
- func (tm *InterceptMap) Store(key string, val *manager.InterceptInfo)
- func (tm *InterceptMap) Subscribe(ctx context.Context) <-chan InterceptMapSnapshot
- func (tm *InterceptMap) SubscribeSubset(ctx context.Context, include func(string, *manager.InterceptInfo) bool) <-chan InterceptMapSnapshot
- type InterceptMapSnapshot
- type InterceptMapUpdate
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AgentMap ¶
type AgentMap struct {
// contains filtered or unexported fields
}
AgentMap is a wrapper around map[string]*manager.AgentInfo that is very similar to sync.Map, and that provides the additional features that:
- it is thread-safe (compared to a bare map)
- it provides type safety (compared to a sync.Map)
- it provides a compare-and-swap operation
- you can Subscribe to either the whole map or just a subset of the map to watch for updates. This gives you complete snapshots, deltas, and coalescing of rapid updates.
func (*AgentMap) Close ¶
func (tm *AgentMap) Close()
Close marks the map as "finished", all subscriber channels are closed and further mutations are forbidden.
After .Close() is called, any calls to .Store() will block forever, and any calls to .Subscribe() will return an already-closed channel.
.Load() and .LoadAll() calls will continue to work normally after .Close() has been called.
func (*AgentMap) CompareAndSwap ¶
CompareAndSwap is the atomic equivalent of:
if loadedVal, loadedOK := m.Load(key); loadedOK && proto.Equal(loadedVal, old) { m.Store(key, new) return true } return false
func (*AgentMap) Delete ¶
Delete deletes the value for a key. This blocks forever if .Close() has already been called.
func (*AgentMap) LoadAndDelete ¶
LoadAndDelete deletes the value for a key, returning a deepcopy of the previous value if any. The 'loaded' result reports whether the key was present.
If the value does need to be deleted, all the same blocking semantics as .Delete() apply.
func (*AgentMap) LoadOrStore ¶
func (tm *AgentMap) LoadOrStore(key string, val *manager.AgentInfo) (value *manager.AgentInfo, loaded bool)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The 'loaded' result is true if the value was loaded, false if stored.
If the value does need to be stored, all the same blocking semantics as .Store() apply
func (*AgentMap) Store ¶
Store sets a key sets the value for a key. This blocks forever if .Close() has already been called.
func (*AgentMap) Subscribe ¶
func (tm *AgentMap) Subscribe(ctx context.Context) <-chan AgentMapSnapshot
Subscribe returns a channel that will emits a complete snapshot of the map immediately after the call to Subscribe(), and then whenever the map changes. Updates are coalesced; if you do not need to worry about reading from the channel faster than you are able. The snapshot will contain the full list of coalesced updates; the initial snapshot will contain 0 updates. A read from the channel will block as long as there are no changes since the last read.
The values in the snapshot are deepcopies of the actual values in the map, but values may be reused between snapshots; if you mutate a value in a snapshot, that mutation may erroneously persist in future snapshots.
The returned channel will be closed when the Context is Done, or .Close() is called. If .Close() has already been called, then an already-closed channel is returned.
func (*AgentMap) SubscribeSubset ¶
func (tm *AgentMap) SubscribeSubset(ctx context.Context, include func(string, *manager.AgentInfo) bool) <-chan AgentMapSnapshot
SubscribeSubset is like Subscribe, but the snapshot returned only includes entries that satisfy the 'include' predicate. Mutations to entries that don't satisfy the predicate do not cause a new snapshot to be emitted. If the value for a key changes from satisfying the predicate to not satisfying it, then this is treated as a delete operation, and a new snapshot is generated.
type AgentMapSnapshot ¶
type AgentMapSnapshot struct { // State is the current state of the snapshot. State map[string]*manager.AgentInfo // Updates is the list of mutations that have happened since the previous snapshot. // Mutations that delete a value have .Delete=true, and .Value set to the value that was // deleted. No-op updates are not included (i.e., setting something to its current value, // or deleting something that does not exist). Updates []AgentMapUpdate }
AgentMapSnapshot contains a snapshot of the current state of a AgentMap, as well as a list of changes that have happened since the last snapshot.
type AgentMapUpdate ¶
type AgentMapUpdate struct { Key string Delete bool // Whether this is deleting the entry for .Key, or setting it to .Value. Value *manager.AgentInfo }
AgentMapUpdate describes a mutation made to a AgentMap.
type ClientMap ¶
type ClientMap struct {
// contains filtered or unexported fields
}
ClientMap is a wrapper around map[string]*manager.ClientInfo that is very similar to sync.Map, and that provides the additional features that:
- it is thread-safe (compared to a bare map)
- it provides type safety (compared to a sync.Map)
- it provides a compare-and-swap operation
- you can Subscribe to either the whole map or just a subset of the map to watch for updates. This gives you complete snapshots, deltas, and coalescing of rapid updates.
func (*ClientMap) Close ¶
func (tm *ClientMap) Close()
Close marks the map as "finished", all subscriber channels are closed and further mutations are forbidden.
After .Close() is called, any calls to .Store() will block forever, and any calls to .Subscribe() will return an already-closed channel.
.Load() and .LoadAll() calls will continue to work normally after .Close() has been called.
func (*ClientMap) CompareAndSwap ¶
func (tm *ClientMap) CompareAndSwap(key string, old, new *manager.ClientInfo) bool
CompareAndSwap is the atomic equivalent of:
if loadedVal, loadedOK := m.Load(key); loadedOK && proto.Equal(loadedVal, old) { m.Store(key, new) return true } return false
func (*ClientMap) Delete ¶
Delete deletes the value for a key. This blocks forever if .Close() has already been called.
func (*ClientMap) Load ¶
func (tm *ClientMap) Load(key string) (value *manager.ClientInfo, ok bool)
Load returns a deepcopy of the value for a specific key.
func (*ClientMap) LoadAll ¶
func (tm *ClientMap) LoadAll() map[string]*manager.ClientInfo
LoadAll returns a deepcopy of all key/value pairs in the map.
func (*ClientMap) LoadAndDelete ¶
func (tm *ClientMap) LoadAndDelete(key string) (value *manager.ClientInfo, loaded bool)
LoadAndDelete deletes the value for a key, returning a deepcopy of the previous value if any. The 'loaded' result reports whether the key was present.
If the value does need to be deleted, all the same blocking semantics as .Delete() apply.
func (*ClientMap) LoadOrStore ¶
func (tm *ClientMap) LoadOrStore(key string, val *manager.ClientInfo) (value *manager.ClientInfo, loaded bool)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The 'loaded' result is true if the value was loaded, false if stored.
If the value does need to be stored, all the same blocking semantics as .Store() apply
func (*ClientMap) Store ¶
func (tm *ClientMap) Store(key string, val *manager.ClientInfo)
Store sets a key sets the value for a key. This blocks forever if .Close() has already been called.
func (*ClientMap) Subscribe ¶
func (tm *ClientMap) Subscribe(ctx context.Context) <-chan ClientMapSnapshot
Subscribe returns a channel that will emits a complete snapshot of the map immediately after the call to Subscribe(), and then whenever the map changes. Updates are coalesced; if you do not need to worry about reading from the channel faster than you are able. The snapshot will contain the full list of coalesced updates; the initial snapshot will contain 0 updates. A read from the channel will block as long as there are no changes since the last read.
The values in the snapshot are deepcopies of the actual values in the map, but values may be reused between snapshots; if you mutate a value in a snapshot, that mutation may erroneously persist in future snapshots.
The returned channel will be closed when the Context is Done, or .Close() is called. If .Close() has already been called, then an already-closed channel is returned.
func (*ClientMap) SubscribeSubset ¶
func (tm *ClientMap) SubscribeSubset(ctx context.Context, include func(string, *manager.ClientInfo) bool) <-chan ClientMapSnapshot
SubscribeSubset is like Subscribe, but the snapshot returned only includes entries that satisfy the 'include' predicate. Mutations to entries that don't satisfy the predicate do not cause a new snapshot to be emitted. If the value for a key changes from satisfying the predicate to not satisfying it, then this is treated as a delete operation, and a new snapshot is generated.
type ClientMapSnapshot ¶
type ClientMapSnapshot struct { // State is the current state of the snapshot. State map[string]*manager.ClientInfo // Updates is the list of mutations that have happened since the previous snapshot. // Mutations that delete a value have .Delete=true, and .Value set to the value that was // deleted. No-op updates are not included (i.e., setting something to its current value, // or deleting something that does not exist). Updates []ClientMapUpdate }
ClientMapSnapshot contains a snapshot of the current state of a ClientMap, as well as a list of changes that have happened since the last snapshot.
type ClientMapUpdate ¶
type ClientMapUpdate struct { Key string Delete bool // Whether this is deleting the entry for .Key, or setting it to .Value. Value *manager.ClientInfo }
ClientMapUpdate describes a mutation made to a ClientMap.
type InterceptMap ¶
type InterceptMap struct {
// contains filtered or unexported fields
}
InterceptMap is a wrapper around map[string]*manager.InterceptInfo that is very similar to sync.Map, and that provides the additional features that:
- it is thread-safe (compared to a bare map)
- it provides type safety (compared to a sync.Map)
- it provides a compare-and-swap operation
- you can Subscribe to either the whole map or just a subset of the map to watch for updates. This gives you complete snapshots, deltas, and coalescing of rapid updates.
func (*InterceptMap) Close ¶
func (tm *InterceptMap) Close()
Close marks the map as "finished", all subscriber channels are closed and further mutations are forbidden.
After .Close() is called, any calls to .Store() will block forever, and any calls to .Subscribe() will return an already-closed channel.
.Load() and .LoadAll() calls will continue to work normally after .Close() has been called.
func (*InterceptMap) CompareAndSwap ¶
func (tm *InterceptMap) CompareAndSwap(key string, old, new *manager.InterceptInfo) bool
CompareAndSwap is the atomic equivalent of:
if loadedVal, loadedOK := m.Load(key); loadedOK && proto.Equal(loadedVal, old) { m.Store(key, new) return true } return false
func (*InterceptMap) Delete ¶
func (tm *InterceptMap) Delete(key string)
Delete deletes the value for a key. This blocks forever if .Close() has already been called.
func (*InterceptMap) Load ¶
func (tm *InterceptMap) Load(key string) (value *manager.InterceptInfo, ok bool)
Load returns a deepcopy of the value for a specific key.
func (*InterceptMap) LoadAll ¶
func (tm *InterceptMap) LoadAll() map[string]*manager.InterceptInfo
LoadAll returns a deepcopy of all key/value pairs in the map.
func (*InterceptMap) LoadAndDelete ¶
func (tm *InterceptMap) LoadAndDelete(key string) (value *manager.InterceptInfo, loaded bool)
LoadAndDelete deletes the value for a key, returning a deepcopy of the previous value if any. The 'loaded' result reports whether the key was present.
If the value does need to be deleted, all the same blocking semantics as .Delete() apply.
func (*InterceptMap) LoadOrStore ¶
func (tm *InterceptMap) LoadOrStore(key string, val *manager.InterceptInfo) (value *manager.InterceptInfo, loaded bool)
LoadOrStore returns the existing value for the key if present. Otherwise, it stores and returns the given value. The 'loaded' result is true if the value was loaded, false if stored.
If the value does need to be stored, all the same blocking semantics as .Store() apply
func (*InterceptMap) Store ¶
func (tm *InterceptMap) Store(key string, val *manager.InterceptInfo)
Store sets a key sets the value for a key. This blocks forever if .Close() has already been called.
func (*InterceptMap) Subscribe ¶
func (tm *InterceptMap) Subscribe(ctx context.Context) <-chan InterceptMapSnapshot
Subscribe returns a channel that will emits a complete snapshot of the map immediately after the call to Subscribe(), and then whenever the map changes. Updates are coalesced; if you do not need to worry about reading from the channel faster than you are able. The snapshot will contain the full list of coalesced updates; the initial snapshot will contain 0 updates. A read from the channel will block as long as there are no changes since the last read.
The values in the snapshot are deepcopies of the actual values in the map, but values may be reused between snapshots; if you mutate a value in a snapshot, that mutation may erroneously persist in future snapshots.
The returned channel will be closed when the Context is Done, or .Close() is called. If .Close() has already been called, then an already-closed channel is returned.
func (*InterceptMap) SubscribeSubset ¶
func (tm *InterceptMap) SubscribeSubset(ctx context.Context, include func(string, *manager.InterceptInfo) bool) <-chan InterceptMapSnapshot
SubscribeSubset is like Subscribe, but the snapshot returned only includes entries that satisfy the 'include' predicate. Mutations to entries that don't satisfy the predicate do not cause a new snapshot to be emitted. If the value for a key changes from satisfying the predicate to not satisfying it, then this is treated as a delete operation, and a new snapshot is generated.
type InterceptMapSnapshot ¶
type InterceptMapSnapshot struct { // State is the current state of the snapshot. State map[string]*manager.InterceptInfo // Updates is the list of mutations that have happened since the previous snapshot. // Mutations that delete a value have .Delete=true, and .Value set to the value that was // deleted. No-op updates are not included (i.e., setting something to its current value, // or deleting something that does not exist). Updates []InterceptMapUpdate }
InterceptMapSnapshot contains a snapshot of the current state of a InterceptMap, as well as a list of changes that have happened since the last snapshot.
type InterceptMapUpdate ¶
type InterceptMapUpdate struct { Key string Delete bool // Whether this is deleting the entry for .Key, or setting it to .Value. Value *manager.InterceptInfo }
InterceptMapUpdate describes a mutation made to a InterceptMap.