Documentation ¶
Index ¶
- Variables
- func ConfigProcess()
- func ConfigSetup()
- func Init(name, version string, started time.Time, apiScheme string, apiPort int)
- func MembersForSpeculativeQuery() (map[int32][]Node, error)
- func Start()
- func Stop()
- type ClusterManager
- type Error
- type HTTPNode
- func (n HTTPNode) GetName() string
- func (n HTTPNode) GetPartitions() []int32
- func (n HTTPNode) GetPriority() int
- func (n HTTPNode) HasData() bool
- func (n HTTPNode) IsLocal() bool
- func (n HTTPNode) IsReady() bool
- func (n HTTPNode) Post(ctx context.Context, name, path string, body Traceable) (ret []byte, err error)
- func (n HTTPNode) PostRaw(ctx context.Context, name, path string, body Traceable) (io.ReadCloser, error)
- func (n HTTPNode) RemoteURL() string
- func (n *HTTPNode) SetPartitions(part []int32)
- func (n *HTTPNode) SetPrimary(primary bool) bool
- func (n *HTTPNode) SetPriority(prio int) bool
- func (n *HTTPNode) SetState(state NodeState) bool
- type HTTPNodesByName
- type InvalidNodeModeErr
- type MemberlistManager
- func (c *MemberlistManager) BroadcastUpdate()
- func (c *MemberlistManager) GetBroadcasts(overhead, limit int) [][]byte
- func (c *MemberlistManager) GetPartitions() []int32
- func (c *MemberlistManager) IsPrimary() bool
- func (c *MemberlistManager) IsReady() bool
- func (c *MemberlistManager) Join(peers []string) (int, error)
- func (c *MemberlistManager) LocalState(join bool) []byte
- func (c *MemberlistManager) MemberList(isReady, hasData bool) []Node
- func (c *MemberlistManager) MergeRemoteState(buf []byte, join bool)
- func (c *MemberlistManager) NodeMeta(limit int) []byte
- func (c *MemberlistManager) NotifyJoin(node *memberlist.Node)
- func (c *MemberlistManager) NotifyLeave(node *memberlist.Node)
- func (c *MemberlistManager) NotifyMsg(buf []byte)
- func (c *MemberlistManager) NotifyUpdate(node *memberlist.Node)
- func (c *MemberlistManager) SetPartitions(part []int32)
- func (c *MemberlistManager) SetPrimary(primary bool)
- func (c *MemberlistManager) SetPriority(prio int)
- func (c *MemberlistManager) SetReady()
- func (c *MemberlistManager) SetState(state NodeState)
- func (c *MemberlistManager) Start()
- func (c *MemberlistManager) Stop()
- func (c *MemberlistManager) ThisNode() Node
- type MockClusterManager
- func (c *MockClusterManager) GetPartitions() []int32
- func (c *MockClusterManager) IsPrimary() bool
- func (c *MockClusterManager) IsReady() bool
- func (c *MockClusterManager) Join(peers []string) (int, error)
- func (c *MockClusterManager) MemberList(isReady, hasData bool) []Node
- func (c *MockClusterManager) SetPartitions(partitions []int32)
- func (c *MockClusterManager) SetPrimary(primary bool)
- func (c *MockClusterManager) SetPriority(prio int)
- func (c *MockClusterManager) SetReady()
- func (c *MockClusterManager) SetReadyIn(t time.Duration)
- func (c *MockClusterManager) SetState(NodeState)
- func (c *MockClusterManager) Start()
- func (c *MockClusterManager) Stop()
- func (c *MockClusterManager) ThisNode() Node
- type MockNode
- func (n *MockNode) GetName() string
- func (n *MockNode) GetPartitions() []int32
- func (n *MockNode) GetPriority() int
- func (n *MockNode) HasData() bool
- func (n *MockNode) IsLocal() bool
- func (n *MockNode) IsReady() bool
- func (n MockNode) Post(ctx context.Context, name, path string, body Traceable) ([]byte, error)
- func (n MockNode) PostRaw(ctx context.Context, name, path string, body Traceable) (io.ReadCloser, error)
- type Node
- type NodeMode
- type NodeState
- type SingleNodeManager
- func (m *SingleNodeManager) GetPartitions() []int32
- func (m *SingleNodeManager) IsPrimary() bool
- func (m *SingleNodeManager) IsReady() bool
- func (m *SingleNodeManager) Join(peers []string) (int, error)
- func (m *SingleNodeManager) MemberList(isReady, hasData bool) []Node
- func (m *SingleNodeManager) SetPartitions(part []int32)
- func (m *SingleNodeManager) SetPrimary(primary bool)
- func (m *SingleNodeManager) SetPriority(prio int)
- func (m *SingleNodeManager) SetReady()
- func (m *SingleNodeManager) SetState(state NodeState)
- func (m *SingleNodeManager) Start()
- func (m *SingleNodeManager) Stop()
- func (m *SingleNodeManager) ThisNode() Node
- type Traceable
Constants ¶
This section is empty.
Variables ¶
var ( Mode NodeMode Manager ClusterManager Tracer opentracing.Tracer InsufficientShardsAvailable = NewError(http.StatusServiceUnavailable, errors.New("Insufficient shards available.")) )
var ( ClusterName string GossipSettlePeriod time.Duration // if gossip not enabled, will be 0 regardless of config )
Functions ¶
func ConfigProcess ¶
func ConfigProcess()
func ConfigSetup ¶
func ConfigSetup()
func MembersForSpeculativeQuery ¶
MembersForSpeculativeQuery returns a prioritized list of nodes for each shard group keyed by the first (lowest) partition of their shard group
Types ¶
type ClusterManager ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
func (*Error) HTTPStatusCode ¶ added in v1.0.0
implement response.Response
type HTTPNode ¶
type HTTPNode struct { Name string `json:"name"` Version string `json:"version"` Primary bool `json:"primary"` PrimaryChange time.Time `json:"primaryChange"` Mode NodeMode `json:"mode"` State NodeState `json:"state"` Priority int `json:"priority"` Started time.Time `json:"started"` StateChange time.Time `json:"stateChange"` Partitions []int32 `json:"partitions"` ApiPort int `json:"apiPort"` ApiScheme string `json:"apiScheme"` Updated time.Time `json:"updated"` RemoteAddr string `json:"remoteAddr"` // contains filtered or unexported fields }
func (HTTPNode) GetPartitions ¶
func (HTTPNode) GetPriority ¶
func (*HTTPNode) SetPartitions ¶ added in v0.12.0
SetPartitions sets the partitions that this node is handling
func (*HTTPNode) SetPrimary ¶ added in v0.12.0
SetPrimary sets the primary state of the node and returns whether it changed
func (*HTTPNode) SetPriority ¶ added in v0.12.0
SetPriority sets the priority of the node and returns whether it changed
type HTTPNodesByName ¶
type HTTPNodesByName []HTTPNode
func (HTTPNodesByName) Len ¶
func (n HTTPNodesByName) Len() int
func (HTTPNodesByName) Less ¶
func (n HTTPNodesByName) Less(i, j int) bool
func (HTTPNodesByName) Swap ¶
func (n HTTPNodesByName) Swap(i, j int)
type InvalidNodeModeErr ¶ added in v0.12.0
type InvalidNodeModeErr string
func (InvalidNodeModeErr) Error ¶ added in v0.12.0
func (e InvalidNodeModeErr) Error() string
type MemberlistManager ¶
func NewMemberlistManager ¶
func NewMemberlistManager(thisNode HTTPNode) *MemberlistManager
func (*MemberlistManager) BroadcastUpdate ¶
func (c *MemberlistManager) BroadcastUpdate()
func (*MemberlistManager) GetBroadcasts ¶
func (c *MemberlistManager) GetBroadcasts(overhead, limit int) [][]byte
GetBroadcasts is called when user data messages can be broadcast. It can return a list of buffers to send. Each buffer should assume an overhead as provided with a limit on the total byte size allowed. The total byte size of the resulting data to send must not exceed the limit. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop.
func (*MemberlistManager) GetPartitions ¶
func (c *MemberlistManager) GetPartitions() []int32
get the partitions that this node is handling.
func (*MemberlistManager) IsPrimary ¶
func (c *MemberlistManager) IsPrimary() bool
Returns true if the this node is a set as a primary node that should write data to cassandra.
func (*MemberlistManager) IsReady ¶
func (c *MemberlistManager) IsReady() bool
Returns true if this node is a ready to accept requests from users.
func (*MemberlistManager) LocalState ¶
func (c *MemberlistManager) LocalState(join bool) []byte
LocalState is used for a TCP Push/Pull. This is sent to the remote side in addition to the membership information. Any data can be sent here. See MergeRemoteState as well. The `join` boolean indicates this is for a join instead of a push/pull.
func (*MemberlistManager) MemberList ¶
func (c *MemberlistManager) MemberList(isReady, hasData bool) []Node
func (*MemberlistManager) MergeRemoteState ¶
func (c *MemberlistManager) MergeRemoteState(buf []byte, join bool)
func (*MemberlistManager) NodeMeta ¶
func (c *MemberlistManager) NodeMeta(limit int) []byte
NodeMeta is used to retrieve meta-data about the current node when broadcasting an alive message. It's length is limited to the given byte size. This metadata is available in the HTTPNode structure.
func (*MemberlistManager) NotifyJoin ¶
func (c *MemberlistManager) NotifyJoin(node *memberlist.Node)
func (*MemberlistManager) NotifyLeave ¶
func (c *MemberlistManager) NotifyLeave(node *memberlist.Node)
func (*MemberlistManager) NotifyMsg ¶
func (c *MemberlistManager) NotifyMsg(buf []byte)
NotifyMsg is called when a user-data message is received. Care should be taken that this method does not block, since doing so would block the entire UDP packet receive loop. Additionally, the byte slice may be modified after the call returns, so it should be copied if needed.
func (*MemberlistManager) NotifyUpdate ¶
func (c *MemberlistManager) NotifyUpdate(node *memberlist.Node)
func (*MemberlistManager) SetPartitions ¶
func (c *MemberlistManager) SetPartitions(part []int32)
set the partitions that this node is handling.
func (*MemberlistManager) SetPrimary ¶
func (c *MemberlistManager) SetPrimary(primary bool)
SetPrimary sets the primary status of this node
func (*MemberlistManager) SetPriority ¶
func (c *MemberlistManager) SetPriority(prio int)
set the priority of this node. lower values == higher priority
func (*MemberlistManager) SetReady ¶
func (c *MemberlistManager) SetReady()
mark this node as ready to accept requests from users.
func (*MemberlistManager) SetState ¶
func (c *MemberlistManager) SetState(state NodeState)
Set the state of this node.
func (*MemberlistManager) Start ¶
func (c *MemberlistManager) Start()
func (*MemberlistManager) Stop ¶
func (c *MemberlistManager) Stop()
func (*MemberlistManager) ThisNode ¶
func (c *MemberlistManager) ThisNode() Node
type MockClusterManager ¶
type MockClusterManager struct { Peers []*MockNode // contains filtered or unexported fields }
func InitMock ¶
func InitMock() *MockClusterManager
func (*MockClusterManager) GetPartitions ¶
func (c *MockClusterManager) GetPartitions() []int32
func (*MockClusterManager) IsPrimary ¶
func (c *MockClusterManager) IsPrimary() bool
func (*MockClusterManager) IsReady ¶
func (c *MockClusterManager) IsReady() bool
func (*MockClusterManager) MemberList ¶
func (c *MockClusterManager) MemberList(isReady, hasData bool) []Node
func (*MockClusterManager) SetPartitions ¶
func (c *MockClusterManager) SetPartitions(partitions []int32)
func (*MockClusterManager) SetPrimary ¶
func (c *MockClusterManager) SetPrimary(primary bool)
func (*MockClusterManager) SetPriority ¶
func (c *MockClusterManager) SetPriority(prio int)
func (*MockClusterManager) SetReady ¶
func (c *MockClusterManager) SetReady()
func (*MockClusterManager) SetReadyIn ¶
func (c *MockClusterManager) SetReadyIn(t time.Duration)
func (*MockClusterManager) SetState ¶
func (c *MockClusterManager) SetState(NodeState)
func (*MockClusterManager) Start ¶
func (c *MockClusterManager) Start()
func (*MockClusterManager) Stop ¶
func (c *MockClusterManager) Stop()
func (*MockClusterManager) ThisNode ¶
func (c *MockClusterManager) ThisNode() Node
type MockNode ¶
type MockNode struct {
// contains filtered or unexported fields
}
func NewMockNode ¶
func (*MockNode) GetPartitions ¶
func (*MockNode) GetPriority ¶
type Node ¶
type Node interface { IsLocal() bool IsReady() bool GetPartitions() []int32 GetPriority() int HasData() bool Post(context.Context, string, string, Traceable) ([]byte, error) PostRaw(ctx context.Context, name, path string, body Traceable) (io.ReadCloser, error) GetName() string }
func MembersForQuery ¶
MembersForQuery returns the list of nodes to broadcast requests to If partitions are assigned to nodes in groups (a[0,1], b[0,1], c[2,3], d[2,3] as opposed to a[0,1], b[0,2], c[1,3], d[2,3]), only 1 member per partition is returned. The nodes are selected based on priority, preferring thisNode if it has the lowest prio, otherwise using a random selection from all nodes with the lowest prio.
type NodeMode ¶ added in v0.12.0
type NodeMode uint8
func NodeModeFromString ¶ added in v0.12.0
capitalized form is what stringer (.String()) generates and is used for json serialization
func (NodeMode) MarshalJSON ¶ added in v0.12.0
MarshalJSON marshals a NodeMode
func (*NodeMode) UnmarshalJSON ¶ added in v0.12.0
UnmarshalJSON unmashals a NodeMode
type NodeState ¶
type NodeState int
func NodeStateFromString ¶
func (NodeState) MarshalJSON ¶
func (*NodeState) UnmarshalJSON ¶
UnmarshalJSON supports unmarshalling according to the older integer based, as well as the new string based, representation
type SingleNodeManager ¶
func NewSingleNodeManager ¶
func NewSingleNodeManager(thisNode HTTPNode) *SingleNodeManager
func (*SingleNodeManager) GetPartitions ¶
func (m *SingleNodeManager) GetPartitions() []int32
get the partitions that this node is handling.
func (*SingleNodeManager) IsPrimary ¶
func (m *SingleNodeManager) IsPrimary() bool
func (*SingleNodeManager) IsReady ¶
func (m *SingleNodeManager) IsReady() bool
func (*SingleNodeManager) MemberList ¶
func (m *SingleNodeManager) MemberList(isReady, hasData bool) []Node
func (*SingleNodeManager) SetPartitions ¶
func (m *SingleNodeManager) SetPartitions(part []int32)
set the partitions that this node is handling.
func (*SingleNodeManager) SetPrimary ¶
func (m *SingleNodeManager) SetPrimary(primary bool)
func (*SingleNodeManager) SetPriority ¶
func (m *SingleNodeManager) SetPriority(prio int)
set the priority of this node. lower values == higher priority
func (*SingleNodeManager) SetReady ¶
func (m *SingleNodeManager) SetReady()
func (*SingleNodeManager) SetState ¶
func (m *SingleNodeManager) SetState(state NodeState)
func (*SingleNodeManager) Start ¶
func (m *SingleNodeManager) Start()
func (*SingleNodeManager) Stop ¶
func (m *SingleNodeManager) Stop()
func (*SingleNodeManager) ThisNode ¶
func (m *SingleNodeManager) ThisNode() Node
type Traceable ¶
type Traceable interface { Trace(span opentracing.Span) TraceDebug(span opentracing.Span) }