/
config.go
116 lines (80 loc) · 3.16 KB
/
config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package cerebrum
import (
"crypto/tls"
"io"
"time"
"github.com/blacklabeldata/serfer"
"github.com/hashicorp/raft"
)
type Config struct {
// Bootstrap allows for a single node to become the leader for Raft.
Bootstrap bool
// NodeID should be unique across all nodes in the cluster.
NodeID string
// NodeName is the name of this node.
NodeName string
// DataCenter is the name of the data center for this node.
DataCenter string
// ServicePrefix is used to filter out unknown events.
ServicePrefix string
// DataPath is where all the data is stored
DataPath string
// LeaderElectionHandler processes leader election events.
LeaderElectionHandler serfer.LeaderElectionHandler
// UserEvent processes known, non-leader election events.
UserEvent serfer.UserEventHandler
// UnknownEventHandler processes unkown events.
UnknownEventHandler serfer.UnknownEventHandler
// Called when a Member joins the cluster.
NodeJoined serfer.MemberJoinHandler
// Called when a Member leaves the cluster by sending a leave message.
NodeLeft serfer.MemberLeaveHandler
// Called when a Member has been detected as failed.
NodeFailed serfer.MemberFailureHandler
// Called when a Member has been Readed from the cluster.
NodeReaped serfer.MemberReapHandler
// Called when a Member has been updated.
NodeUpdated serfer.MemberUpdateHandler
// Called when a serf.Query is received.
QueryHandler serfer.QueryEventHandler
// GossipBindAddr is the address of the Serf server.
GossipBindAddr string
// GossipBindPort is the port for the Serf server.
GossipBindPort int
// GossipAdvertiseAddr is the advertising address for the Serf server.
GossipAdvertiseAddr string
// GossipAdvertisePort is the advertising port for the Serf server.
GossipAdvertisePort int
// LogOutput is the output for all logs.
LogOutput io.Writer
// RaftConfig configures the Raft server.
RaftConfig *raft.Config
// SnapshotsRetained is the number of snapshots kept for Raft
SnapshotsRetained int
// LogCacheSize is the number of log entries to keep in memory.
LogCacheSize int
// TLSConfig is the config for Raft over TLS
TLSConfig *tls.Config
// RaftBindAddr is the bind address and port for the Raft TLS server.
RaftBindAddr string
// ReconcileInterval is the interval at which Raft makes sure the FSM has caught up.
ReconcileInterval time.Duration
// ConnectionDeadline is the maximum the TLS server will wait for connections.
// This deadline also applies to the ammount of time to wait for the server to shutdown.
ConnectionDeadline time.Duration
// EnqueueTimeout is the maximum amount of time a Raft submission will wait
// before timing out.
EnqueueTimeout time.Duration
// EstablishLeadership is called when a node becomes the leader of the
// Raft cluster. This function can be called multiple times if it returns an
// error.
EstablishLeadership func() error
// RevokeLeadership is called when a node loses the leadership of the
// Raft cluster.
RevokeLeadership func() error
// ConsistentNodeStatus
// Services is an array of services running on top of Cerebrum.
Services []Service
// ExistingNodes is an array of nodes already in the cluster.
ExistingNodes []string
}