client

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 20, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClientMaxReceiveMessageSize is the max gRPC message size (~2GB).
	ClientMaxReceiveMessageSize = 2*gb - 1
)

Variables

View Source
var ErrNoConnection = errors.New("no gRPC client connection")

ErrNoConnection is returned when a hook or accessor needs the gRPC client connection but Dial() has not (yet) established one.

View Source
var ErrNoTLSCredentials = errors.New("the teamclient has no TLS credentials to use")

ErrNoTLSCredentials is returned when TLS dial options are requested but the selected teamserver config has no credentials (e.g. an in-memory dialer).

Functions

func TLSAuthMiddleware

func TLSAuthMiddleware(cli *client.Client) ([]grpc.DialOption, error)

TLSAuthMiddleware returns the Mutual-TLS dial options for the teamclient's selected remote server configuration: transport credentials built from the config's CA/cert/key, plus a per-RPC bearer token carrying the config token.

Types

type Dialer

type Dialer struct {
	// contains filtered or unexported fields
}

Dialer is a ready-to-use gRPC team/client.Dialer. It is the supported, importable evolution of the code that used to live under example/transports/grpc/client.

It dials the remote teamserver described by the teamclient's selected config (Mutual TLS when the config carries credentials; plaintext for an in-memory bufconn dialer whose options were produced by the server transport's NewClientFrom). It deliberately registers NO application RPC client of its own; instead it EXPOSES the established *grpc.ClientConn so applications can build their own service clients on the shared connection:

  • Conn() returns the connection after Dial().
  • PostDial(hook) runs your hook with the connection right after Dial() succeeds (the counterpart to the server handler's PostServe).

func NewClient

func NewClient(opts ...grpc.DialOption) *Dialer

NewClient returns a gRPC teamclient dialer loaded with the provided dial options (a max-receive-size call option is always added). For in-memory use, pass the options returned by the server transport's NewClientFrom.

func (*Dialer) Close

func (d *Dialer) Close() error

Close implements team/client.Dialer.Close(); it closes the connection if any.

func (*Dialer) Conn

func (d *Dialer) Conn() *grpc.ClientConn

Conn returns the established gRPC client connection, or nil before Dial().

func (*Dialer) Dial

func (d *Dialer) Dial() (err error)

Dial implements team/client.Dialer.Dial(). It connects to the configured host:port, then runs any PostDial hooks so the application can register its service clients on the connection.

func (*Dialer) Init

func (d *Dialer) Init(cli *client.Client) error

Init implements team/client.Dialer.Init(). It binds the teamclient core and assembles dial options from the selected server config: when the config carries a private key it adds Mutual-TLS credentials, otherwise it stays plaintext (the in-memory case).

func (*Dialer) PostDial

func (d *Dialer) PostDial(hooks ...func(*grpc.ClientConn) error)

PostDial registers hooks to run, in order, immediately after Dial() establishes the connection — the seam for registering application service clients on the shared *grpc.ClientConn. A hook error fails the dial.

func (*Dialer) Users

func (d *Dialer) Users() ([]team.User, error)

Users returns the list of teamserver users, via the core Team service. It requires the server to have been created with WithCoreServices(); otherwise the call returns an Unimplemented error. Implementing this (and VersionServer) makes the dialer satisfy team.Client, so a teamclient created WithDialer(this) answers its Users()/VersionServer() through this transport automatically.

func (*Dialer) VersionServer

func (d *Dialer) VersionServer() (team.Version, error)

VersionServer returns the connected teamserver's version, via the core Team service (requires WithCoreServices() on the server).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL