Documentation ¶
Index ¶
- Constants
- 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) 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) RemoteURL() string
- type HTTPNodesByName
- 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() []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(p 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() []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
- type ModeType
- type Node
- 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() []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 ¶
const ( ModeSingle = "single" ModeMulti = "multi" )
Variables ¶
var ( Mode ModeType Manager ClusterManager Tracer opentracing.Tracer InsufficientShardsAvailable = NewError(http.StatusServiceUnavailable, errors.New("Insufficient shards available.")) )
var (
ClusterName string
)
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 HTTPNode ¶
type HTTPNode struct { Name string `json:"name"` Version string `json:"version"` Primary bool `json:"primary"` PrimaryChange time.Time `json:"primaryChange"` 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 ¶
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 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() []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(p 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() []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 (*MockNode) GetPartitions ¶
func (*MockNode) GetPriority ¶
type Node ¶
type Node interface { IsLocal() bool IsReady() bool GetPartitions() []int32 GetPriority() int Post(context.Context, string, string, Traceable) ([]byte, error) GetName() string }
func MembersForQuery ¶
MembersForQuery returns the list of nodes to broadcast requests to If partitions are assinged 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 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() []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) }