Documentation ¶
Index ¶
- type GRPCConfiguration
- type GRPCService
- type GRPCSetupFunc
- type Interceptor
- type RESTService
- func (service *RESTService) DialOpts(options []grpc.DialOption) *RESTService
- func (service *RESTService) Name() string
- func (service *RESTService) StartWithContext(ctx context.Context) error
- func (service *RESTService) Stop() error
- func (service *RESTService) WithInsecure(value bool) *RESTService
- func (service *RESTService) WithInterceptor(interceptor Interceptor) *RESTService
- func (service *RESTService) WithUserAgent(value string) *RESTService
- type RESTSetupFunc
- type ViperConfiguration
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 ¶
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 ViperConfiguration ¶
ViperConfiguration is the `GRPCConfiguration` implementation for `viper`.
func (*ViperConfiguration) BindAddr ¶
func (c *ViperConfiguration) BindAddr() (string, error)