service

package
v0.0.0-...-757fb74 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrOverThreshold = errors.New("value is over threshold")

Functions

This section is empty.

Types

type Handler

type Handler struct {
	Threshold int
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(threshold int) Handler

func (Handler) Handle

func (h Handler) Handle(_ context.Context, value int) error

type HandlerWithLogs

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

func WithLogs

func WithLogs(s Service, logger Logger) HandlerWithLogs

func (HandlerWithLogs) Handle

func (h HandlerWithLogs) Handle(ctx context.Context, value int) (err error)

type HandlerWithMetrics

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

func WithMetrics

func WithMetrics(s Service, metrics Metrics) HandlerWithMetrics

func (HandlerWithMetrics) Handle

func (h HandlerWithMetrics) Handle(ctx context.Context, value int) (err error)

type HandlerWithTrace

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

func WithTrace

func WithTrace(s Service, tracer trace.Tracer) HandlerWithTrace

func (HandlerWithTrace) Handle

func (h HandlerWithTrace) Handle(ctx context.Context, value int) (err error)

type Logger

type Logger interface {
	DebugContext(ctx context.Context, msg string, args ...any)
	InfoContext(ctx context.Context, msg string, args ...any)
	WarnContext(ctx context.Context, msg string, args ...any)
	ErrorContext(ctx context.Context, msg string, args ...any)
}

type Metrics

type Metrics interface {
	IncRequestsReceived()
	IncRequestsFailed()
	ObserveHandlingLatency(ctx context.Context, dur time.Duration)
}

type Service

type Service interface {
	Handle(ctx context.Context, value int) error
}

Service describes the behavior that a general service (as a handler) would have

It is declared on the same file as the implementation simply to make it easer for the observability wrappers

Jump to

Keyboard shortcuts

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