bootstrap

package
v3.5.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const ApplicationName = "ledger"

Variables

This section is empty.

Functions

func WithSwaggerEnvConfig

func WithSwaggerEnvConfig() fiber.Handler

WithSwaggerEnvConfig returns a middleware that applies Swagger configuration from environment variables exactly once (on first request), ensuring thread-safe initialization without data races on the global api.SwaggerInfo.

Types

type Config

type Config struct {
	EnvName  string `env:"ENV_NAME"`
	LogLevel string `env:"LOG_LEVEL"`
	Version  string `env:"VERSION"`

	// Server configuration - unified port for all APIs
	ServerAddress string `env:"SERVER_ADDRESS" envDefault:":3002"`

	// OpenTelemetry configuration
	OtelServiceName         string `env:"OTEL_RESOURCE_SERVICE_NAME"`
	OtelLibraryName         string `env:"OTEL_LIBRARY_NAME"`
	OtelServiceVersion      string `env:"OTEL_RESOURCE_SERVICE_VERSION"`
	OtelDeploymentEnv       string `env:"OTEL_RESOURCE_DEPLOYMENT_ENVIRONMENT"`
	OtelColExporterEndpoint string `env:"OTEL_EXPORTER_OTLP_ENDPOINT"`
	EnableTelemetry         bool   `env:"ENABLE_TELEMETRY"`

	// Auth configuration
	AuthEnabled bool   `env:"PLUGIN_AUTH_ENABLED"`
	AuthHost    string `env:"PLUGIN_AUTH_HOST"`
}

Config is the top level configuration struct for the unified ledger component.

type Options

type Options struct {
	// Logger allows callers to provide a pre-configured logger, avoiding multiple
	// initializations when composing components (e.g. unified ledger).
	Logger libLog.Logger
}

Options contains optional dependencies that can be injected by callers.

type RouteRegistrar

type RouteRegistrar func(app *fiber.App)

RouteRegistrar is a function that registers routes to an existing Fiber app. Each module (onboarding, transaction) implements this to register its routes.

type Server

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

Server represents the HTTP server for Ledger metadata index services.

func NewServer

func NewServer(cfg *Config, app *fiber.App, logger libLog.Logger, telemetry *libOpentelemetry.Telemetry) *Server

NewServer creates an instance of Server.

func (*Server) Run

func (s *Server) Run(l *libCommons.Launcher) error

Run runs the server.

func (*Server) ServerAddress

func (s *Server) ServerAddress() string

ServerAddress returns the server address.

type Service

type Service struct {
	OnboardingService  onboarding.OnboardingService
	TransactionService transaction.TransactionService
	UnifiedServer      *UnifiedServer
	Logger             libLog.Logger
	Telemetry          *libOpentelemetry.Telemetry
}

Service is the unified ledger service that composes onboarding and transaction.

func InitServers

func InitServers() (*Service, error)

InitServers initializes the unified ledger service that composes both onboarding and transaction modules in a single process. The transaction module is initialized first so its BalancePort (the UseCase) can be passed directly to onboarding for in-process calls.

func InitServersWithOptions

func InitServersWithOptions(opts *Options) (*Service, error)

InitServersWithOptions initializes the unified ledger service with optional dependency injection.

func (*Service) GetRunnables

func (s *Service) GetRunnables() []mbootstrap.RunnableConfig

GetRunnables returns all runnable components for the unified ledger. This can be used for custom launcher configuration if needed.

func (*Service) Run

func (s *Service) Run()

Run starts the unified ledger service with all APIs on a single port. The UnifiedServer consolidates all HTTP routes from onboarding and transaction. Non-HTTP runnables (RabbitMQ, Redis consumers, workers) are started separately.

type UnifiedServer

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

UnifiedServer consolidates all HTTP APIs (onboarding + transaction) in a single Fiber server. This enables the unified ledger mode where all routes are accessible on a single port.

func NewUnifiedServer

func NewUnifiedServer(
	serverAddress string,
	logger libLog.Logger,
	telemetry *libOpentelemetry.Telemetry,
	routeRegistrars ...RouteRegistrar,
) *UnifiedServer

NewUnifiedServer creates a server that exposes all APIs on a single port. It accepts route registration functions from each module to compose all routes in one Fiber app.

func (*UnifiedServer) Run

Run implements mbootstrap.Runnable interface. Starts the unified HTTP server with graceful shutdown support.

func (*UnifiedServer) ServerAddress

func (s *UnifiedServer) ServerAddress() string

ServerAddress returns the server address for logging/debugging purposes.

Jump to

Keyboard shortcuts

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