servicekit

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2025 License: MIT Imports: 11 Imported by: 0

README

servicekit

A comprehensive toolkit for building robust Go microservices. Provides essential utilities for logging, metrics, tracing, middleware, and more.

  • Structured logging
  • Request tracing
  • Connection pooling
  • Middleware stack

License

MIT License - feel free to use in your own projects.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendCtx

func AppendCtx(parent context.Context, attr slog.Attr) context.Context

AppendCtx adds an slog attribute to the provided context so that it will be included in any Record created with such context

func Connect

func Connect(config DBConfig) (*sql.DB, error)

Connect connects to the database and returns the connection

func Echo

func Echo() *echo.Echo

func InitAPI

func InitAPI()

func Migrate

func Migrate(config DBConfig, db *sql.DB) error

Migrate runs the database migrations

func SetLogger

func SetLogger(config LoggerConfig)

func Start

func Start(port string)

Types

type DBConfig

type DBConfig interface {
	DBConnString() string
	DBMigrationPath() string
}

type Handler

type Handler struct {
	slog.Handler
}

func (Handler) Handle

func (h Handler) Handle(ctx context.Context, r slog.Record) error

Handle adds contextual attributes to the Record before calling the underlying handler

type LoggerConfig

type LoggerConfig interface {
	LoggerLevel() string
	LoggerSource() bool
	LoggerFormat() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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