Skip to content

Commit

Permalink
upgradeContextWithBearerToken does not need a receiver
Browse files Browse the repository at this point in the history
Signed-off-by: radekg <radek@gruchalski.com>
  • Loading branch information
radekg committed Oct 1, 2019
1 parent 3e82f81 commit 308d113
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions plugin/storage/grpc/shared/grpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ type grpcClient struct {
// upgradeContextWithBearerToken turns the context into a gRPC outgoing context with bearer token
// in the request metadata, if the original context has bearer token attached.
// Otherwise returns original context.
func (c *grpcClient) upgradeContextWithBearerToken(ctx context.Context) context.Context {
func upgradeContextWithBearerToken(ctx context.Context) context.Context {
bearerToken, hasToken := spanstore.GetBearerToken(ctx)
if hasToken {
requestMetadata := metadata.New(map[string]string{
Expand Down Expand Up @@ -66,7 +66,7 @@ func (c *grpcClient) SpanWriter() spanstore.Writer {

// GetTrace takes a traceID and returns a Trace associated with that traceID
func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*model.Trace, error) {
stream, err := c.readerClient.GetTrace(c.upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{
stream, err := c.readerClient.GetTrace(upgradeContextWithBearerToken(ctx), &storage_v1.GetTraceRequest{
TraceID: traceID,
})
if err != nil {
Expand All @@ -89,7 +89,7 @@ func (c *grpcClient) GetTrace(ctx context.Context, traceID model.TraceID) (*mode

// GetServices returns a list of all known services
func (c *grpcClient) GetServices(ctx context.Context) ([]string, error) {
resp, err := c.readerClient.GetServices(c.upgradeContextWithBearerToken(ctx), &storage_v1.GetServicesRequest{})
resp, err := c.readerClient.GetServices(upgradeContextWithBearerToken(ctx), &storage_v1.GetServicesRequest{})
if err != nil {
return nil, errors.Wrap(err, "plugin error")
}
Expand All @@ -99,7 +99,7 @@ func (c *grpcClient) GetServices(ctx context.Context) ([]string, error) {

// GetOperations returns the operations of a given service
func (c *grpcClient) GetOperations(ctx context.Context, service string) ([]string, error) {
resp, err := c.readerClient.GetOperations(c.upgradeContextWithBearerToken(ctx), &storage_v1.GetOperationsRequest{
resp, err := c.readerClient.GetOperations(upgradeContextWithBearerToken(ctx), &storage_v1.GetOperationsRequest{
Service: service,
})
if err != nil {
Expand All @@ -111,7 +111,7 @@ func (c *grpcClient) GetOperations(ctx context.Context, service string) ([]strin

// FindTraces retrieves traces that match the traceQuery
func (c *grpcClient) FindTraces(ctx context.Context, query *spanstore.TraceQueryParameters) ([]*model.Trace, error) {
stream, err := c.readerClient.FindTraces(c.upgradeContextWithBearerToken(ctx), &storage_v1.FindTracesRequest{
stream, err := c.readerClient.FindTraces(upgradeContextWithBearerToken(ctx), &storage_v1.FindTracesRequest{
Query: &storage_v1.TraceQueryParameters{
ServiceName: query.ServiceName,
OperationName: query.OperationName,
Expand Down Expand Up @@ -149,7 +149,7 @@ func (c *grpcClient) FindTraces(ctx context.Context, query *spanstore.TraceQuery

// FindTraceIDs retrieves traceIDs that match the traceQuery
func (c *grpcClient) FindTraceIDs(ctx context.Context, query *spanstore.TraceQueryParameters) ([]model.TraceID, error) {
resp, err := c.readerClient.FindTraceIDs(c.upgradeContextWithBearerToken(ctx), &storage_v1.FindTraceIDsRequest{
resp, err := c.readerClient.FindTraceIDs(upgradeContextWithBearerToken(ctx), &storage_v1.FindTraceIDsRequest{
Query: &storage_v1.TraceQueryParameters{
ServiceName: query.ServiceName,
OperationName: query.OperationName,
Expand Down

0 comments on commit 308d113

Please sign in to comment.