Documentation ¶
Index ¶
- Constants
- func GetKappaEventName(name string) string
- func GetRawEventName(name string) string
- func IsKappaEvent(name string) bool
- func PublicKeyCallback(sys datamodel.System) (func(ssh.ConnMetadata, ssh.PublicKey) (*ssh.Permissions, error), error)
- func ValidateNode(member serf.Member) (ok bool, role, cluster string)
- type DatabaseConfig
- type EchoHandler
- type NodeDetails
- type NodeList
- type SerfNodeJoinHandler
- type SerfNodeLeaveHandler
- type SerfNodeUpdateHandler
- type SerfReconciler
- type SerfUserEventHandler
- type Server
- func (s *Server) Encrypted() bool
- func (s *Server) IsLeader() bool
- func (s *Server) Join(addrs []string) (int, error)
- func (s *Server) KeyManager() *serf.KeyManager
- func (c *Server) LocalMember() serf.Member
- func (s *Server) Members() []serf.Member
- func (s *Server) RemoveFailedNode(node string) error
- func (s *Server) Start() error
- func (s *Server) Stop()
Constants ¶
const ( // SerfCheckID = "serfHealth" // SerfCheckName = "Serf Health Status" // SerfCheckAliveOutput = "Agent alive and reachable" // SerfCheckFailedOutput = "Agent not live or unreachable" KappaServiceID = "kappa" KappaServiceName = "kappa" LeaderEventName = "kappa:new-leader" )
const (
// KappaEventPrefix is pre-pended to a kappa event to distinguish it
KappaEventPrefix = "kappa-event:"
)
const ( // StatusReap is used to update the status of a node if we // are handling a EventMemberReap StatusReap = serf.MemberStatus(-1) )
Variables ¶
This section is empty.
Functions ¶
func GetKappaEventName ¶
GetKappaEventName computes the name of a kappa event
func GetRawEventName ¶
GetRawEventName is used to get the raw kappa event name
func IsKappaEvent ¶
IsKappaEvent checks if a serf event is a Kappa event
func PublicKeyCallback ¶
func PublicKeyCallback(sys datamodel.System) (func(ssh.ConnMetadata, ssh.PublicKey) (*ssh.Permissions, error), error)
PublicKeyCallback returns a function to validate public keys for user login.
Types ¶
type DatabaseConfig ¶
type DatabaseConfig struct { // NodeName is the name of the node. If it is empty, a name // will be generated. NodeName string // ClusterName prevents two clusters from merging. ClusterName string // ExistingNodes is an array of nodes already in the cluster. ExistingNodes []string // Bootstrap determines if the server is bootstrapped into the cluster. Bootstrap bool BootstrapExpect int // Build is the running server revision. Build string // AdminCertificateFile is the path to the admin user's certificate. AdminCertificateFile string // CACertificateFile is the path to the CA certificate. CACertificateFile string // DataPath is the root directory for all data produced by the database. DataPath string // LogOutput is the writer to which all logs are // written to. If nil, it defaults to os.Stdout. LogOutput io.Writer // SSHBindAddress is the address on which the SSH server listens. SSHBindAddress string // SSHConnectionDeadline is the deadline for maximum connection attempts. SSHConnectionDeadline time.Duration // SSHPrivateKeyFile refers to the private key file of the SSH server. SSHPrivateKeyFile string // GossipBindAddr GossipBindAddr string // GossipBindPort GossipBindPort int // GossipAdvertiseAddr GossipAdvertiseAddr string // GossipAdvertisePort GossipAdvertisePort int }
DatabaseConfig contains all the information to start the Kappa server.
type EchoHandler ¶
type EchoHandler struct { }
type NodeDetails ¶
type NodeDetails struct { Name string Role string Cluster string DataCenter string Service string SSHPort int Bootstrap bool Addr net.TCPAddr Expect int }
NodeDetails stores details about a single serf.Member
func GetKappaServer ¶
func GetKappaServer(m serf.Member) (n *NodeDetails, err error)
GetKappaServer should validate all the Serf tags for the given member and returns NodeDetails and any that occured error.
func (NodeDetails) String ¶
func (n NodeDetails) String() (s string)
type NodeList ¶
type NodeList interface { // AddNode adds a new node to the cluster. AddNode(NodeDetails) // RemoveNode removes a node from the cluster. RemoveNode(NodeDetails) // GetNodes returns a list of nodes currently in the cluster GetNodes() []NodeDetails // Size returns the number of nodes in the cluster. Size() int // FindByDataCenter returns a list of nodes which are in the given data denter. FindByDataCenter(string) []NodeDetails // FindByRole returns a list of nodes which have the given role. FindByRole(string) []NodeDetails // FindByService returns a list of nodes which are running the given service. FindByService(string) []NodeDetails // Filter returns a list of nodes which satisfy the given filter. Filter(func(NodeDetails) bool) []NodeDetails }
NodeList maintains a list of remote nodes in the cluster.
func NewNodeList ¶
func NewNodeList() NodeList
NewNodeList creates a new nodeList which tracks the number of nodes in the cluster.
type SerfNodeJoinHandler ¶
type SerfNodeJoinHandler struct { // ClusterManager ClusterManager Cluster NodeList Logger log.Logger }
SerfNodeJoinHandler processes cluster Join events.
func (*SerfNodeJoinHandler) HandleMemberEvent ¶
func (s *SerfNodeJoinHandler) HandleMemberEvent(me serf.MemberEvent)
HandleMemberEvent is used to handle join events on the serf cluster.
type SerfNodeLeaveHandler ¶
SerfNodeLeaveHandler processes cluster leave events.
func (*SerfNodeLeaveHandler) HandleMemberEvent ¶
func (s *SerfNodeLeaveHandler) HandleMemberEvent(me serf.MemberEvent)
HandleMemberEvent is used to handle fail events in the Serf cluster.
type SerfNodeUpdateHandler ¶
func (*SerfNodeUpdateHandler) HandleMemberEvent ¶
func (s *SerfNodeUpdateHandler) HandleMemberEvent(me serf.MemberEvent)
nodeJoin is used to handle join events on the both serf clusters
type SerfReconciler ¶
SerfReconciler dispatches membership changes to Raft. If IsLeader is nil, the server will panic.
func (*SerfReconciler) Reconcile ¶
func (s *SerfReconciler) Reconcile(m serf.Member)
Reconcile is used to reconcile Serf events with the strongly consistent store if we are the current leader
type SerfUserEventHandler ¶
SerfUserEventHandler handles both local and remote user events in Serf.
func (*SerfUserEventHandler) HandleUserEvent ¶
func (s *SerfUserEventHandler) HandleUserEvent(event serf.UserEvent)
HandleUserEvent is called when a user event is received from both local and remote nodes.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(c *DatabaseConfig) (server *Server, err error)
func (*Server) Join ¶
Join is used to have Kappa join the cluster. The target address should be another node inside the cluster listening on the Serf address
func (*Server) KeyManager ¶
func (s *Server) KeyManager() *serf.KeyManager
KeyManager returns the Serf keyring manager
func (*Server) LocalMember ¶
LocalMember is used to return the local node
func (*Server) RemoveFailedNode ¶
RemoveFailedNode is used to remove a failed node from the cluster