Documentation
¶
Overview ¶
Package grpctransport provides an implementation of the clients.TransportBuilder interface using gRPC.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder creates gRPC-based Transports. It must be paired with ServerIdentifiers that contain an Extension field of type ServerIdentifierExtension.
func NewBuilder ¶ added in v1.73.0
NewBuilder provides a builder for creating gRPC-based Transports using the credentials from provided map of credentials names to credentials.Bundle.
type Config ¶ added in v1.73.0
type Config struct { // Credentials is the credentials bundle to be used for the connection. Credentials credentials.Bundle // GRPCNewClient is an optional custom function to establish a gRPC connection. // If nil, grpc.NewClient will be used as the default. GRPCNewClient func(target string, opts ...grpc.DialOption) (*grpc.ClientConn, error) }
Config defines the configuration for connecting to a gRPC server, including credentials and an optional custom new client function.
type ServerIdentifierExtension ¶
type ServerIdentifierExtension struct { // ConfigName is the name of the configuration to use for this transport. // It must be present as a key in the map of configs passed to NewBuilder. ConfigName string }
ServerIdentifierExtension holds settings for connecting to a gRPC server, such as an xDS management or an LRS server.
It must be set by value (not pointer) in the clients.ServerIdentifier.Extensions field (See Example).
Example ¶
ExampleServerIdentifierExtension demonstrates how to create clients.ServerIdentifier with grpctransport.ServerIdentifierExtension as its extensions.
This example is creating clients.ServerIdentifier to connect to server at localhost:5678 using the config named "local". Note that "local" must exist as an entry in the provided configs to grpctransport.Builder.
package main import ( "fmt" "google.golang.org/grpc/xds/internal/clients" "google.golang.org/grpc/xds/internal/clients/grpctransport" ) func main() { // Note the Extensions field is set by value and not by pointer. fmt.Printf("%+v", clients.ServerIdentifier{ServerURI: "localhost:5678", Extensions: grpctransport.ServerIdentifierExtension{ConfigName: "local"}}) }
Output: {ServerURI:localhost:5678 Extensions:{ConfigName:local}}