mirror of https://github.com/status-im/consul.git
Retain reference to RPC endpoints
This commit is contained in:
parent
d781e29d7c
commit
679dae613e
|
@ -27,6 +27,9 @@ type Server struct {
|
|||
// Connection pool to other consul servers
|
||||
connPool *ConnPool
|
||||
|
||||
// Endpoints holds our RPC endpoints
|
||||
endpoints endpoints
|
||||
|
||||
// eventChLAN is used to receive events from the
|
||||
// serf cluster in the datacenter
|
||||
eventChLAN chan serf.Event
|
||||
|
@ -76,6 +79,14 @@ type Server struct {
|
|||
shutdownLock sync.Mutex
|
||||
}
|
||||
|
||||
// Holds the RPC endpoints
|
||||
type endpoints struct {
|
||||
Catalog *Catalog
|
||||
Health *Health
|
||||
Raft *Raft
|
||||
Status *Status
|
||||
}
|
||||
|
||||
// NewServer is used to construct a new Consul server from the
|
||||
// configuration, potentially returning an error
|
||||
func NewServer(config *Config) (*Server, error) {
|
||||
|
@ -223,11 +234,17 @@ func (s *Server) setupRaft() error {
|
|||
|
||||
// setupRPC is used to setup the RPC listener
|
||||
func (s *Server) setupRPC() error {
|
||||
// Create endpoints
|
||||
s.endpoints.Status = &Status{s}
|
||||
s.endpoints.Raft = &Raft{s}
|
||||
s.endpoints.Catalog = &Catalog{s}
|
||||
s.endpoints.Health = &Health{s}
|
||||
|
||||
// Register the handlers
|
||||
s.rpcServer.Register(&Status{s})
|
||||
s.rpcServer.Register(&Raft{s})
|
||||
s.rpcServer.Register(&Catalog{s})
|
||||
s.rpcServer.Register(&Health{s})
|
||||
s.rpcServer.Register(s.endpoints.Status)
|
||||
s.rpcServer.Register(s.endpoints.Raft)
|
||||
s.rpcServer.Register(s.endpoints.Catalog)
|
||||
s.rpcServer.Register(s.endpoints.Health)
|
||||
|
||||
list, err := net.ListenTCP("tcp", s.config.RPCAddr)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue