service

package module
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: BSD-2-Clause Imports: 12 Imported by: 30

README

Service

A Go service framework library that provides a standardized way to build HTTP services with Sentry integration, structured logging, and graceful shutdown capabilities.

Features

  • Standardized Service Architecture: Interface → Constructor → Struct → Method pattern
  • Sentry Integration: Built-in error reporting and exception handling
  • Graceful Shutdown: Context-aware service lifecycle management
  • HTTP Server Utilities: Health checks, metrics, and routing with Gorilla Mux
  • Concurrent Execution: Run multiple service components with proper error handling
  • Testing Support: Counterfeiter mock generation and Ginkgo/Gomega test framework

Quick Start

Example for creating a service can be found in example/main.go

func main() {
    app := &application{}
    os.Exit(service.Main(context.Background(), app, &app.SentryDSN, &app.SentryProxy))
}

See the example directory for a complete implementation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterErrors

func FilterErrors(fn run.Func, filteredErrors ...error) run.Func

FilterErrors for the given func

func Main

func Main(
	ctx context.Context,
	app Application,
	sentryDSN *string,
	sentryProxy *string,
	fns ...OptionsFn,
) int

func MainCmd

func MainCmd(
	ctx context.Context,
	app run.Runnable,
) int

MainCmd has no sentry and don't print anything

func Run

func Run(ctx context.Context, funcs ...run.Func) error

Types

type Application

type Application interface {
	Run(ctx context.Context, sentryClient libsentry.Client) error
}

type Options

type Options struct {
	ExcludeErrors sentry.ExcludeErrors
}

func NewOptions

func NewOptions(fns ...OptionsFn) Options

type OptionsFn

type OptionsFn func(option *Options)

type Service

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

func NewService

func NewService(
	sentryClient libsentry.Client,
	app Application,
) Service

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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