Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Implement GetCoordinator in adapter #440

Merged
merged 3 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pkg/coord/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (a *adapter) QDB() qdb.QDB {
// TODO : unit tests
// TODO : implement
func (a *adapter) ShareKeyRange(id string) error {
return spqrerror.New(spqrerror.SPQR_NOT_IMPLEMENTED, "shareKeyRange not implemented")
return spqrerror.New(spqrerror.SPQR_NOT_IMPLEMENTED, "ShareKeyRange not implemented")
}

// TODO : unit tests
Expand Down Expand Up @@ -414,13 +414,15 @@ func (a *adapter) GetDataspace(ctx context.Context, table string) (*dataspaces.D
}

// TODO : unit tests
// TODO : implement
func (a *adapter) UpdateCoordinator(ctx context.Context, address string) error {
return spqrerror.New(spqrerror.SPQR_NOT_IMPLEMENTED, "UpdateCoordinator not implemeneted")
c := proto.NewTopologyServiceClient(a.conn)
_, err := c.UpdateCoordinator(ctx, &proto.UpdateCoordinatorRequest{Address: address})
return err
}

// TODO : unit tests
// TODO : implement
func (a *adapter) GetCoordinator(ctx context.Context) (string, error) {
return "", spqrerror.New(spqrerror.SPQR_NOT_IMPLEMENTED, "GetCoordinator not implemented")
c := proto.NewTopologyServiceClient(a.conn)
resp, err := c.GetCoordinator(ctx, &proto.GetCoordinatorRequest{})
return resp.Address, err
}
201 changes: 162 additions & 39 deletions pkg/protos/coordinator.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions pkg/protos/coordinator_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion protos/coordinator.proto
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ service TopologyService {
rpc GetRouterStatus(GetRouterStatusRequest) returns (GetRouterStatusReply) {}
rpc CloseRouter(CloseRouterRequest) returns (CloseRouterReply) {}
rpc UpdateCoordinator(UpdateCoordinatorRequest) returns (UpdateCoordinatorResponse) {}
rpc GetCoordinator(GetCoordinatorRequest) returns (GetCoordinatorResponse) {}
}

message OpenRouterRequest {}
Expand All @@ -32,4 +33,10 @@ message UpdateCoordinatorRequest {
string address = 1;
}

message UpdateCoordinatorResponse {}
message UpdateCoordinatorResponse {}

message GetCoordinatorRequest {}

message GetCoordinatorResponse {
string address = 1;
}
7 changes: 7 additions & 0 deletions router/grpc/qrouter.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,13 @@ func (l *LocalQrouterServer) UpdateCoordinator(ctx context.Context, req *protos.
return reply, err
}

func (l *LocalQrouterServer) GetCoordinator(ctx context.Context, req *protos.GetCoordinatorRequest) (*protos.GetCoordinatorResponse, error) {
reply := &protos.GetCoordinatorResponse{}
re, err := l.mgr.GetCoordinator(ctx)
reply.Address = re
return reply, err
}

func Register(server reflection.GRPCServer, qrouter qrouter.QueryRouter, mgr meta.EntityMgr, rr rulerouter.RuleRouter) {

lqr := &LocalQrouterServer{
Expand Down