bootstrap

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MountSystemEndpoints

func MountSystemEndpoints(r ports.HTTPRouter, se SystemEndpoints)

MountSystemEndpoints registers health, docs, version, and metrics endpoints.

func NewDefaultRouter

func NewDefaultRouter(log ports.Logger) ports.HTTPRouter

NewDefaultRouter constructs a router with a sensible default middleware stack.

func NewMigrator

func NewMigrator(dsn, table string, lockKey int64, allowDown bool, log ports.Logger, dirs []string, embedded []fs.FS) (ports.Migrator, error)

NewMigrator builds a migrator with either directories or embedded FS sources.

func OpenAndPingDB

func OpenAndPingDB(ctx context.Context, dsn string, timeout time.Duration) (ports.DatabasePool, error)

OpenAndPingDB opens a DB pool and verifies connectivity with a short timeout.

func OpenPoolOrExit added in v1.0.2

func OpenPoolOrExit(ctx context.Context, dsn string, timeout time.Duration, log ports.Logger) ports.DatabasePool

OpenPoolOrExit opens a DB pool and terminates the process if it fails.

func RunDown

func RunDown(ctx context.Context, m ports.Migrator, dir string) error

RunDown runs migrations down with context and directory path.

func RunMigrationsOrExit added in v1.0.2

func RunMigrationsOrExit(ctx context.Context, cfg config.Config, log ports.Logger, embedded []fs.FS)

RunMigrationsOrExit runs startup migrations using config defaults or exits on failure.

func RunUp

func RunUp(ctx context.Context, m ports.Migrator, dir string) error

RunUp runs migrations up with context and directory path.

func StartServer

func StartServer(
	ctx context.Context,
	addr string,
	handler http.Handler,
	log ports.Logger,
) error

StartServer runs an HTTP server and performs graceful shutdown when the context is canceled.

func StartServerOrExit added in v1.0.2

func StartServerOrExit(
	ctx context.Context,
	addr string,
	handler http.Handler,
	log ports.Logger,
)

StartServerOrExit runs the HTTP server and exits the process when it fails.

func Status

func Status(ctx context.Context, m ports.Migrator, dir string) (string, error)

Status returns a text status of migrations.

func WithTimeout

func WithTimeout(parent context.Context, d time.Duration) (context.Context, context.CancelFunc)

WithTimeout derives a context with a default timeout for long-running migration ops.

Types

type SystemEndpoints added in v1.0.2

type SystemEndpoints struct {
	Health  *health.Handler
	Docs    *docs.Handler
	Version *version.Handler
	Pprof   http.Handler
	Metrics http.Handler
}

SystemEndpoints bundles handlers/config for mounting.

Jump to

Keyboard shortcuts

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