goservice

package module
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service handles config required by the service

func NewService

func NewService(opts ...ServiceOption) *Service

NewService creates a new service

func (*Service) Broker

func (s *Service) Broker() broker.Broker

Broker returns the instance as broker.Broker

func (*Service) Client

func (s *Service) Client() client.Client

Client returns the instance as client.Client

func (*Service) Database

func (s *Service) Database() db.ServiceDatabase

Database returns the instance as database.ServiceDatabase

func (*Service) Init

func (s *Service) Init(ctx context.Context) error

Init initializes the service Configures dependencies

func (*Service) IterateComponents

func (s *Service) IterateComponents(
	ctx context.Context,
	cb func(ctx context.Context, key string, comp component.Component) error,
) error

IterateComponents - iterates over all the service components and invokes the callback

func (*Service) KVStore

func (s *Service) KVStore() kvstore.KVStore

KVStore returns the instance as kvstore.KVStore

func (*Service) Logger

func (s *Service) Logger() logger.Logger

Logger returns the instance as logger.Logger

func (*Service) Registry

func (s *Service) Registry() registry.ServiceRegistry

Registry returns the instance as registry.ServiceRegistry

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

Run runs all the components of the service

func (*Service) Server

func (s *Service) Server() server.Server

Server returns the instance as server.Server

func (*Service) ShutDown

func (s *Service) ShutDown(ctx context.Context)

Shutdown - shuts down the service by stopping all the components

func (*Service) Tracer

func (s *Service) Tracer() tracer.Tracer

Tracer returns the instance as tracer.Tracer

type ServiceOption

type ServiceOption func(*Service)

ServiceOption to pass as arg while creating new service

func WithBroker

func WithBroker(b broker.Broker) ServiceOption

WithBroker sets a broker for the service

func WithClient

func WithClient(c client.Client) ServiceOption

WithClient registers the server's client

func WithDatabase

func WithDatabase(database db.ServiceDatabase) ServiceOption

WithDatabase sets the database used by the service

func WithKVStore

func WithKVStore(kvStore kvstore.KVStore) ServiceOption

WithKVStore passes the kvstore used by the service

func WithLogger

func WithLogger(l logger.Logger) ServiceOption

WithLogger sets the logger used by the service

func WithRegistry

func WithRegistry(r registry.ServiceRegistry) ServiceOption

WithRegistry passes services registry externally

func WithServer

func WithServer(srv server.Server) ServiceOption

WithServer passes the server

func WithTracer

func WithTracer(t tracer.Tracer) ServiceOption

WithTracer assigns the tracer to be used by the service

Jump to

Keyboard shortcuts

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