Documentation
¶
Index ¶
- type Cache
- type Node
- type NodeStatus
- type NodeType
- type Pool
- func (p *Pool) Add(t NodeType, address string, capabilitiesList []capabilities.Capabilities) 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
- 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
func (*Cache) Get ¶
Get - returns node from cache.
type Node ¶
type Node struct {
Type NodeType
Address string
Status NodeStatus
SessionID string
Updated int64
Registered int64
CapabilitiesList []capabilities.Capabilities
}
func NewNode ¶
func NewNode( 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(t NodeType, address string, capabilitiesList []capabilities.Capabilities) error
func (*Pool) CountNodes ¶
func (p *Pool) CountNodes(status *NodeStatus) (int, error)
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.
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
}
type StorageMock ¶
func (*StorageMock) Add ¶
func (s *StorageMock) Add(node Node, limit int) error
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) SetBusy ¶
func (s *StorageMock) SetBusy(node Node, sessionID 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)
Source Files
¶
- cache.go
- mocks.go
- node.go
- pool.go
- strategyList.go
Click to show internal directories.
Click to hide internal directories.