Skip to content

Commit

Permalink
feat(bigtable): support PingAndWarm in emulator (#5803)
Browse files Browse the repository at this point in the history
Fixes #5802 

I do not check that the instance is in `s.instances`, because there is no way to create an instance. I do not think we want to require that users call `CreateInstance` before `CreateTable`, so we probably do not want to require that users call `CreateInstance` before `PingAndWarm` either.
  • Loading branch information
dbolduc authored Apr 28, 2022
1 parent f157b3b commit 9b943d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions bigtable/bttest/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,10 @@ func (s *server) CheckAndMutateRow(ctx context.Context, req *btpb.CheckAndMutate
return res, nil
}

func (s *server) PingAndWarm(ctx context.Context, req *btpb.PingAndWarmRequest) (*btpb.PingAndWarmResponse, error) {
return &btpb.PingAndWarmResponse{}, nil
}

// applyMutations applies a sequence of mutations to a row.
// fam should be a snapshot of the keys of tbl.families.
// It assumes r.mu is locked.
Expand Down
10 changes: 10 additions & 0 deletions bigtable/internal/mockserver/inmem.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ type Server struct {
MutateRowsFn func(*btpb.MutateRowsRequest, btpb.Bigtable_MutateRowsServer) error
// CheckAndMutateRowFn mocks CheckAndMutateRow.
CheckAndMutateRowFn func(context.Context, *btpb.CheckAndMutateRowRequest) (*btpb.CheckAndMutateRowResponse, error)
// PingAndWarmFn mocks PingAndWarm.
PingAndWarmFn func(context.Context, *btpb.PingAndWarmRequest) (*btpb.PingAndWarmResponse, error)
// ReadModifyWriteRowFn mocks ReadModifyWriteRow.
ReadModifyWriteRowFn func(context.Context, *btpb.ReadModifyWriteRowRequest) (*btpb.ReadModifyWriteRowResponse, error)
}
Expand Down Expand Up @@ -124,6 +126,14 @@ func (s *Server) CheckAndMutateRow(ctx context.Context, srv *btpb.CheckAndMutate
return nil, status.Error(codes.Unimplemented, "unimplemented")
}

// PingAndWarm implements PingAndWarm of the BigtableServer interface.
func (s *Server) PingAndWarm(ctx context.Context, srv *btpb.PingAndWarmRequest) (*btpb.PingAndWarmResponse, error) {
if s.PingAndWarmFn != nil {
return s.PingAndWarmFn(ctx, srv)
}
return nil, status.Error(codes.Unimplemented, "unimplemented")
}

// ReadModifyWriteRow implements ReadModifyWriteRow of the BigtableServer interface.
func (s *Server) ReadModifyWriteRow(ctx context.Context, srv *btpb.ReadModifyWriteRowRequest) (*btpb.ReadModifyWriteRowResponse, error) {
if s.ReadModifyWriteRowFn != nil {
Expand Down

0 comments on commit 9b943d5

Please sign in to comment.