Documentation
¶
Index ¶
Constants ¶
View Source
const ( // DefaultGRPCAddr is the default address for the gRPC endpoint. DefaultGRPCAddr = "127.0.0.1:50051" // DefaultHTTPAddr is the default address for the HTTP endpoint. DefaultHTTPAddr = "127.0.0.1:9090" // DefaultDebugAddr is the default address for the debug endpoint (/debug/pprof and /debug/vars). DefaultDebugAddr = "127.0.0.1:6060" // DefaultMaxSendMsgSize is the default max send message size, per gRPC DefaultMaxSendMsgSize = 1024 * 1024 * 4 // DefaultMaxRecvMsgSize is the default max receive message size, per gRPC DefaultMaxRecvMsgSize = 1024 * 1024 * 4 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GRPCServer ¶
GRPCServer is used to register a gRPC server.
type HTTPGateway ¶
type HTTPGateway func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
HTTPGateway is used to register a HTTP gateway for forwarding requests to a gRPC endpoint.
type Hoster ¶
type Hoster struct { // GRPCAddr is the endpoint (host and port) on which to host the gRPC service. Default is 127.0.0.1:50051. May be left blank if no gRPC servers have been registered. GRPCAddr string // HTTPAddr is the endpoint (host and port) on which to host the HTTP service. Default is 127.0.0.1:9090. May be left blank if no HTTP gateways have been registered. HTTPAddr string // DebugAddr is the endpoint (host and port) on which to host the debug endpoint (/debug/pprof and /debug/vars). Default is 127.0.0.1:6060. May be left blank if EnableDebug is false. DebugAddr string // CertFile is the certificate file for use with TLS. May be left blank if using insecure mode. CertFile string // KeyFile is the private key file for use with TLS. May be left blank if using insecure mode. KeyFile string // InsecureSkipVerify will cause verification of the host name during a TLS handshake to be skipped if set to true. InsecureSkipVerify bool // HTTPHandler is used to register a handler that can optionally be added to the HTTP endpoint. Leave blank to use default mux. HTTPHandler func(mux *runtime.ServeMux) http.Handler // EnableDebug will enable the debug endpoint (/debug/pprof and /debug/vars). The debug endpoint address is defined by DebugAddr. EnableDebug bool // MaxSendMsgSize will change the size of the message that can be sent from the service. MaxSendMsgSize int // MaxRecvMsgSize will change the size of the message that can be received by the service. MaxRecvMsgSize int // UnaryInterceptors is an array of unary interceptors to be used by the service. They will be executed in order, from first to last. UnaryInterceptors []grpc.UnaryServerInterceptor // StreamInterceptors is an array of stream interceptors to be used by the service. They will be executed in order, from first to last. StreamInterceptors []grpc.StreamServerInterceptor // contains filtered or unexported fields }
Hoster is used to serve gRPC and HTTP endpoints.
func NewHoster ¶
func NewHoster() *Hoster
NewHoster creates a new hoster instance with defaults set.
func (*Hoster) ListenAndServe ¶
ListenAndServe creates and starts the server.
func (*Hoster) RegisterGRPCServer ¶
func (h *Hoster) RegisterGRPCServer(servers ...GRPCServer)
RegisterGRPCServer will add a function for registering a gRPC server. The function is invoked when ListenAndServe is called.
func (*Hoster) RegisterHTTPGateway ¶
func (h *Hoster) RegisterHTTPGateway(gateways ...HTTPGateway)
RegisterHTTPGateway will add a function for registering a HTTP gateway. The function is invoked when ListenAndServe is called.
Directories
¶
Path | Synopsis |
---|---|
examples
|
|
hello/proto
Package hello is a generated protocol buffer package.
|
Package hello is a generated protocol buffer package. |
test/proto
Package test is a generated protocol buffer package.
|
Package test is a generated protocol buffer package. |
Click to show internal directories.
Click to hide internal directories.