server

package
v0.0.0-...-d74ee84 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2020 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package server is a generated protocol buffer package.

It is generated from these files:

fake_server.proto

It has these top-level messages:

FailWithHTTPErrorRequest

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterFakeServerServer

func RegisterFakeServerServer(s *grpc.Server, srv FakeServerServer)

func RegisterInstrumentation

func RegisterInstrumentation(router *mux.Router)

RegisterInstrumentation on the given router.

Types

type Config

type Config struct {
	MetricsNamespace  string `yaml:"-"`
	HTTPListenAddress string `yaml:"http_listen_address"`
	HTTPListenPort    int    `yaml:"http_listen_port"`
	HTTPConnLimit     int    `yaml:"http_listen_conn_limit"`
	GRPCListenAddress string `yaml:"grpc_listen_address"`
	GRPCListenPort    int    `yaml:"grpc_listen_port"`
	GRPCConnLimit     int    `yaml:"grpc_listen_conn_limit"`

	RegisterInstrumentation bool `yaml:"register_instrumentation"`
	ExcludeRequestInLog     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:"-"`

	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"`

	LogLevel logging.Level     `yaml:"log_level"`
	Log      logging.Interface `yaml:"-"`

	PathPrefix string `yaml:"http_path_prefix"`
}

Config for a Server

func (*Config) RegisterFlags

func (cfg *Config) RegisterFlags(f *flag.FlagSet)

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" json:"Code,omitempty"`
}

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

type FakeServerClient

type FakeServerClient interface {
	Succeed(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
	FailWithError(ctx context.Context, in *google_protobuf.Empty, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
	FailWithHTTPError(ctx context.Context, in *FailWithHTTPErrorRequest, opts ...grpc.CallOption) (*google_protobuf.Empty, error)
}

func NewFakeServerClient

func NewFakeServerClient(cc *grpc.ClientConn) FakeServerClient

type Server

type Server struct {
	HTTP       *mux.Router
	HTTPServer *http.Server
	GRPC       *grpc.Server
	Log        logging.Interface
	// 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 New

func New(cfg Config) (*Server, error)

New makes a new Server

func (*Server) Run

func (s *Server) Run() error

Run the server; blocks until SIGTERM or an error is received.

func (*Server) Shutdown

func (s *Server) Shutdown()

Shutdown the server, gracefully. Should be defered after New().

func (*Server) Stop

func (s *Server) Stop()

Stop unblocks Run().

Jump to

Keyboard shortcuts

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