xservice

package
v0.0.27 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: Apache-2.0 Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunService

func RunService(ctx context.Context, s RunnerCloser) error

RunService runs the service and locks the thread while running given service.

Types

type Closer

type Closer interface {
	Close(ctx context.Context) error
}

Closer is an interface used for the services which allows to got closed.

type Runner

type Runner interface {
	Run() error
}

Runner is an interface used for the services which allows to runSub it.

type RunnerCloser

type RunnerCloser interface {
	Run() error
	Close(ctx context.Context) error
}

RunnerCloser is the interface used as one of the service ports.

type Service

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

Service is an implementation of the service that allows to start and close ports and other RunnerCloser.

func New

func New(name string) *Service

New creates a new service implementation that allows to add sub runners (ports).

func (*Service) Close

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

Close closes all connection within provided context.

func (*Service) Error

func (s *Service) Error() error

Error gets the service resultant error.

func (*Service) Run

func (s *Service) Run() error

Run establish connection for all dialers in the service.

func (*Service) Start

func (s *Service) Start(ctx context.Context) <-chan struct{}

Start locks the thread and serves the service runners. The resultant channel closes when the service is finished.

func (*Service) With

func (s *Service) With(sub RunnerCloser)

With sets the sub runner (port) that would be started and closed along with the service.

func (*Service) WithCloser

func (s *Service) WithCloser(closer Closer)

WithCloser adds the closer to the given service, which would be closed along with the service.

type Starter added in v0.0.4

type Starter interface {
	Start(ctx context.Context) <-chan struct{}
}

Starter is an interface used for the services that starts and blocks it's thread.

type Transactioner

type Transactioner interface {
	Commit() error
	Rollback() error
}

Transactioner is an interface used as a transaction base, responsible for committing and rolling back the transaction.

Directories

Path Synopsis
xgorm module
xmysql module
xpg module
xpq module

Jump to

Keyboard shortcuts

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