srvgrpc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2020 License: MIT Imports: 9 Imported by: 0

README

services-grpc

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GRPCConfiguration

type GRPCConfiguration interface {
	// BindAddr returns the bind address for the GRPC server when `GRPCService` is starting. It will be called only
	// when the `Start` of the `GRPCService` is called.
	BindAddr() (string, error)
}

GRPCConfiguration abstracts the implementation for the GRPCService configuration.

type GRPCService

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

GRPCService is the `services.Service` implementation for GRPC services.

func NewGRPCService

func NewGRPCService(name string, config GRPCConfiguration, setupFunc GRPCSetupFunc) *GRPCService

NewGRPCService returns a new instance of the `GRPCService`.

Arguments:

  • `name` identifies the service, required by the `github.com/setare/services.Service` interface.
  • `config` will provide additional configuration for the grpc.Server initialization. It is a `GRPCConfiguration` interface implementation.
  • `setupFunc` is the callback responsible for registering the implementation to the `*grpc.Server` that is passed as argument.

func (*GRPCService) Name

func (service *GRPCService) Name() string

Name will return a human identifiable name for this service. Ex: Postgresql Connection.

func (*GRPCService) ServerOptions

func (service *GRPCService) ServerOptions(options ...grpc.ServerOption) *GRPCService

ServerOptions set the `grpc.ServerOption` array that is passed when the service starts the `*grpc.Server`.

func (*GRPCService) StartWithContext

func (service *GRPCService) StartWithContext(ctx context.Context) error

StartWithContext start the service in a blocking way. This is cancellable, so the context received can be cancelled at any moment. If your start implementation is not cancellable, you should implement `Startable` instead.

If the service is successfully started, `nil` should be returned. Otherwise, an error must be returned.

func (*GRPCService) Stop

func (service *GRPCService) Stop() error

Stop will stop this service.

For most implementations it will be blocking and should return only when the service finishes stopping.

If the service is successfully stopped, `nil` should be returned. Otherwise, an error must be returned.

type GRPCSetupFunc

type GRPCSetupFunc func(*grpc.Server)

GRPCSetupFunc receives the `grpc.Server` instance and should register it on target package.

type Interceptor

type Interceptor func(rw http.ResponseWriter, r *http.Request, next func())

type RESTService

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

func NewRESTService

func NewRESTService(bindAddr, name string, setupFunc RESTSetupFunc) *RESTService

func (*RESTService) DialOpts

func (service *RESTService) DialOpts(options []grpc.DialOption) *RESTService

func (*RESTService) Name

func (service *RESTService) Name() string

Name will return a human identifiable name for this service. Ex: Postgresql Connection.

func (*RESTService) StartWithContext

func (service *RESTService) StartWithContext(ctx context.Context) error

StartWithContext start the service in a blocking way. This is cancellable, so the context received can be cancelled at any moment. If your start implementation is not cancellable, you should implement `Startable` instead.

If the service is successfully started, `nil` should be returned. Otherwise, an error must be returned.

func (*RESTService) Stop

func (service *RESTService) Stop() error

Stop will stop this service.

For most implementations it will be blocking and should return only when the service finishes stopping.

If the service is successfully stopped, `nil` should be returned. Otherwise, an error must be returned.

func (*RESTService) WithInsecure

func (service *RESTService) WithInsecure(value bool) *RESTService

func (*RESTService) WithInterceptor

func (service *RESTService) WithInterceptor(interceptor Interceptor) *RESTService

func (*RESTService) WithUserAgent

func (service *RESTService) WithUserAgent(value string) *RESTService

type RESTSetupFunc

type RESTSetupFunc func(context.Context, *runtime.ServeMux, ...grpc.DialOption) error

type ViperConfiguration

type ViperConfiguration struct {
	Prefix string
	Viper  *viper.Viper
}

ViperConfiguration is the `GRPCConfiguration` implementation for `viper`.

func (*ViperConfiguration) BindAddr

func (c *ViperConfiguration) BindAddr() (string, error)

Jump to

Keyboard shortcuts

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