MCPcopy Create free account
hub / github.com/coder/envbuilder / initRPC

Function initRPC

log/coder.go:97–117  ·  view source on GitHub ↗
(ctx context.Context, client *agentsdk.Client, l slog.Logger)

Source from the content-addressed store, hash-verified

95}
96
97func initRPC(ctx context.Context, client *agentsdk.Client, l slog.Logger) (proto.DRPCAgentClient20, error) {
98 var c proto.DRPCAgentClient20
99 var err error
100 retryCtx, retryCancel := context.WithTimeout(ctx, rpcConnectTimeout)
101 defer retryCancel()
102 attempts := 0
103 for r := retry.New(100*time.Millisecond, time.Second); r.Wait(retryCtx); {
104 attempts++
105 // Maximize compatibility.
106 c, err = client.ConnectRPC20(ctx)
107 if err != nil {
108 l.Debug(ctx, "Failed to connect to Coder", slog.F("error", err), slog.F("attempt", attempts))
109 continue
110 }
111 break
112 }
113 if c == nil {
114 return nil, err
115 }
116 return proto.NewDRPCAgentClient(c.DRPCConn()), nil
117}
118
119// sendLogsV1 uses the PatchLogs endpoint to send logs.
120// This is deprecated, but required for backward compatibility with older versions of Coder.

Callers 1

CoderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected