Documentation
¶
Overview ¶
Package token provides a token pool for SR-IOV resources
Index ¶
- type Pool
- func (p *Pool) AddListener(listener func())
- func (p *Pool) Allocate(id string) error
- func (p *Pool) Find(id string) (string, error)
- func (p *Pool) Free(id string) error
- func (p *Pool) Restore(tokens map[string][]string) error
- func (p *Pool) StopUsing(id string) error
- func (p *Pool) ToEnv(tokenName string, tokenIDs []string) (name, value string)
- func (p *Pool) Tokens() map[string]map[string]bool
- func (p *Pool) Use(id string, names []string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages forwarder SR-IOV resource tokens
func (*Pool) AddListener ¶
func (p *Pool) AddListener(listener func())
AddListener adds a new listener that fires on tokens state change to/from "closed"
func (*Pool) Allocate ¶
Allocate marks a token selected by the given ID as "allocated": * `free` -> `allocated` (common case) * `allocated` -> `allocated` (we have not called Free, but Device Plugin is already using the token) * `inUse` -stopUsing-> `allocated` (we have not called StopUsing, Free, but Device Plugin is already using the token) * `closed` -XXX-> `error`
func (*Pool) Free ¶
Free marks a token selected by the given ID as "free": * `free` -> `free` (nothing to do here) * `allocated` -> `free` (common case) * `inUse` -stopUsing-> `allocated` -> `free` (we have not called StopUsing, but the client have died) * `closed` -> `closed` (we should not fail, but we cannot free closed token)
func (*Pool) Restore ¶
Restore replaces part of existing tokens with given tokens and set them into the allocated state NOTE: it can be called only on untouched Pool, any actions will disable Restore
func (*Pool) StopUsing ¶
StopUsing marks an "inUse" token selected by ID as "allocated" and frees all related closed tokens: * `free` -XXX-> `error` * `allocated` -XXX-> `error` * `inUse` -> `allocated` (common case) * `closed` -XXX-> `error`
func (*Pool) ToEnv ¶ added in v1.1.0
ToEnv returns a (name, value) pair to store given tokens into the environment variable