services

package
v0.13.16 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 53 Imported by: 0

Documentation

Overview

Package services provides the background operations that the application runs independent of any HTTP interfaces, e.g. data cleanups on timers

Index

Constants

View Source
const ReadyTag = `group:"ready"`

Variables

View Source
var ErrNotReady = errors.New("service not ready")

Functions

func BindGatewayHandlers

func BindGatewayHandlers(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

func HttpServer added in v0.13.0

func HttpServer(c *gin.Context) *http.Server

func InitializeGrpcServers

func InitializeGrpcServers(server *grpc.Server, client *ent.Client, readies []ReadyCheck) error

func Module added in v0.13.0

func Module() fx.Option

func WrapService added in v0.13.0

func WrapService(
	ctx context.Context,
	eg *errgroup.Group,
	service Service,
	l fx.Lifecycle,
	client *ent.Client,
) (serviceResults, error)

Types

type DeadLetterSettings

type DeadLetterSettings struct {
	actions.DeadLetterDeliveriesParams
	Interval time.Duration
	Fuzz     time.Duration
	Backoff  time.Duration
}

func (*DeadLetterSettings) ApplyDefaults

func (s *DeadLetterSettings) ApplyDefaults()

type HTTPService added in v0.13.0

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

func NewHTTPService added in v0.13.0

func NewHTTPService(r *gin.Engine, defaultPort, offset int) *HTTPService

NewHTTPService configures an HTTP server service using the given routing engine.

It will listen on `defaultPort` normally, unless overridden by the PORT environment variable.

func (*HTTPService) Cleanup added in v0.13.0

func (s *HTTPService) Cleanup(ctx context.Context) error

func (*HTTPService) Name added in v0.13.0

func (s *HTTPService) Name() string

func (*HTTPService) Start added in v0.13.0

func (s *HTTPService) Start(ctx context.Context, ready chan<- struct{}) error

type PruneCommonSettings

type PruneCommonSettings struct {
	actions.PruneCommonParams
	Interval time.Duration
	Fuzz     time.Duration
	Backoff  time.Duration
}

func (*PruneCommonSettings) ApplyDefaults

func (s *PruneCommonSettings) ApplyDefaults()

type ReadyCheck added in v0.13.0

type ReadyCheck interface {
	Ready() error
}

type Service added in v0.13.0

type Service interface {
	// Name describes the specific service for use in logging and status reports
	Name() string

	// Initialize should do any prep work for the service, but not actually start
	// it yet. The context should only be used for the duration of the initialization.
	Initialize(context.Context, *ent.Client) error

	// Start runs the service. It will be invoked on a goroutine, so it should
	// block and not return until the context is canceled, which is how the
	// service is requested to stop. The service must close the ready channel once
	// it is operational, so that any dependent services can know when they are OK
	// to proceed.
	Start(context.Context, chan<- struct{}) error

	// Cleanup should release any resources acquired during Initialize. If another
	// service fails during Initialize, Cleanup may be called without Start ever
	// being called. If Start is called, Cleanup will not be called until after it
	// returns.
	Cleanup(context.Context) error
}

Jump to

Keyboard shortcuts

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