server

package
v0.0.0-...-66c088b Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2020 License: ISC Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GRPCServer

type GRPCServer struct {
	// contains filtered or unexported fields
}

GRPCServer is a gRPC server implementing graceful.Server interface.

func NewGRPCServer

func NewGRPCServer(greetingService greetingpb.GreetingServiceServer, opts GRPCServerOptions) (*GRPCServer, error)

NewGRPCServer creates a new instance of gRPC Server.

func (*GRPCServer) ListenAndServe

func (s *GRPCServer) ListenAndServe() error

ListenAndServe starts listening for incoming requests synchronously. It blocks the current goroutine until an error is returned.

func (*GRPCServer) Shutdown

func (s *GRPCServer) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server. It stops accepting new conenctions and blocks the current goroutine until all the pending requests are completed. If the context is cancelled, an error will be returned.

func (*GRPCServer) String

func (s *GRPCServer) String() string

String returns the name of the server.

type GRPCServerOptions

type GRPCServerOptions struct {
	// The port number for the gRPC server.
	// The default port number is 9090.
	Port uint16

	// A TLS certificate for the gRPC server identity.
	TLSCert *tls.Certificate

	// A pool of certificate authorities for verifying gRPC client identities.
	ClientCA *x509.CertPool

	// Additional options for the gRPC server.
	Options []grpc.ServerOption
}

GRPCServerOptions are optional settings for creating a gRPC server.

type HTTPServer

type HTTPServer struct {
	// contains filtered or unexported fields
}

HTTPServer is an HTTP server implementing graceful.Server interface.

func NewHTTPServer

func NewHTTPServer(healthHandler http.Handler, opts HTTPServerOptions) (*HTTPServer, error)

NewHTTPServer creates a new instance of HTTP Server.

func (*HTTPServer) ListenAndServe

func (s *HTTPServer) ListenAndServe() error

ListenAndServe starts listening for incoming requests synchronously. It blocks the current goroutine until an error is returned.

func (*HTTPServer) Shutdown

func (s *HTTPServer) Shutdown(ctx context.Context) error

Shutdown gracefully stops the server. It stops accepting new conenctions and blocks the current goroutine until all the pending requests are completed. If the context is cancelled, an error will be returned.

func (*HTTPServer) String

func (s *HTTPServer) String() string

String returns the name of the server.

type HTTPServerOptions

type HTTPServerOptions struct {
	// The port number for the HTTP server.
	// The default port number is 8080.
	Port uint16
}

HTTPServerOptions are optional settings for creating an HTTP server.

Jump to

Keyboard shortcuts

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