service

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2020 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewOptions

func NewOptions() *options

Types

type Option

type Option func(*options)

func WithAddress

func WithAddress(addr string) Option

WithAddress sets the address of the server

func WithAfterStart

func WithAfterStart(fn ...func() error) Option

func WithAfterStop

func WithAfterStop(fn ...func() error) Option

func WithBeforeStart

func WithBeforeStart(fn ...func() error) Option

func WithBeforeStop

func WithBeforeStop(fn ...func() error) Option

func WithCACert

func WithCACert(path string) Option

func WithCert

func WithCert(path string) Option

func WithContext

func WithContext(ctx context.Context) Option

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

func WithDB

func WithDB(dialect string, args ...interface{}) Option

func WithGRPCServerOpts

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

func WithKey

func WithKey(path string) Option

func WithName

func WithName(name string) Option

func WithReflection

func WithReflection(r bool) Option

func WithRegistry

func WithRegistry(registry registry.Registry) Option

func WithSecure

func WithSecure(s bool) Option

func WithStreamClientInterceptor

func WithStreamClientInterceptor(i ...grpc.StreamClientInterceptor) Option

func WithStreamServerInterceptor

func WithStreamServerInterceptor(i ...grpc.StreamServerInterceptor) Option

func WithSubscriberInterceptor

func WithSubscriberInterceptor(w ...interface{}) Option

WithSubscriberInterceptor adds subscriber interceptors to the options passed into the server

func WithTLSConfig

func WithTLSConfig(conf *tls.Config) Option

func WithUnaryClientInterceptor

func WithUnaryClientInterceptor(i ...grpc.UnaryClientInterceptor) Option

func WithUnaryServerInterceptor

func WithUnaryServerInterceptor(i ...grpc.UnaryServerInterceptor) Option

WithUnaryServerInterceptor adds unary Wrapper interceptors to the options passed into the server

func WithVersion

func WithVersion(version string) Option

type Options

type Options interface {
	Context() context.Context
	Name() string
	Version() string
	Address() string
	Reflection() bool
	CACert() string
	Cert() string
	Key() string
	TLSConfig() *tls.Config
	Secure() bool
	Registry() registry.Registry
	DB() *gorm.DB
	BeforeStart() []func() error
	AfterStart() []func() error
	BeforeStop() []func() error
	AfterStop() []func() error
	ServerOpts() []grpc.ServerOption
	ServerInterceptors() []grpc.UnaryServerInterceptor
	StreamServerInterceptors() []grpc.StreamServerInterceptor
	ClientInterceptors() []grpc.UnaryClientInterceptor
	StreamClientInterceptors() []grpc.StreamClientInterceptor
	Defaults()
}

type Service

type Service interface {
	Options() Options
	Server() *grpc.Server
	DB() *gorm.DB
	Start() error
	Stop() error
	Close() error
	Cmd() *cobra.Command

	RegisterService(desc *grpc.ServiceDesc, impl interface{})
}

func New

func New(opts ...Option) (Service, error)

Jump to

Keyboard shortcuts

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