client

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ClientMaxReceiveMessageSize - Max gRPC message size ~2Gb.
	ClientMaxReceiveMessageSize = (2 * gb) - 1 // 2Gb - 1 byte

)

Variables

View Source
var (
	// ErrNoRPC indicates that no gRPC generated proto.Teamclient bound to a client
	// connection is available. The error is raised when the handler hasn't connected.
	ErrNoRPC = errors.New("no working grpc.Teamclient available")

	// ErrNoTLSCredentials is an error raised if the teamclient was asked to setup, or try
	// connecting with, TLS credentials. If such an error is raised, make sure your team
	// client has correctly fetched -using client.Config()- a remote teamserver config.
	ErrNoTLSCredentials = errors.New("the grpc Teamclient has no TLS credentials to use")
)

Functions

func LogMiddlewareOptions

func LogMiddlewareOptions(cli *client.Client) []grpc.DialOption

LogMiddlewareOptions is an example list of gRPC options with logging middleware set up. This function uses the core teamclient loggers to log the gRPC stack/requests events. The Teamclient of this package uses them by default.

Types

type Teamclient

type Teamclient struct {
	*client.Client
	// contains filtered or unexported fields
}

Teamclient is a simple example gRPC teamclient and dialer backend. It comes correctly configured with Mutual TLS authentication and RPC connection/registration/use when created with NewTeamClient().

This teamclient embeds a team/client.Client core driver and uses it for fetching/setting up the transport credentials, dialers, etc... It also has a few internal types (clientConns, options) for working.

Note that this teamclient is not able to be used as an in-memory dialer. See the counterpart `team/transports/grpc/server` package for creating one. Also note that this example transport has been made for a single use-case, and that your program might require more elaborated behavior. In this case, please use this simple code as a reference for what/not to do.

func NewTeamClient

func NewTeamClient(opts ...grpc.DialOption) *Teamclient

NewTeamClient creates a new gRPC-based RPC teamclient and dialer backend. This client has by default only a few options, like max message buffer size. All options passed to this call are stored as is and will be used later.

func (*Teamclient) Close

func (h *Teamclient) Close() error

Close implements team/client.Dialer.Close(), and closes the gRPC client connection.

func (*Teamclient) Dial

func (h *Teamclient) Dial() (err error)

Dial implements team/client.Dialer.Dial(). It uses the teamclient remote server configuration as a target of a dial call. If the connection is successful, the teamclient registers a proto.Teamclient RPC around its client connection, to provide the core teamclient functionality.

func (*Teamclient) Init

func (h *Teamclient) Init(cli *client.Client) error

Init implements team/client.Dialer.Init(c). This implementation asks the teamclient core for its remote server configuration, and uses it to load a set of Mutual TLS dialing options.

func (*Teamclient) Users

func (h *Teamclient) Users() (users []team.User, err error)

Users returns a list of all users registered with the app teamserver. If the gRPC teamclient is not connected or does not have an RPC client, an ErrNoRPC is returned.

func (*Teamclient) VersionServer

func (h *Teamclient) VersionServer() (version team.Version, err error)

VersionServer returns the version information of the server to which the client is connected, or nil and an error if it could not retrieve it. If the gRPC teamclient is not connected or does not have an RPC client, an ErrNoRPC is returned.

type TokenAuth

type TokenAuth string

TokenAuth extracts authentication metadata from contexts, specifically the "Authorization": "Bearer" key:value pair.

func (TokenAuth) GetRequestMetadata

func (t TokenAuth) GetRequestMetadata(_ context.Context, _ ...string) (map[string]string, error)

GetRequestMetadata return values that are mapped to request headers.

func (TokenAuth) RequireTransportSecurity

func (TokenAuth) RequireTransportSecurity() bool

RequireTransportSecurity always return true.

Jump to

Keyboard shortcuts

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