@@ -16,6 +16,7 @@ import (
1616 "github.com/Jille/raftadmin"
1717 raftadminpb "github.com/Jille/raftadmin/proto"
1818 "github.com/bootjp/elastickv/adapter"
19+ "github.com/bootjp/elastickv/distribution"
1920 "github.com/bootjp/elastickv/kv"
2021 pb "github.com/bootjp/elastickv/proto"
2122 "github.com/bootjp/elastickv/store"
@@ -224,14 +225,15 @@ func setupStorage(dir string) (raft.LogStore, raft.StableStore, raft.SnapshotSto
224225 return ldb , sdb , fss , nil
225226}
226227
227- func setupGRPC (r * raft.Raft , st store.MVCCStore , tm * transport.Manager , coordinator * kv.Coordinate ) * grpc.Server {
228+ func setupGRPC (r * raft.Raft , st store.MVCCStore , tm * transport.Manager , coordinator * kv.Coordinate , distServer * adapter. DistributionServer ) * grpc.Server {
228229 s := grpc .NewServer ()
229230 trx := kv .NewTransaction (r )
230231 gs := adapter .NewGRPCServer (st , coordinator )
231232 tm .Register (s )
232233 pb .RegisterRawKVServer (s , gs )
233234 pb .RegisterTransactionalKVServer (s , gs )
234235 pb .RegisterInternalServer (s , adapter .NewInternal (trx , r , coordinator .Clock ()))
236+ pb .RegisterDistributionServer (s , distServer )
235237 leaderhealth .Setup (r , s , []string {"RawKV" })
236238 raftadmin .Register (s , r )
237239 return s
@@ -307,8 +309,10 @@ func run(eg *errgroup.Group, cfg config) error {
307309
308310 trx := kv .NewTransaction (r )
309311 coordinator := kv .NewCoordinator (trx , r )
312+ distEngine := distribution .NewEngineWithDefaultRoute ()
313+ distServer := adapter .NewDistributionServer (distEngine )
310314
311- s := setupGRPC (r , st , tm , coordinator )
315+ s := setupGRPC (r , st , tm , coordinator , distServer )
312316
313317 grpcSock , err := lc .Listen (ctx , "tcp" , cfg .address )
314318 if err != nil {
0 commit comments