service

package
v0.0.45 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flags

func Flags() []flag.Flag

Flags returns the flags for the services.

func Serve

func Serve(ctx context.Context, options ...Option) error

Serve starts the services accepting connections. Serve blocks until an error occurs, or until the context fires (which triggers a graceful shutdown). This should only be called after the flags have been parsed.

Types

type CreateServerFunc

type CreateServerFunc func(context.Context, *Options, log.Interface) (grpcutil.Server, error)

CreateServerFunc is a function to create a server.

type Info

type Info struct {
	Name           string           // The service name
	DefaultTCPPort int              // The default TCP port
	DefaultWSPort  int              // The default websocket port
	Create         CreateServerFunc // The creation func
	Addr           *address.Address // The default server address
	Env            string           // The env name used to set the server address
}

Info is the info describing a service.

func (*Info) Register

func (info *Info) Register() error

Register registers a service.

func (*Info) Validate

func (info *Info) Validate() error

Validate validates the data.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option sets options on a server.

func Log

func Log(lg log.Interface) Option

Log sets the destination log.

func MaxNumConnections

func MaxNumConnections(n int) Option

MaxNumConnections sets the maximum number of incoming connections per socket.

func SSLCert

func SSLCert(crt []byte) Option

SSLCert adds the given SSL certificate for outgoing connections.

func SSLCertAndKey

func SSLCertAndKey(crt []byte, key []byte) Option

SSLCertAndKey adds the given SSL public certificate and private key pair for incoming connections.

func SSLDisabled added in v0.0.22

func SSLDisabled() Option

SSLDisabled marks SSL as disabled for outgoing connections.

type Options

type Options struct {
	Address     *address.Address // The address
	SSLDisabled bool             // Is SSL disabled for outgoing connections?
	SSLCert     []byte           // The SSL certificate for outgoing connections
	SSLKeyCert  []byte           // The server's SSL (public) certificate for incoming connections
	SSLKey      []byte           // The server's SSL (private) key for incoming connections
}

Options are the options passed to a server on creation.

Jump to

Keyboard shortcuts

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