Skip to content

Commit

Permalink
fix: change ForwardedContext method to private
Browse files Browse the repository at this point in the history
Signed-off-by: hlts2 <[email protected]>
  • Loading branch information
hlts2 committed Sep 20, 2024
1 parent c71cd5b commit cee80ee
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions pkg/gateway/mirror/service/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const (

// Gateway represents an interface for interacting with gRPC clients.
type Gateway interface {
ForwardedContext(ctx context.Context, podName string) context.Context
FromForwardedContext(ctx context.Context) string
BroadCast(ctx context.Context,
f func(ctx context.Context, target string, vc MirrorClient, copts ...grpc.CallOption) error) error
Expand Down Expand Up @@ -74,9 +73,9 @@ func (g *gateway) GRPCClient() grpc.Client {
return g.client.GRPCClient()
}

// ForwardedContext takes a context and a podName, returning a new context
// forwardedContext takes a context and a podName, returning a new context
// with additional information related to forwarding.
func (*gateway) ForwardedContext(ctx context.Context, podName string) context.Context {
func (*gateway) forwardedContext(ctx context.Context, podName string) context.Context {

Check warning on line 78 in pkg/gateway/mirror/service/gateway.go

View check run for this annotation

Codecov / codecov/patch

pkg/gateway/mirror/service/gateway.go#L78

Added line #L78 was not covered by tests
return grpc.NewOutgoingContext(ctx, grpc.MD{
forwardedContextKey: []string{
podName,
Expand Down Expand Up @@ -114,7 +113,7 @@ func (g *gateway) BroadCast(
span.End()
}
}()
return g.client.GRPCClient().RangeConcurrent(g.ForwardedContext(ctx, g.podName), -1, func(ictx context.Context,
return g.client.GRPCClient().RangeConcurrent(g.forwardedContext(ctx, g.podName), -1, func(ictx context.Context,

Check warning on line 116 in pkg/gateway/mirror/service/gateway.go

View check run for this annotation

Codecov / codecov/patch

pkg/gateway/mirror/service/gateway.go#L116

Added line #L116 was not covered by tests
addr string, conn *grpc.ClientConn, copts ...grpc.CallOption,
) (err error) {
select {
Expand Down Expand Up @@ -144,7 +143,7 @@ func (g *gateway) Do(
if target == "" {
return nil, errors.ErrTargetNotFound
}
fctx := g.ForwardedContext(ctx, g.podName)
fctx := g.forwardedContext(ctx, g.podName)
res, err = g.client.GRPCClient().Do(fctx, target,

Check warning on line 147 in pkg/gateway/mirror/service/gateway.go

View check run for this annotation

Codecov / codecov/patch

pkg/gateway/mirror/service/gateway.go#L146-L147

Added lines #L146 - L147 were not covered by tests
func(ictx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (any, error) {
return f(ictx, target, NewMirrorClient(conn), copts...)
Expand Down Expand Up @@ -179,7 +178,7 @@ func (g *gateway) DoMulti(
if len(targets) == 0 {
return errors.ErrTargetNotFound
}
return g.client.GRPCClient().OrderedRangeConcurrent(g.ForwardedContext(ctx, g.podName), targets, -1,
return g.client.GRPCClient().OrderedRangeConcurrent(g.forwardedContext(ctx, g.podName), targets, -1,

Check warning on line 181 in pkg/gateway/mirror/service/gateway.go

View check run for this annotation

Codecov / codecov/patch

pkg/gateway/mirror/service/gateway.go#L181

Added line #L181 was not covered by tests
func(ictx context.Context, addr string, conn *grpc.ClientConn, copts ...grpc.CallOption) (err error) {
select {
case <-ictx.Done():
Expand Down

0 comments on commit cee80ee

Please sign in to comment.