infrastructure

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 41 Imported by: 0

Documentation

Overview

Package infrastructure provides infrastructure components module for the API server.

Index

Constants

View Source
const (
	// DefaultSenderCloseTimeout is the default timeout for closing the Kafka sender.
	DefaultSenderCloseTimeout = 10 * time.Second

	// DefaultReceiverCloseTimeout is the default timeout for closing the Kafka receiver.
	DefaultReceiverCloseTimeout = 10 * time.Second
)
View Source
const (
	// DefaultHTTPReadTimeout is the default timeout for reading HTTP requests.
	// It should be set to a reasonable value to avoid security issues.
	DefaultHTTPReadTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func New

func New() fx.Option

New creates a new module for infrastructure components. This includes HTTP server, database, messaging, and WebSocket registry.

func NewEngine

func NewEngine(
	controllers []helper.Controller,
	securityService *security.Service,
	observabilityService *observability.Service,
	logger *slog.Logger,
) *gin.Engine

NewEngine creates a new Gin engine and registers the provided controllers' routes.

func NewEventhubAdapter

func NewEventhubAdapter(
	settings *config.EventSettings,
	logger *slog.Logger,
	lifecycle fx.Lifecycle,
) (port.EventHubPort, error)

NewEventhubAdapter creates the appropriate event sender adapter based on configuration. Returns inmemory adapter for standalone mode, or Kafka adapter for distributed mode.

func NewHTTPServer

func NewHTTPServer(
	lifecycle fx.Lifecycle,
	engine *gin.Engine,
	settings *config.ServerSettings,
	logger *slog.Logger,
	connContext func(context.Context, net.Conn) context.Context,
) *http.Server

NewHTTPServer creates a new HTTP server instance.

func NewMongoDBClient

func NewMongoDBClient(
	settings *config.ServerSettings,
	meterProvider metricapi.MeterProvider,
	traceProvider traceapi.TracerProvider,
	lifecycle fx.Lifecycle,
) (*mongo.Client, error)

NewMongoDBClient creates a new MongoDB client with OpenTelemetry instrumentation.

func NewMongoDatabase

func NewMongoDatabase(
	client *mongo.Client,
	settings *config.ServerSettings,
	lifecycle fx.Lifecycle,
) (*mongo.Database, error)

NewMongoDatabase creates a new MongoDB database from the client.

Types

type MongoDBHealthIndicator

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

MongoDBHealthIndicator is a health indicator for MongoDB.

func NewMongoDBHealthIndicator

func NewMongoDBHealthIndicator(client *mongo.Client) *MongoDBHealthIndicator

NewMongoDBHealthIndicator creates a new MongoDBHealthIndicator.

func (*MongoDBHealthIndicator) Health

Health returns the health status of the MongoDB connection.

func (*MongoDBHealthIndicator) Name

func (m *MongoDBHealthIndicator) Name() string

Name returns the name of the health indicator.

func (*MongoDBHealthIndicator) Readiness

Readiness returns the readiness status of the MongoDB connection.

type UnsupportedEventProtocolError

type UnsupportedEventProtocolError struct {
	ProtocolType string
}

UnsupportedEventProtocolError is returned when an unsupported event protocol type is specified.

func (*UnsupportedEventProtocolError) Error

Error implements the error interface.

Jump to

Keyboard shortcuts

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