Documentation
¶
Overview ¶
Package idmanager pkg/app/idmanager/delta_informer.go c2-vis-appsvc
Package idmanager pkg/app/idmanager/manager.go c2-vis-appsvc
Package idmanager pkg/app/idmanager/util.go c2-vis-appsvc
Index ¶
- Variables
- func AssertConn(v interface{}) (net.Conn, error)
- func AssertListener(v interface{}) (net.Listener, error)
- type DeltaInformer
- type Manager
- func (m *Manager) Add(id uint16, v interface{}) (free func() bool, err error)
- func (m *Manager) AddDeltaInformer() *DeltaInformer
- func (m *Manager) CloseAll()
- func (m *Manager) DoRange(next func(id uint16, v interface{}) bool)
- func (m *Manager) Get(id uint16) (interface{}, bool)
- func (m *Manager) Len() int
- func (m *Manager) Pop(id uint16) (interface{}, error)
- func (m *Manager) ReserveNextID() (id *uint16, free func() bool, err error)
- func (m *Manager) Set(id uint16, v interface{}) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNoMoreAvailableValues is returned when all the slots are reserved. ErrNoMoreAvailableValues = errors.New("no more available values") // ErrValueAlreadyExists is returned when value associated with the specified key already exists. ErrValueAlreadyExists = errors.New("value already exists") // ErrManagerClosed is returned by Set / ReserveNextID once CloseAll has run. // The caller owns the value it was about to store, so it must close it. ErrManagerClosed = errors.New("id manager is closed") )
Functions ¶
func AssertConn ¶
AssertConn asserts that `v` is of type `net.Conn`.
func AssertListener ¶
AssertListener asserts that `v` is of type `net.Listener`.
Types ¶
type DeltaInformer ¶
type DeltaInformer struct {
// contains filtered or unexported fields
}
DeltaInformer informs when there has been a change to the id-manager. .Trigger() and .Stop() can not be called concurrently to each other.
func NewDeltaInformer ¶
func NewDeltaInformer() *DeltaInformer
NewDeltaInformer creates a new DeltaInformer.
func (*DeltaInformer) Chan ¶
func (di *DeltaInformer) Chan() <-chan int
Chan returns the internal chan that gets triggered when a change occurs.
func (*DeltaInformer) Trigger ¶
func (di *DeltaInformer) Trigger(n int)
Trigger should be called whenever the internal chan should be triggered.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages allows to store and retrieve arbitrary values associated with the `uint16` key in a thread-safe manner. Provides method to generate key.
func (*Manager) AddDeltaInformer ¶
func (m *Manager) AddDeltaInformer() *DeltaInformer
AddDeltaInformer adds a DeltaInformer to the id manager and returns the DeltaInformer.
func (*Manager) CloseAll ¶
func (m *Manager) CloseAll()
CloseAll closes and removes all internal values that implements io.Closer
func (*Manager) DoRange ¶
DoRange performs range over the manager contents. Loop stops when `next` returns false.
func (*Manager) Pop ¶
Pop removes value specified by `id` from the idManager instance and returns it.
func (*Manager) ReserveNextID ¶
ReserveNextID reserves next free slot for the value and returns the id for it.