Files
coder/coderd/aibridged/client.go
T
Paweł Banaszewski 8f5f15a92f fix: remove unbound Client() method from aibridged.Server (#27845)
Adds client context to `Client()` method in `aibridged.Server`,
effectivly renaming `ClientContext()` method as `Client()`.
Similarly `aibridged.ClientFuncWithContext` became
`aibridged.ClientFunc`.

`aibridged.Server.Client()` acquired a DRPC client with
`context.Background()`, callers in theory could wait indefinitely for
the daemon to connect to coderd.

Every call site already had a context except the recorder callback.
`aibridge.NewRecorder` takes a `func(context.Context) (Recorder, error)`
and acquires against the record call's context.
2026-08-04 16:57:16 +02:00

40 lines
937 B
Go

package aibridged
import (
"context"
"storj.io/drpc"
"github.com/coder/coder/v2/coderd/aibridged/proto"
)
type Dialer func(ctx context.Context) (DRPCClient, error)
// ClientFunc acquires a DRPCClient, honoring the passed context so a blocking
// acquisition (e.g. waiting for the daemon to connect to coderd) unblocks when
// the context is canceled. Server.Client satisfies it.
type ClientFunc func(context.Context) (DRPCClient, error)
// DRPCClient is the union of various service interfaces the client must support.
type DRPCClient interface {
proto.DRPCRecorderClient
proto.DRPCMCPConfiguratorClient
proto.DRPCAuthorizerClient
proto.DRPCProviderConfiguratorClient
}
var _ DRPCClient = &Client{}
type Client struct {
proto.DRPCRecorderClient
proto.DRPCMCPConfiguratorClient
proto.DRPCAuthorizerClient
proto.DRPCProviderConfiguratorClient
Conn drpc.Conn
}
func (c *Client) DRPCConn() drpc.Conn {
return c.Conn
}