Skip to content

Commit

Permalink
Add RPC method to call FetchResourceUsageRecords over gRPC service (#281
Browse files Browse the repository at this point in the history
)

This PR exposes FetchResourceUsageRecords datastore method to the existing admin gRPC service by creating a RPC method FetchClientResourceUsageRecords and two corresponding RPC messages FetchClientResourceUsageRecordsRequest and FetchClientResourceUsageRecordsResponse.
  • Loading branch information
tsehori authored Sep 1, 2020
1 parent 2654a01 commit 616a079
Show file tree
Hide file tree
Showing 4 changed files with 448 additions and 206 deletions.
14 changes: 14 additions & 0 deletions fleetspeak/src/server/admin/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,17 @@ func (s adminServer) BlacklistClient(ctx context.Context, req *spb.BlacklistClie
}
return &fspb.EmptyMessage{}, nil
}

func (s adminServer) FetchClientResourceUsageRecords(ctx context.Context, req *spb.FetchClientResourceUsageRecordsRequest) (*spb.FetchClientResourceUsageRecordsResponse, error) {
clientID, idErr := common.BytesToClientID(req.ClientId)
if idErr != nil {
return nil, idErr
}
records, dbErr := s.store.FetchResourceUsageRecords(ctx, clientID, int(req.Limit))
if dbErr != nil {
return nil, dbErr
}
return &spb.FetchClientResourceUsageRecordsResponse{
Records: records,
}, nil
}
Loading

0 comments on commit 616a079

Please sign in to comment.