Skip to content

Commit

Permalink
Fixup: Refactor sentry client ctx passing
Browse files Browse the repository at this point in the history
  • Loading branch information
tjanez committed Nov 13, 2019
1 parent b6a62c5 commit 0c11c6d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
8 changes: 2 additions & 6 deletions go/sentry/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ var (

// Client is a sentry client for querying sentry nodes for their address(es).
type Client struct {
ctx context.Context

logger *logging.Logger

sentryAddress *node.Address
Expand All @@ -60,14 +58,14 @@ func (c *Client) Close() {
}

// GetConsensusAddresses returns the list of sentry node's consensus addresses.
func (c *Client) GetConsensusAddresses() ([]node.ConsensusAddress, error) {
func (c *Client) GetConsensusAddresses(ctx context.Context) ([]node.ConsensusAddress, error) {
if c.client == nil {
return nil, ErrSentryNotAvailable
}

var req sentry.GetConsensusAddressesRequest

resp, err := c.client.GetConsensusAddresses(c.ctx, &req)
resp, err := c.client.GetConsensusAddresses(ctx, &req)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -116,13 +114,11 @@ func (c *Client) createConnection() error {

// New creates a new sentry client.
func New(
ctx context.Context,
sentryAddress *node.Address,
sentryCert *x509.Certificate,
nodeIdentity *identity.Identity,
) (*Client, error) {
c := &Client{
ctx: ctx,
logger: logging.GetLogger("sentry/client"),
sentryAddress: sentryAddress,
sentryCert: sentryCert,
Expand Down
2 changes: 1 addition & 1 deletion go/sentry/grpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type grpcServer struct {
}

func (s *grpcServer) GetConsensusAddresses(ctx context.Context, req *pb.GetConsensusAddressesRequest) (*pb.GetConsensusAddressesResponse, error) {
addresses, err := s.backend.GetConsensusAddresses()
addresses, err := s.backend.GetConsensusAddresses(ctx)
if err != nil {
return nil, fmt.Errorf("sentry: error obtaining public addresses: %w", err)
}
Expand Down

0 comments on commit 0c11c6d

Please sign in to comment.