Documentation ¶
Index ¶
- Variables
- type AddFunc
- type AllowedIPsRefCounter
- type Counter
- func (rm *Counter[I, O]) Decrement(prefix netip.Prefix) (Ref[O], error)
- func (rm *Counter[I, O]) DecrementWithID(id string) error
- func (rm *Counter[I, O]) Flush() error
- func (rm *Counter[I, O]) Increment(prefix netip.Prefix, in I) (Ref[O], error)
- func (rm *Counter[I, O]) IncrementWithID(id string, prefix netip.Prefix, in I) (Ref[O], error)
- type Ref
- type RemoveFunc
- type RouteRefCounter
Constants ¶
This section is empty.
Variables ¶
var ErrIgnore = errors.New("ignore")
ErrIgnore can be returned by AddFunc to indicate that the counter not be incremented for the given prefix.
Functions ¶
This section is empty.
Types ¶
type AllowedIPsRefCounter ¶
AllowedIPsRefCounter is a Counter for AllowedIPs, it takes a peer key on Increment and passes it back to Decrement
type Counter ¶
type Counter[I, O any] struct { // contains filtered or unexported fields }
func New ¶
func New[I, O any](add AddFunc[I, O], remove RemoveFunc[I, O]) *Counter[I, O]
New creates a new Counter instance
func (*Counter[I, O]) Decrement ¶
Decrement decrements the reference count for the given prefix. If the reference count reaches 0, the RemoveFunc is called.
func (*Counter[I, O]) DecrementWithID ¶
DecrementWithID decrements the reference count for all prefixes associated with the given ID. If the reference count reaches 0, the RemoveFunc is called.
func (*Counter[I, O]) Increment ¶
Increment increments the reference count for the given prefix. If this is the first reference to the prefix, the AddFunc is called.
func (*Counter[I, O]) IncrementWithID ¶
IncrementWithID increments the reference count for the given prefix and groups it under the given ID. If this is the first reference to the prefix, the AddFunc is called.
type RouteRefCounter ¶
RouteRefCounter is a Counter for Route, it doesn't take any input on Increment and doesn't use any output on Decrement