Skip to content

Commit

Permalink
embed: add Election service
Browse files Browse the repository at this point in the history
  • Loading branch information
heyitsanthony committed Apr 3, 2017
1 parent 2ab263c commit bd04f2b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions embed/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ import (

"github.com/coreos/etcd/etcdserver"
"github.com/coreos/etcd/etcdserver/api/v3client"
"github.com/coreos/etcd/etcdserver/api/v3election"
"github.com/coreos/etcd/etcdserver/api/v3election/v3electionpb"
"github.com/coreos/etcd/etcdserver/api/v3lock"
"github.com/coreos/etcd/etcdserver/api/v3lock/v3lockpb"
"github.com/coreos/etcd/etcdserver/api/v3rpc"
Expand Down Expand Up @@ -68,10 +70,14 @@ func (sctx *serveCtx) serve(s *etcdserver.EtcdServer, tlscfg *tls.Config, handle
plog.Info("ready to serve client requests")

m := cmux.New(sctx.l)
v3c := v3client.New(s)
servElection := v3election.NewElectionServer(v3c)
servLock := v3lock.NewLockServer(v3c)

if sctx.insecure {
gs := v3rpc.Server(s, nil)
v3lockpb.RegisterLockServer(gs, v3lock.NewLockServer(v3client.New(s)))
v3electionpb.RegisterElectionServer(gs, servElection)
v3lockpb.RegisterLockServer(gs, servLock)
if sctx.serviceRegister != nil {
sctx.serviceRegister(gs)
}
Expand Down Expand Up @@ -99,7 +105,8 @@ func (sctx *serveCtx) serve(s *etcdserver.EtcdServer, tlscfg *tls.Config, handle

if sctx.secure {
gs := v3rpc.Server(s, tlscfg)
v3lockpb.RegisterLockServer(gs, v3lock.NewLockServer(v3client.New(s)))
v3electionpb.RegisterElectionServer(gs, servElection)
v3lockpb.RegisterLockServer(gs, servLock)
if sctx.serviceRegister != nil {
sctx.serviceRegister(gs)
}
Expand Down

0 comments on commit bd04f2b

Please sign in to comment.