service

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultName    = "mkit.service.default"
	DefaultVersion = "latest"
	DefaultAddress = ":0"
	// DefaultShutdownTimeout defines the default timeout given to the service when calling Shutdown.
	DefaultShutdownTimeout = time.Minute * 1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Options)

func Context

func Context(ctx context.Context) Option

Context specifies a context for the service. Can be used to signal shutdown of the service Can be used for extra option values.

func Name

func Name(n string) Option

Name of the service

func Version

func Version(v string) Option

Version of the service

func WithBrokerOptions

func WithBrokerOptions(opts ...broker.Option) Option

func WithDialOptions

func WithDialOptions(opts ...grpc.DialOption) Option

func WithGrpcEndpoint

func WithGrpcEndpoint(endpoint string) Option

WithGrpcEndpoint specifies the net.Listener endpoint to use instead of the default

func WithGrpcOptions

func WithGrpcOptions(opts ...grpc.ServerOption) Option

func WithShutdownTimeout

func WithShutdownTimeout(timeout time.Duration) Option

type Options

type Options struct {
	Name    string
	Version string

	GrpcEndpoint string
	GrpcOptions  []grpc.ServerOption
	DialOptions  []grpc.DialOption

	BrokerOptions []broker.Option

	// ShutdownTimeout defines the timeout given to the http.Server when calling Shutdown.
	// If nil, DefaultShutdownTimeout is used.
	ShutdownTimeout time.Duration
	// Alternative options
	Context context.Context
}

type Remote

type Remote struct {
	Endpoint      string
	ServiceConfig string
	Authority     string
}

type Service

type Service interface {
	Options() Options
	Server() *grpc.Server
	Client(remote Remote) (*grpc.ClientConn, error)
	Broker() broker.Broker
	ApplyOptions(opts ...Option) // TODO: no use, make private ?
	Start() error
	Shutdown() error
}

func NewService

func NewService(opts ...Option) Service

NewService creates and returns a new Service based on the packages within.

Jump to

Keyboard shortcuts

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