server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package server provides the remote procedure call (RPC) server based on gRPC.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	WebRTC            WebRTCOptions
	UnaryInterceptor  grpc.UnaryServerInterceptor
	StreamInterceptor grpc.StreamServerInterceptor
}

Options change the runtime behavior of the server.

type RegisterServiceHandlerFromEndpointFunc

type RegisterServiceHandlerFromEndpointFunc func(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

A RegisterServiceHandlerFromEndpointFunc is a means to have a service attach itself to a gRPC gateway mux.

type Server

type Server interface {
	// InternalAddr returns the address from the listener used for
	// gRPC communications. It may be the same listener the server
	// was constructed with.
	InternalAddr() net.Addr

	// Start only starts up the internal gRPC server.
	Start() error

	// Serve will externally serve, on the given listener, the
	// all in one handler described by http.Handler.
	Serve(listener net.Listener) (err error)

	// Stop stops the internal gRPC and the HTTP server if it
	// was started.
	Stop() error

	// RegisterServiceServer associates a service description with
	// its implementation along with any gateway handlers.
	RegisterServiceServer(
		ctx context.Context,
		svcDesc *grpc.ServiceDesc,
		svcServer interface{},
		svcHandlers ...RegisterServiceHandlerFromEndpointFunc,
	) error

	// GatewayHandler returns a handler for gateway based gRPC requests.
	// See: https://github.com/grpc-ecosystem/grpc-gateway
	GatewayHandler() http.Handler

	// GRPCHandler returns a handler for standard grpc/grpc-web requests which
	// expect to be served from a root path.
	GRPCHandler() http.Handler

	// http.Handler implemented here is an all-in-one handler for any kind of gRPC traffic.
	// This is useful in a scenario where all gRPC is served from the root path due to
	// limitations of normal gRPC being served from a non-root path.
	http.Handler

	// SignalingAddr returns the WebRTC signaling address in use.
	SignalingAddr() string

	// SignalingHost returns the host WebRTC communications are happening on behalf of.
	SignalingHost() string
}

A Server provides a convenient way to get a gRPC server up and running with HTTP facilities.

func New

func New(logger golog.Logger) (Server, error)

New returns a new server ready to be started that will listen on some random port bound to localhost.

func NewWithListener

func NewWithListener(
	grpcListener net.Listener,
	opts Options,
	logger golog.Logger,
) (Server, error)

NewWithListener returns a new server ready to be started that will listen on the given listener.

func NewWithOptions

func NewWithOptions(opts Options, logger golog.Logger) (Server, error)

NewWithOptions returns a new server ready to be started that will listen on some random port bound to localhost.

type WebRTCOptions

type WebRTCOptions struct {
	// Enable controls if WebRTC should be turned on. It is disabled
	// by default since signaling has the potential to open up random
	// ports on the host which may not be expected.
	Enable bool

	// Insecure determines if communications are expected to be insecure or not.
	Insecure bool

	// EnableSignaling controls if this server will provide SDP signaling
	// assistance.
	EnableSignaling bool

	// SignalingAddress specifies where the WebRTC signaling
	// answerer should connect to and "listen" from. If it is empty,
	// it will connect to the server's internal address acting as
	// an answerer for itself.
	SignalingAddress string

	// SignalingHost specifies what host is being listened for.
	SignalingHost string
}

WebRTCOptions control how WebRTC is utilized in a server.

Jump to

Keyboard shortcuts

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