Documentation
¶
Overview ¶
Package configgrpc defines the configuration settings to create a gRPC client and server.
The configuration structs in this package may be shared across signals, but assume each struct is used for a single protocol and component.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BalancerName ¶ added in v0.105.0
func BalancerName() string
BalancerName returns a string with default load balancer value
Types ¶
type ClientConfig ¶ added in v0.94.0
type ClientConfig struct {
// The target to which the exporter is going to send traces or metrics,
// using the gRPC protocol. The valid syntax is described at
// https://github.com/grpc/grpc/blob/master/doc/naming.md.
Endpoint string `mapstructure:"endpoint,omitempty"`
// The compression key for supported compression types within collector.
Compression configcompression.Type `mapstructure:"compression,omitempty"`
// TLS struct exposes TLS client configuration.
TLS configtls.ClientConfig `mapstructure:"tls,omitempty"`
// The keepalive parameters for gRPC client. See grpc.WithKeepaliveParams.
// (https://godoc.org/google.golang.org/grpc#WithKeepaliveParams).
Keepalive configoptional.Optional[KeepaliveClientConfig] `mapstructure:"keepalive,omitempty"`
// ReadBufferSize for gRPC client. See grpc.WithReadBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithReadBufferSize).
ReadBufferSize int `mapstructure:"read_buffer_size,omitempty"`
// WriteBufferSize for gRPC gRPC. See grpc.WithWriteBufferSize.
// (https://godoc.org/google.golang.org/grpc#WithWriteBufferSize).
WriteBufferSize int `mapstructure:"write_buffer_size,omitempty"`
// WaitForReady parameter configures client to wait for ready state before sending data.
// (https://github.com/grpc/grpc/blob/master/doc/wait-for-ready.md)
WaitForReady bool `mapstructure:"wait_for_ready,omitempty"`
// The headers associated with gRPC requests.
Headers configopaque.MapList `mapstructure:"headers,omitempty"`
// Sets the balancer in grpclb_policy to discover the servers. Default is pick_first.
// https://github.com/grpc/grpc-go/blob/master/examples/features/load_balancing/README.md
BalancerName string `mapstructure:"balancer_name"`
// WithAuthority parameter configures client to rewrite ":authority" header
// (godoc.org/google.golang.org/grpc#WithAuthority)
Authority string `mapstructure:"authority,omitempty"`
// Auth configuration for outgoing RPCs.
Auth configoptional.Optional[configauth.Config] `mapstructure:"auth,omitempty"`
// Middlewares for the gRPC client.
Middlewares []configmiddleware.Config `mapstructure:"middlewares,omitempty"`
}
ClientConfig defines common settings for a gRPC client configuration.
func NewDefaultClientConfig ¶ added in v0.100.0
func NewDefaultClientConfig() ClientConfig
NewDefaultClientConfig returns a new instance of ClientConfig with default values.
func (*ClientConfig) ToClientConn ¶ added in v0.94.0
func (cc *ClientConfig) ToClientConn( ctx context.Context, extensions map[component.ID]component.Component, settings component.TelemetrySettings, extraOpts ...ToClientConnOption, ) (*grpc.ClientConn, error)
ToClientConn creates a client connection to the given target. By default, it's a non-blocking dial (the function won't wait for connections to be established, and connecting happens in the background). To make it a blocking dial, use the WithGrpcDialOption(grpc.WithBlock()) option.
To allow the configuration to reference middleware or authentication extensions, the `extensions` argument should be the output of `host.GetExtensions()`. It may also be `nil` in tests where no such extension is expected to be used.
func (*ClientConfig) Validate ¶ added in v0.111.0
func (cc *ClientConfig) Validate() error
type KeepaliveClientConfig ¶
type KeepaliveClientConfig struct {
Time time.Duration `mapstructure:"time"`
Timeout time.Duration `mapstructure:"timeout"`
PermitWithoutStream bool `mapstructure:"permit_without_stream,omitempty"`
// contains filtered or unexported fields
}
KeepaliveClientConfig exposes the keepalive.ClientParameters to be used by the exporter. Refer to the original data-structure for the meaning of each parameter: https://godoc.org/google.golang.org/grpc/keepalive#ClientParameters
func NewDefaultKeepaliveClientConfig ¶ added in v0.100.0
func NewDefaultKeepaliveClientConfig() KeepaliveClientConfig
NewDefaultKeepaliveClientConfig returns a new instance of KeepaliveClientConfig with default values.
type KeepaliveEnforcementPolicy ¶
type KeepaliveEnforcementPolicy struct {
MinTime time.Duration `mapstructure:"min_time,omitempty"`
PermitWithoutStream bool `mapstructure:"permit_without_stream,omitempty"`
// contains filtered or unexported fields
}
KeepaliveEnforcementPolicy allow configuration of the keepalive.EnforcementPolicy. The same default values as keepalive.EnforcementPolicy are applicable and get applied by the server. See https://godoc.org/google.golang.org/grpc/keepalive#EnforcementPolicy for details.
func NewDefaultKeepaliveEnforcementPolicy ¶ added in v0.100.0
func NewDefaultKeepaliveEnforcementPolicy() KeepaliveEnforcementPolicy
NewDefaultKeepaliveEnforcementPolicy creates and returns a new instance of KeepaliveEnforcementPolicy with default settings.
type KeepaliveServerConfig ¶
type KeepaliveServerConfig struct {
ServerParameters configoptional.Optional[KeepaliveServerParameters] `mapstructure:"server_parameters,omitempty"`
EnforcementPolicy configoptional.Optional[KeepaliveEnforcementPolicy] `mapstructure:"enforcement_policy,omitempty"`
// contains filtered or unexported fields
}
KeepaliveServerConfig is the configuration for keepalive.
func NewDefaultKeepaliveServerConfig ¶ added in v0.100.0
func NewDefaultKeepaliveServerConfig() KeepaliveServerConfig
NewDefaultKeepaliveServerConfig returns a new instance of KeepaliveServerConfig with default values.
type KeepaliveServerParameters ¶
type KeepaliveServerParameters struct {
MaxConnectionIdle time.Duration `mapstructure:"max_connection_idle,omitempty"`
MaxConnectionAge time.Duration `mapstructure:"max_connection_age,omitempty"`
MaxConnectionAgeGrace time.Duration `mapstructure:"max_connection_age_grace,omitempty"`
Time time.Duration `mapstructure:"time,omitempty"`
Timeout time.Duration `mapstructure:"timeout,omitempty"`
// contains filtered or unexported fields
}
KeepaliveServerParameters allow configuration of the keepalive.ServerParameters. The same default values as keepalive.ServerParameters are applicable and get applied by the server. See https://godoc.org/google.golang.org/grpc/keepalive#ServerParameters for details.
func NewDefaultKeepaliveServerParameters ¶ added in v0.100.0
func NewDefaultKeepaliveServerParameters() KeepaliveServerParameters
NewDefaultKeepaliveServerParameters creates and returns a new instance of KeepaliveServerParameters with default settings.
type ServerConfig ¶ added in v0.94.0
type ServerConfig struct {
// Server net.Addr config. For transport only "tcp" and "unix" are valid options.
NetAddr confignet.AddrConfig `mapstructure:",squash"`
// Configures the protocol to use TLS.
// The default value is nil, which will cause the protocol to not use TLS.
TLS configoptional.Optional[configtls.ServerConfig] `mapstructure:"tls,omitempty"`
// MaxRecvMsgSizeMiB sets the maximum size (in MiB) of messages accepted by the server.
MaxRecvMsgSizeMiB int `mapstructure:"max_recv_msg_size_mib,omitempty"`
// MaxConcurrentStreams sets the limit on the number of concurrent streams to each ServerTransport.
// It has effect only for streaming RPCs.
MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams,omitempty,omitempty"`
// ReadBufferSize for gRPC server. See grpc.ReadBufferSize.
// (https://godoc.org/google.golang.org/grpc#ReadBufferSize).
ReadBufferSize int `mapstructure:"read_buffer_size,omitempty"`
// WriteBufferSize for gRPC server. See grpc.WriteBufferSize.
// (https://godoc.org/google.golang.org/grpc#WriteBufferSize).
WriteBufferSize int `mapstructure:"write_buffer_size,omitempty"`
// Keepalive anchor for all the settings related to keepalive.
Keepalive configoptional.Optional[KeepaliveServerConfig] `mapstructure:"keepalive,omitempty"`
// Auth for this receiver
Auth configoptional.Optional[configauth.Config] `mapstructure:"auth,omitempty"`
// Include propagates the incoming connection's metadata to downstream consumers.
IncludeMetadata bool `mapstructure:"include_metadata,omitempty"`
// Middlewares for the gRPC server.
Middlewares []configmiddleware.Config `mapstructure:"middlewares,omitempty"`
// contains filtered or unexported fields
}
ServerConfig defines common settings for a gRPC server configuration.
func NewDefaultServerConfig ¶ added in v0.100.0
func NewDefaultServerConfig() ServerConfig
NewDefaultServerConfig returns a new instance of ServerConfig with default values.
func (*ServerConfig) ToServer ¶ added in v0.94.0
func (sc *ServerConfig) ToServer( ctx context.Context, extensions map[component.ID]component.Component, settings component.TelemetrySettings, extraOpts ...ToServerOption, ) (*grpc.Server, error)
ToServer returns a grpc.Server for the configuration.
To allow the configuration to reference middleware or authentication extensions, the `extensions` argument should be the output of `host.GetExtensions()`. It may also be `nil` in tests where no such extension is expected to be used.
func (*ServerConfig) Validate ¶ added in v0.109.0
func (sc *ServerConfig) Validate() error
type ToClientConnOption ¶ added in v0.110.0
type ToClientConnOption interface {
// contains filtered or unexported methods
}
ToClientConnOption is a sealed interface wrapping options for ClientConfig.ToClientConn.
func WithGrpcDialOption ¶ added in v0.110.0
func WithGrpcDialOption(opt grpc.DialOption) ToClientConnOption
WithGrpcDialOption wraps a grpc.DialOption into a ToClientConnOption.
type ToServerOption ¶ added in v0.110.0
type ToServerOption interface {
// contains filtered or unexported methods
}
ToServerOption is a sealed interface wrapping options for ServerConfig.ToServer.
func WithGrpcServerOption ¶ added in v0.110.0
func WithGrpcServerOption(opt grpc.ServerOption) ToServerOption
WithGrpcServerOption wraps a grpc.ServerOption into a ToServerOption.