gcon

package module
v0.0.0-...-d6f633b Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 8 Imported by: 0

README

gcon

gRPC connection configuration for dial with options.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Target is the address of the gRPC server, as "localhost:50051"
	Target string `cfg:"target"`
	// Authority sets the grpc.WithAuthority.
	Authority string `cfg:"authority"`

	// TLS is the TLS configuration for the connection.
	TLS TLSConfig `cfg:"tls"`
	// Block will block the Dial method until connection is established.
	Block       bool          `cfg:"block"        default:"true"`
	DialTimeout time.Duration `cfg:"dial_timeout" default:"5s"`
}

func (Config) Dial

func (c Config) Dial(ctx context.Context, opts ...grpc.DialOption) (*grpc.ClientConn, error)

Dial dials the target gRPC server.

func (Config) Options

func (c Config) Options() ([]grpc.DialOption, error)

Options returns the gRPC dial options based on the Config.

type TLSConfig

type TLSConfig struct {
	Enabled            bool `cfg:"enabled"`
	InsecureSkipVerify bool `cfg:"insecure_skip_verify"`
	// CertFile is the path to the client's TLS certificate.
	// Should be use with KeyFile.
	CertFile string `cfg:"cert_file"`
	// KeyFile is the path to the client's TLS key.
	// Should be use with CertFile.
	KeyFile string `cfg:"key_file"`
	// CAFile is the path to the CA certificate.
	// If empty, the server's root CA set will be used.
	CAFile string `cfg:"ca_file"`
	// ServerName is the server name used to verify the hostname on the returned certificates from the server.
	ServerName string `cfg:"server_name"`
}

func (TLSConfig) Generate

func (t TLSConfig) Generate() (*tls.Config, error)

Generate returns a tls.Config based on the TLSConfig.

Jump to

Keyboard shortcuts

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