mirror of
https://github.com/gravitational/teleport
synced 2024-10-19 16:53:57 +00:00
Drop gRPC call options from api/client.Client (#23917)
* Drop Client.WithCallOptions * Drop Client.callOpts
This commit is contained in:
parent
815daec7d5
commit
8a18b2b58e
|
@ -32,8 +32,7 @@ import (
|
|||
// createOrResumeAuditStream creates or resumes audit stream described in the request.
|
||||
func (c *Client) createOrResumeAuditStream(ctx context.Context, request proto.AuditStreamRequest) (events.Stream, error) {
|
||||
closeCtx, cancel := context.WithCancel(ctx)
|
||||
callOpts := append(c.callOpts, grpc.UseCompressor(ggzip.Name))
|
||||
stream, err := c.grpc.CreateAuditStream(closeCtx, callOpts...)
|
||||
stream, err := c.grpc.CreateAuditStream(closeCtx, grpc.UseCompressor(ggzip.Name))
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, trail.FromGRPC(err)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -197,7 +197,7 @@ func (d downstreamPipeControlStream) Recv() <-chan proto.DownstreamInventoryMess
|
|||
// UpstreamInventoryHello, and the first message received must be a DownstreamInventoryHello.
|
||||
func (c *Client) InventoryControlStream(ctx context.Context) (DownstreamInventoryControlStream, error) {
|
||||
cancelCtx, cancel := context.WithCancel(ctx)
|
||||
stream, err := c.grpc.InventoryControlStream(cancelCtx, c.callOpts...)
|
||||
stream, err := c.grpc.InventoryControlStream(cancelCtx)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, trail.FromGRPC(err)
|
||||
|
@ -206,7 +206,7 @@ func (c *Client) InventoryControlStream(ctx context.Context) (DownstreamInventor
|
|||
}
|
||||
|
||||
func (c *Client) GetInventoryStatus(ctx context.Context, req proto.InventoryStatusRequest) (proto.InventoryStatusSummary, error) {
|
||||
rsp, err := c.grpc.GetInventoryStatus(ctx, &req, c.callOpts...)
|
||||
rsp, err := c.grpc.GetInventoryStatus(ctx, &req)
|
||||
if err != nil {
|
||||
return proto.InventoryStatusSummary{}, trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ func (c *Client) GetInventoryStatus(ctx context.Context, req proto.InventoryStat
|
|||
}
|
||||
|
||||
func (c *Client) PingInventory(ctx context.Context, req proto.InventoryPingRequest) (proto.InventoryPingResponse, error) {
|
||||
rsp, err := c.grpc.PingInventory(ctx, &req, c.callOpts...)
|
||||
rsp, err := c.grpc.PingInventory(ctx, &req)
|
||||
if err != nil {
|
||||
return proto.InventoryPingResponse{}, trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ func (c *Client) GetInstances(ctx context.Context, filter types.InstanceFilter)
|
|||
// halts early.
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
instances, err := c.grpc.GetInstances(ctx, &filter, c.callOpts...)
|
||||
instances, err := c.grpc.GetInstances(ctx, &filter)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return stream.Fail[types.Instance](trail.FromGRPC(err))
|
||||
|
|
|
@ -32,7 +32,7 @@ import (
|
|||
// returned value to release the keepAliver resources.
|
||||
func (c *Client) NewKeepAliver(ctx context.Context) (types.KeepAliver, error) {
|
||||
cancelCtx, cancel := context.WithCancel(ctx)
|
||||
stream, err := c.grpc.SendKeepAlives(cancelCtx, c.callOpts...)
|
||||
stream, err := c.grpc.SendKeepAlives(cancelCtx)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, trail.FromGRPC(err)
|
||||
|
|
|
@ -39,7 +39,7 @@ func (c *Client) WebSessions() types.WebSessionInterface {
|
|||
|
||||
// Get returns the web session for the specified request
|
||||
func (r *webSessions) Get(ctx context.Context, req types.GetWebSessionRequest) (types.WebSession, error) {
|
||||
resp, err := r.c.grpc.GetWebSession(ctx, &req, r.c.callOpts...)
|
||||
resp, err := r.c.grpc.GetWebSession(ctx, &req)
|
||||
if err != nil {
|
||||
return nil, trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ func (r *webSessions) Get(ctx context.Context, req types.GetWebSessionRequest) (
|
|||
|
||||
// List returns the list of all web sessions
|
||||
func (r *webSessions) List(ctx context.Context) ([]types.WebSession, error) {
|
||||
resp, err := r.c.grpc.GetWebSessions(ctx, &emptypb.Empty{}, r.c.callOpts...)
|
||||
resp, err := r.c.grpc.GetWebSessions(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return nil, trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ func (r *webSessions) Upsert(ctx context.Context, session types.WebSession) erro
|
|||
|
||||
// Delete deletes the web session specified with the request
|
||||
func (r *webSessions) Delete(ctx context.Context, req types.DeleteWebSessionRequest) error {
|
||||
_, err := r.c.grpc.DeleteWebSession(ctx, &req, r.c.callOpts...)
|
||||
_, err := r.c.grpc.DeleteWebSession(ctx, &req)
|
||||
if err != nil {
|
||||
return trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ func (r *webSessions) Delete(ctx context.Context, req types.DeleteWebSessionRequ
|
|||
|
||||
// DeleteAll deletes all web sessions
|
||||
func (r *webSessions) DeleteAll(ctx context.Context) error {
|
||||
_, err := r.c.grpc.DeleteAllWebSessions(ctx, &emptypb.Empty{}, r.c.callOpts...)
|
||||
_, err := r.c.grpc.DeleteAllWebSessions(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ func (c *Client) WebTokens() types.WebTokenInterface {
|
|||
|
||||
// Get returns the web token for the specified request
|
||||
func (r *webTokens) Get(ctx context.Context, req types.GetWebTokenRequest) (types.WebToken, error) {
|
||||
resp, err := r.c.grpc.GetWebToken(ctx, &req, r.c.callOpts...)
|
||||
resp, err := r.c.grpc.GetWebToken(ctx, &req)
|
||||
if err != nil {
|
||||
return nil, trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ func (r *webTokens) Get(ctx context.Context, req types.GetWebTokenRequest) (type
|
|||
|
||||
// List returns the list of all web tokens
|
||||
func (r *webTokens) List(ctx context.Context) ([]types.WebToken, error) {
|
||||
resp, err := r.c.grpc.GetWebTokens(ctx, &emptypb.Empty{}, r.c.callOpts...)
|
||||
resp, err := r.c.grpc.GetWebTokens(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return nil, trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ func (r *webTokens) Upsert(ctx context.Context, token types.WebToken) error {
|
|||
|
||||
// Delete deletes the web token specified with the request
|
||||
func (r *webTokens) Delete(ctx context.Context, req types.DeleteWebTokenRequest) error {
|
||||
_, err := r.c.grpc.DeleteWebToken(ctx, &req, r.c.callOpts...)
|
||||
_, err := r.c.grpc.DeleteWebToken(ctx, &req)
|
||||
if err != nil {
|
||||
return trail.FromGRPC(err)
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ func (r *webTokens) Delete(ctx context.Context, req types.DeleteWebTokenRequest)
|
|||
|
||||
// DeleteAll deletes all web tokens
|
||||
func (r *webTokens) DeleteAll(ctx context.Context) error {
|
||||
_, err := r.c.grpc.DeleteAllWebTokens(ctx, &emptypb.Empty{}, r.c.callOpts...)
|
||||
_, err := r.c.grpc.DeleteAllWebTokens(ctx, &emptypb.Empty{})
|
||||
if err != nil {
|
||||
return trail.FromGRPC(err)
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ func (c *Client) NewWatcher(ctx context.Context, watch types.Watch) (types.Watch
|
|||
for _, kind := range watch.Kinds {
|
||||
protoWatch.Kinds = append(protoWatch.Kinds, proto.FromWatchKind(kind))
|
||||
}
|
||||
stream, err := c.grpc.WatchEvents(cancelCtx, &protoWatch, c.callOpts...)
|
||||
stream, err := c.grpc.WatchEvents(cancelCtx, &protoWatch)
|
||||
if err != nil {
|
||||
cancel()
|
||||
return nil, trail.FromGRPC(err)
|
||||
|
|
|
@ -66,13 +66,15 @@ func (c BaseConfig) GetTeleportClient(ctx context.Context) (teleport.Client, err
|
|||
Credentials: c.Teleport.Credentials(),
|
||||
DialOpts: []grpc.DialOption{
|
||||
grpc.WithConnectParams(grpc.ConnectParams{Backoff: bk, MinConnectTimeout: initTimeout}),
|
||||
grpc.WithDefaultCallOptions(
|
||||
grpc.WaitForReady(true),
|
||||
),
|
||||
grpc.WithReturnConnectionError(),
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, trace.Wrap(err)
|
||||
}
|
||||
clt = clt.WithCallOptions(grpc.WaitForReady(true))
|
||||
|
||||
return clt, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue