service

package
v1.0.0-beta.6 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2025 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseService

type BaseService struct {
	Logger zerolog.Logger
	// contains filtered or unexported fields
}

BaseService provides a basic implementation of the Service interface.

func NewBaseService

func NewBaseService(logger zerolog.Logger, name string, impl Service) *BaseService

NewBaseService creates a new BaseService. The provided implementation (impl) should be the "subclass" that implements Run.

func (*BaseService) Run

func (bs *BaseService) Run(ctx context.Context) error

Run implements the Service interface. It logs the start of the service, then defers to the implementation's Run method to do the actual work. If impl is nil or the same as bs, it uses the default implementation.

func (*BaseService) SetLogger

func (bs *BaseService) SetLogger(l zerolog.Logger)

SetLogger sets the logger.

func (*BaseService) String

func (bs *BaseService) String() string

String returns the service name.

type Service

type Service interface {
	// Run starts the service and blocks until it is shut down via context cancellation,
	// an error occurs, or all work is done.
	Run(ctx context.Context) error
}

Service exposes a Run method that blocks until the service ends or the context is canceled.

Jump to

Keyboard shortcuts

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