Documentation
¶
Index ¶
- Constants
- func RegisterFakeServerServer(s *grpc.Server, srv FakeServerServer)
- func RegisterInstrumentation(router *mux.Router)
- func RegisterInstrumentationWithGatherer(router *mux.Router, gatherer prometheus.Gatherer)
- type Config
- type FailWithHTTPErrorRequest
- func (*FailWithHTTPErrorRequest) Descriptor() ([]byte, []int)
- func (m *FailWithHTTPErrorRequest) GetCode() int32
- func (*FailWithHTTPErrorRequest) ProtoMessage()
- func (m *FailWithHTTPErrorRequest) Reset()
- func (m *FailWithHTTPErrorRequest) String() string
- func (m *FailWithHTTPErrorRequest) XXX_DiscardUnknown()
- func (m *FailWithHTTPErrorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *FailWithHTTPErrorRequest) XXX_Merge(src proto.Message)
- func (m *FailWithHTTPErrorRequest) XXX_Size() int
- func (m *FailWithHTTPErrorRequest) XXX_Unmarshal(b []byte) error
- type FakeServerClient
- type FakeServerServer
- type FakeServer_StreamSleepClient
- type FakeServer_StreamSleepServer
- type Metrics
- type Server
- type SignalHandler
- type TLSConfig
- type UnimplementedFakeServerServer
- func (*UnimplementedFakeServerServer) FailWithError(ctx context.Context, req *empty.Empty) (*empty.Empty, error)
- func (*UnimplementedFakeServerServer) FailWithHTTPError(ctx context.Context, req *FailWithHTTPErrorRequest) (*empty.Empty, error)
- func (*UnimplementedFakeServerServer) Sleep(ctx context.Context, req *empty.Empty) (*empty.Empty, error)
- func (*UnimplementedFakeServerServer) StreamSleep(req *empty.Empty, srv FakeServer_StreamSleepServer) error
- func (*UnimplementedFakeServerServer) Succeed(ctx context.Context, req *empty.Empty) (*empty.Empty, error)
Constants ¶
const ( // DefaultNetwork the host resolves to multiple IP addresses, // Dial will try each IP address in order until one succeeds DefaultNetwork = "tcp" // NetworkTCPV4 for IPV4 only NetworkTCPV4 = "tcp4" )
Listen on the named network
Variables ¶
This section is empty.
Functions ¶
func RegisterFakeServerServer ¶
func RegisterFakeServerServer(s *grpc.Server, srv FakeServerServer)
func RegisterInstrumentation ¶
RegisterInstrumentation on the given router.
func RegisterInstrumentationWithGatherer ¶
func RegisterInstrumentationWithGatherer(router *mux.Router, gatherer prometheus.Gatherer)
RegisterInstrumentationWithGatherer on the given router.
Types ¶
type Config ¶
type Config struct {
MetricsNamespace string `yaml:"-"`
// Set to > 1 to add native histograms to requestDuration.
// See documentation for NativeHistogramBucketFactor in
// https://pkg.go.dev/github.com/prometheus/client_golang/prometheus#HistogramOpts
// for details. A generally useful value is 1.1.
MetricsNativeHistogramFactor float64 `yaml:"-"`
HTTPListenNetwork string `yaml:"http_listen_network"`
HTTPListenAddress string `yaml:"http_listen_address"`
HTTPListenPort int `yaml:"http_listen_port"`
HTTPConnLimit int `yaml:"http_listen_conn_limit"`
GRPCListenNetwork string `yaml:"grpc_listen_network"`
GRPCListenAddress string `yaml:"grpc_listen_address"`
GRPCListenPort int `yaml:"grpc_listen_port"`
GRPCConnLimit int `yaml:"grpc_listen_conn_limit"`
CipherSuites string `yaml:"tls_cipher_suites"`
MinVersion string `yaml:"tls_min_version"`
HTTPTLSConfig TLSConfig `yaml:"http_tls_config"`
GRPCTLSConfig TLSConfig `yaml:"grpc_tls_config"`
RegisterInstrumentation bool `yaml:"register_instrumentation"`
ExcludeRequestInLog bool `yaml:"-"`
DisableRequestSuccessLog bool `yaml:"-"`
ServerGracefulShutdownTimeout time.Duration `yaml:"graceful_shutdown_timeout"`
HTTPServerReadTimeout time.Duration `yaml:"http_server_read_timeout"`
HTTPServerWriteTimeout time.Duration `yaml:"http_server_write_timeout"`
HTTPServerIdleTimeout time.Duration `yaml:"http_server_idle_timeout"`
GRPCOptions []grpc.ServerOption `yaml:"-"`
GRPCMiddleware []grpc.UnaryServerInterceptor `yaml:"-"`
GRPCStreamMiddleware []grpc.StreamServerInterceptor `yaml:"-"`
HTTPMiddleware []middleware.Interface `yaml:"-"`
Router *mux.Router `yaml:"-"`
DoNotAddDefaultHTTPMiddleware bool `yaml:"-"`
RouteHTTPToGRPC bool `yaml:"-"`
GPRCServerMaxRecvMsgSize int `yaml:"grpc_server_max_recv_msg_size"`
GRPCServerMaxSendMsgSize int `yaml:"grpc_server_max_send_msg_size"`
GPRCServerMaxConcurrentStreams uint `yaml:"grpc_server_max_concurrent_streams"`
GRPCServerMaxConnectionIdle time.Duration `yaml:"grpc_server_max_connection_idle"`
GRPCServerMaxConnectionAge time.Duration `yaml:"grpc_server_max_connection_age"`
GRPCServerMaxConnectionAgeGrace time.Duration `yaml:"grpc_server_max_connection_age_grace"`
GRPCServerTime time.Duration `yaml:"grpc_server_keepalive_time"`
GRPCServerTimeout time.Duration `yaml:"grpc_server_keepalive_timeout"`
GRPCServerMinTimeBetweenPings time.Duration `yaml:"grpc_server_min_time_between_pings"`
GRPCServerPingWithoutStreamAllowed bool `yaml:"grpc_server_ping_without_stream_allowed"`
LogFormat logging.Format `yaml:"log_format"`
LogLevel logging.Level `yaml:"log_level"`
Log logging.Interface `yaml:"-"`
LogSourceIPs bool `yaml:"log_source_ips_enabled"`
LogSourceIPsHeader string `yaml:"log_source_ips_header"`
LogSourceIPsRegex string `yaml:"log_source_ips_regex"`
LogRequestHeaders bool `yaml:"log_request_headers"`
LogRequestAtInfoLevel bool `yaml:"log_request_at_info_level_enabled"`
LogRequestExcludeHeadersList string `yaml:"log_request_exclude_headers_list"`
// If not set, default signal handler is used.
SignalHandler SignalHandler `yaml:"-"`
// If not set, default Prometheus registry is used.
Registerer prometheus.Registerer `yaml:"-"`
Gatherer prometheus.Gatherer `yaml:"-"`
PathPrefix string `yaml:"http_path_prefix"`
}
Config for a Server
func (*Config) RegisterFlags ¶
RegisterFlags adds the flags required to config this to the given FlagSet
type FailWithHTTPErrorRequest ¶
type FailWithHTTPErrorRequest struct {
Code int32 `protobuf:"varint,1,opt,name=Code,proto3" json:"Code,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func (*FailWithHTTPErrorRequest) Descriptor ¶
func (*FailWithHTTPErrorRequest) Descriptor() ([]byte, []int)
func (*FailWithHTTPErrorRequest) GetCode ¶
func (m *FailWithHTTPErrorRequest) GetCode() int32
func (*FailWithHTTPErrorRequest) ProtoMessage ¶
func (*FailWithHTTPErrorRequest) ProtoMessage()
func (*FailWithHTTPErrorRequest) Reset ¶
func (m *FailWithHTTPErrorRequest) Reset()
func (*FailWithHTTPErrorRequest) String ¶
func (m *FailWithHTTPErrorRequest) String() string
func (*FailWithHTTPErrorRequest) XXX_DiscardUnknown ¶
func (m *FailWithHTTPErrorRequest) XXX_DiscardUnknown()
func (*FailWithHTTPErrorRequest) XXX_Marshal ¶
func (m *FailWithHTTPErrorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*FailWithHTTPErrorRequest) XXX_Merge ¶
func (m *FailWithHTTPErrorRequest) XXX_Merge(src proto.Message)
func (*FailWithHTTPErrorRequest) XXX_Size ¶
func (m *FailWithHTTPErrorRequest) XXX_Size() int
func (*FailWithHTTPErrorRequest) XXX_Unmarshal ¶
func (m *FailWithHTTPErrorRequest) XXX_Unmarshal(b []byte) error
type FakeServerClient ¶
type FakeServerClient interface {
Succeed(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error)
FailWithError(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error)
FailWithHTTPError(ctx context.Context, in *FailWithHTTPErrorRequest, opts ...grpc.CallOption) (*empty.Empty, error)
Sleep(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (*empty.Empty, error)
StreamSleep(ctx context.Context, in *empty.Empty, opts ...grpc.CallOption) (FakeServer_StreamSleepClient, error)
}
FakeServerClient is the client API for FakeServer service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewFakeServerClient ¶
func NewFakeServerClient(cc *grpc.ClientConn) FakeServerClient
type FakeServerServer ¶
type FakeServerServer interface {
Succeed(context.Context, *empty.Empty) (*empty.Empty, error)
FailWithError(context.Context, *empty.Empty) (*empty.Empty, error)
FailWithHTTPError(context.Context, *FailWithHTTPErrorRequest) (*empty.Empty, error)
Sleep(context.Context, *empty.Empty) (*empty.Empty, error)
StreamSleep(*empty.Empty, FakeServer_StreamSleepServer) error
}
FakeServerServer is the server API for FakeServer service.
type FakeServer_StreamSleepClient ¶
type FakeServer_StreamSleepClient interface {
Recv() (*empty.Empty, error)
grpc.ClientStream
}
type FakeServer_StreamSleepServer ¶
type FakeServer_StreamSleepServer interface {
Send(*empty.Empty) error
grpc.ServerStream
}
type Metrics ¶
type Metrics struct {
TcpConnections *prometheus.GaugeVec
TcpConnectionsLimit *prometheus.GaugeVec
RequestDuration *prometheus.HistogramVec
ReceivedMessageSize *prometheus.HistogramVec
SentMessageSize *prometheus.HistogramVec
InflightRequests *prometheus.GaugeVec
}
func NewServerMetrics ¶
func (*Metrics) MustRegister ¶
func (s *Metrics) MustRegister(registerer prometheus.Registerer)
type Server ¶
type Server struct {
GRPCOnHTTPServer *grpc.Server
HTTP *mux.Router
HTTPServer *http.Server
GRPC *grpc.Server
Log logging.Interface
Registerer prometheus.Registerer
Gatherer prometheus.Gatherer
// contains filtered or unexported fields
}
Server wraps a HTTP and gRPC server, and some common initialization.
Servers will be automatically instrumented for Prometheus metrics.
func NewWithMetrics ¶
NewWithMetrics makes a new Server using the provided Metrics. It will not attempt to register the metrics, the user is responsible for doing so.
func (*Server) GRPCListenAddr ¶
GRPCListenAddr exposes `net.Addr` that `Server` is listening to for GRPC connections.
func (*Server) HTTPListenAddr ¶
HTTPListenAddr exposes `net.Addr` that `Server` is listening to for HTTP connections.
func (*Server) Run ¶
Run the server; blocks until SIGTERM (if signal handling is enabled), an error is received, or Stop() is called.
type SignalHandler ¶
type SignalHandler interface {
// Starts the signals handler. This method is blocking, and returns only after signal is received,
// or "Stop" is called.
Loop()
// Stop blocked "Loop" method.
Stop()
}
SignalHandler used by Server.
type TLSConfig ¶
type TLSConfig struct {
TLSCertPath string `yaml:"cert_file"`
TLSKeyPath string `yaml:"key_file"`
ClientAuth string `yaml:"client_auth_type"`
ClientCAs string `yaml:"client_ca_file"`
}
TLSConfig contains TLS parameters for Config.
type UnimplementedFakeServerServer ¶
type UnimplementedFakeServerServer struct {
}
UnimplementedFakeServerServer can be embedded to have forward compatible implementations.
func (*UnimplementedFakeServerServer) FailWithError ¶
func (*UnimplementedFakeServerServer) FailWithHTTPError ¶
func (*UnimplementedFakeServerServer) FailWithHTTPError(ctx context.Context, req *FailWithHTTPErrorRequest) (*empty.Empty, error)
func (*UnimplementedFakeServerServer) StreamSleep ¶
func (*UnimplementedFakeServerServer) StreamSleep(req *empty.Empty, srv FakeServer_StreamSleepServer) error