module

package
v2.303.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package module provides top-level Fx module composition for go-service.

This package defines opinionated, high-level module bundles that compose multiple lower-level feature modules into a single `di.Option` suitable for inclusion in an Fx/Dig application graph.

Bundles

The exported bundles are intended as defaults:

  • `Library`: shared, transport-agnostic wiring (building block for both servers and clients).

  • `Server`: a typical server composition (builds on Library and adds configuration decoding, server-side transports, telemetry, debugging, health checks, and common integrations).

  • `Client`: a typical client composition (builds on Library and adds configuration decoding, client-side transports/integrations, telemetry, and common client helpers).

Enablement and configuration

Most subsystems in go-service are enabled/disabled by configuration, typically using optional pointer sub-configs (nil meaning "disabled"). These bundles wire constructors and registrations; whether a subsystem is active depends on the configuration supplied to the graph.

Start with `Library`, `Server`, and `Client`.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Library provides a baseline Fx module intended for reuse by both servers and clients.
	//
	// It wires common, transport-agnostic dependencies that many subsystems build upon:
	//   - env.Module (service identity values like name/version/id, user agent, etc.)
	//   - compress.Module (compression registry and default codecs)
	//   - encoding.Module (encoding registry and default encoders)
	//   - crypto.Module (crypto primitives and helpers)
	//   - time.Module (time providers/utilities)
	//   - sync.Module (sync/pool helpers)
	//   - id.Module (ID generator implementations and selection)
	//
	// Library does not wire transports, servers, or request handling; it is intended to be a common
	// foundation that both the Server and Client bundles build upon.
	Library = di.Module(
		env.Module,
		compress.Module,
		encoding.Module,
		crypto.Module,
		time.Module,
		sync.Module,
		id.Module,
	)

	// Server provides the standard Fx module composition for a go-service server.
	//
	// It builds on Library and adds server-oriented wiring commonly needed by services:
	//   - debug.Module (debug server + diagnostic endpoints)
	//   - cache.Module (cache drivers, cache facade, and package-level cache registration)
	//   - config.Module (config decoding + validation + common sub-config projections)
	//   - feature.Module (OpenFeature client + optional provider registration)
	//   - sql.Module (SQL database wiring; currently PostgreSQL)
	//   - telemetry.Module (logging/tracing/metrics wiring)
	//   - limiter.Module (rate limiter key map wiring; transport modules typically construct limiters)
	//   - transport.Module (HTTP/gRPC transports and related client/server integrations)
	//   - health.Module (health server wiring)
	//
	// Many of these subsystems are optional and are enabled/disabled by configuration (often via nil pointer
	// sub-configs). This bundle wires constructors/registrations; runtime behavior depends on the config
	// supplied to the graph.
	Server = di.Module(
		Library,
		debug.Module,
		cache.Module,
		config.Module,
		feature.Module,
		sql.Module,
		telemetry.Module,
		limiter.Module,
		transport.Module,
		health.Module,
	)

	// Client provides the standard Fx module composition for a go-service client.
	//
	// It builds on Library and adds client-oriented wiring commonly needed by client processes
	// and batch jobs:
	//   - cache.Module (cache drivers/facade; optional by config)
	//   - config.Module (config decoding + validation + common sub-config projections)
	//   - feature.Module (OpenFeature client + optional provider registration)
	//   - hooks.Module (Standard Webhooks helpers; used by HTTP hook integrations)
	//   - sql.Module (SQL database wiring; currently PostgreSQL)
	//   - telemetry.Module (logging/tracing/metrics wiring)
	//   - limiter.Module (rate limiter key map wiring)
	//
	// Unlike Server, Client does not wire debug endpoints, transports, or a health server by default.
	// Those can be added explicitly by composing additional modules on top of Client if needed.
	Client = di.Module(
		Library,
		cache.Module,
		config.Module,
		feature.Module,
		hooks.Module,
		sql.Module,
		telemetry.Module,
		limiter.Module,
	)
)

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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