Skip to content

Commit

Permalink
GCS Object table: Rename struct to something more specific
Browse files Browse the repository at this point in the history
  • Loading branch information
Russell-Tran committed Apr 29, 2024
1 parent 0ebd863 commit ad610ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions go/cmd/gcsobjtable/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,22 @@ func main() {
}
_ = lis;
s := grpc.NewServer()
pb.RegisterGCSObjServer(s, &server{})
pb.RegisterGCSObjServer(s, &GCSObjServer{}) // TODO: do i need to do a create for the map instead of a raw struct?
log.Printf("server listening at %v", lis.Addr())
if err := s.Serve(lis); err != nil {
log.Fatalf("failed to serve: %v", err)
}
}

// server is used to implement your gRPC service.
type server struct {
type GCSObjServer struct {
pb.UnimplementedGCSObjServer
objectLocations map[uint32][]uint32
mu sync.Mutex
}

// Implement your service methods here.
func (s *server) NotifyOwns(ctx context.Context, req *pb.NotifyOwnsRequest) (*pb.StatusResponse, error) {
func (s *GCSObjServer) NotifyOwns(ctx context.Context, req *pb.NotifyOwnsRequest) (*pb.StatusResponse, error) {
s.mu.Lock()
defer s.mu.Unlock()

Expand All @@ -49,7 +49,10 @@ func (s *server) NotifyOwns(ctx context.Context, req *pb.NotifyOwnsRequest) (*pb
return &pb.StatusResponse{Success: true}, nil
}

func (s *server) RequestLocation(ctx context.Context, req *pb.RequestLocationRequest) (*pb.StatusResponse, error) {

// TODO: Actually needs to match the pseudocode from our project architecture -- like it should
// be hanging out with the channels thing
func (s *GCSObjServer) RequestLocation(ctx context.Context, req *pb.RequestLocationRequest) (*pb.StatusResponse, error) {
s.mu.Lock()
nodeIds, exists := s.objectLocations[req.Uid]
s.mu.Unlock()
Expand Down
2 changes: 1 addition & 1 deletion go/cmd/gcsobjtable/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var lis *bufconn.Listener
func init() {
lis = bufconn.Listen(bufSize)
s := grpc.NewServer()
pb.RegisterGCSObjServer(s, &server{objectLocations: make(map[uint32][]uint32)})
pb.RegisterGCSObjServer(s, &GCSObjServer{objectLocations: make(map[uint32][]uint32)})
go func() {
if err := s.Serve(lis); err != nil {
log.Fatalf("Server exited with error: %v", err)
Expand Down

0 comments on commit ad610ad

Please sign in to comment.