xservice

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HealthCheckStatusStrings added in v0.0.28

func HealthCheckStatusStrings() []string

HealthCheckStatusStrings returns a slice of all String values of the enum

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 HealthCheckStatus added in v0.0.28

type HealthCheckStatus int

HealthCheckStatus gets the status of the health check.

const (
	HealthCheckStatusUnknown HealthCheckStatus = iota
	HealthCheckStatusServing
	HealthCheckStatusNotServing
	HealthCheckStatusServiceUnknown
)

Health check predefined statuses.

func HealthCheckStatusString added in v0.0.28

func HealthCheckStatusString(s string) (HealthCheckStatus, error)

HealthCheckStatusString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func HealthCheckStatusValues added in v0.0.28

func HealthCheckStatusValues() []HealthCheckStatus

HealthCheckStatusValues returns all values of the enum

func (HealthCheckStatus) IsAHealthCheckStatus added in v0.0.28

func (i HealthCheckStatus) IsAHealthCheckStatus() bool

IsAHealthCheckStatus returns "true" if the value is listed in the enum definition. "false" otherwise

func (HealthCheckStatus) MarshalText added in v0.0.28

func (i HealthCheckStatus) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for HealthCheckStatus

func (HealthCheckStatus) String added in v0.0.28

func (i HealthCheckStatus) String() string

func (*HealthCheckStatus) UnmarshalText added in v0.0.28

func (i *HealthCheckStatus) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for HealthCheckStatus

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) WithCleanupFunc added in v0.1.0

func (s *Service) WithCleanupFunc(cleanupFunc func())

WithCleanupFunc adds the cleanup function to the list of service closers.

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