Documentation
¶
Index ¶
- type Cache
- type Node
- type NodeStatus
- type NodeType
- type Pool
- func (p *Pool) Add(key string, t NodeType, address string, ...) error
- func (p *Pool) CleanUpNode(node *Node) error
- func (p *Pool) CountNodes(status *NodeStatus) (int, error)
- func (p *Pool) FixNodeStatuses()
- func (p *Pool) GetAll() ([]Node, error)
- func (p *Pool) GetNodeByAddress(address string) (*Node, error)
- func (p *Pool) GetNodeBySessionID(sessionID string) (*Node, error)
- func (p *Pool) RegisterSession(node *Node, sessionID string) error
- func (p *Pool) Remove(node *Node) error
- func (p *Pool) ReserveAvailableNode(caps capabilities.Capabilities) (*Node, error)
- func (p *Pool) SetBusyNodeDuration(duration time.Duration)
- func (p *Pool) SetReservedNodeDuration(duration time.Duration)
- type StorageInterface
- type StorageMock
- func (s *StorageMock) Add(node Node, limit int) error
- func (s *StorageMock) GetAll() ([]Node, error)
- func (s *StorageMock) GetByAddress(address string) (Node, error)
- func (s *StorageMock) GetBySession(sessionID string) (Node, error)
- func (s *StorageMock) GetCountWithStatus(nodeStatus *NodeStatus) (int, error)
- func (s *StorageMock) Remove(node Node) error
- func (s *StorageMock) ReserveAvailable(nodeList []Node) (Node, error)
- func (s *StorageMock) SetAvailable(node Node) error
- func (s *StorageMock) SetBusy(node Node, sessionID string) error
- func (s *StorageMock) UpdateAddress(node Node, newAddress string) error
- type StrategyInterface
- type StrategyList
- type StrategyListInterface
- type StrategyListMock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cache ¶
Cache - caches nodes by session ID. !!! no thread safe
type Node ¶
type Node struct { // A unique key, by which we understand how to find this object in the outer world + for not adding the second time the same thing. // The value may depend on the strategy: // - for constant nodes ip: port // - for temporary pod.name Key string `json:"key"` Type NodeType `json:"type"` Address string `json:"address"` Status NodeStatus `json:"status"` SessionID string `json:"session_id"` Updated int64 `json:"updated"` Registered int64 `json:"registered"` CapabilitiesList []capabilities.Capabilities `json:"capabilities_list"` }
func NewNode ¶
func NewNode( key string, t NodeType, address string, status NodeStatus, sessionID string, updated int64, registered int64, capabilitiesList []capabilities.Capabilities, ) *Node
type NodeStatus ¶
type NodeStatus string
const ( NodeStatusAvailable NodeStatus = "available" NodeStatusReserved NodeStatus = "reserved" NodeStatusBusy NodeStatus = "busy" )
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
func NewPool ¶
func NewPool(storage StorageInterface, strategyList StrategyListInterface) *Pool
func (*Pool) Add ¶
func (p *Pool) Add(key string, t NodeType, address string, capabilitiesList []capabilities.Capabilities) error
func (*Pool) CleanUpNode ¶
func (*Pool) CountNodes ¶
func (p *Pool) CountNodes(status *NodeStatus) (int, error)
func (*Pool) FixNodeStatuses ¶
func (p *Pool) FixNodeStatuses()
func (*Pool) GetNodeBySessionID ¶
func (*Pool) ReserveAvailableNode ¶
func (p *Pool) ReserveAvailableNode(caps capabilities.Capabilities) (*Node, error)
TODO: research close transaction and defer close mysql result body.
func (*Pool) SetBusyNodeDuration ¶
func (*Pool) SetReservedNodeDuration ¶
type StorageInterface ¶
type StorageInterface interface { Add(node Node, limit int) error ReserveAvailable([]Node) (Node, error) SetBusy(Node, string) error SetAvailable(Node) error GetCountWithStatus(*NodeStatus) (int, error) GetBySession(string) (Node, error) GetByAddress(string) (Node, error) GetAll() ([]Node, error) Remove(Node) error UpdateAddress(node Node, newAddress string) error }
type StorageMock ¶
func (*StorageMock) GetAll ¶
func (s *StorageMock) GetAll() ([]Node, error)
func (*StorageMock) GetByAddress ¶
func (s *StorageMock) GetByAddress(address string) (Node, error)
func (*StorageMock) GetBySession ¶
func (s *StorageMock) GetBySession(sessionID string) (Node, error)
func (*StorageMock) GetCountWithStatus ¶
func (s *StorageMock) GetCountWithStatus(nodeStatus *NodeStatus) (int, error)
func (*StorageMock) Remove ¶
func (s *StorageMock) Remove(node Node) error
func (*StorageMock) ReserveAvailable ¶
func (s *StorageMock) ReserveAvailable(nodeList []Node) (Node, error)
func (*StorageMock) SetAvailable ¶
func (s *StorageMock) SetAvailable(node Node) error
func (*StorageMock) UpdateAddress ¶ added in v0.4.0
func (s *StorageMock) UpdateAddress(node Node, newAddress string) error
type StrategyInterface ¶
type StrategyInterface interface { Reserve(capabilities.Capabilities) (Node, error) CleanUp(Node) error FixNodeStatus(Node) error }
type StrategyList ¶
type StrategyList struct {
// contains filtered or unexported fields
}
func NewStrategyList ¶
func NewStrategyList(list []StrategyInterface) *StrategyList
func (*StrategyList) CleanUp ¶
func (s *StrategyList) CleanUp(node Node) error
func (*StrategyList) FixNodeStatus ¶
func (s *StrategyList) FixNodeStatus(node Node) error
func (*StrategyList) Reserve ¶
func (s *StrategyList) Reserve(caps capabilities.Capabilities) (node Node, err error)
type StrategyListInterface ¶
type StrategyListInterface interface { Reserve(caps capabilities.Capabilities) (node Node, err error) CleanUp(node Node) error FixNodeStatus(node Node) error }
type StrategyListMock ¶
func (*StrategyListMock) CleanUp ¶
func (s *StrategyListMock) CleanUp(node Node) error
func (*StrategyListMock) FixNodeStatus ¶
func (s *StrategyListMock) FixNodeStatus(node Node) error
func (*StrategyListMock) Reserve ¶
func (s *StrategyListMock) Reserve(caps capabilities.Capabilities) (Node, error)
Click to show internal directories.
Click to hide internal directories.