infrastructure

package
v0.1.37 Latest Latest
Warning

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

Go to latest
Published: May 2, 2026 License: MIT Imports: 55 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

	// DefaultKafkaTimeout is the default timeout for Kafka operations.
	DefaultKafkaTimeout = 30 * time.Second

	// DefaultKafkaRetryMax is the default maximum number of retries for Kafka operations.
	DefaultKafkaRetryMax = 10

	// DefaultKafkaRetryBackoff is the default backoff duration between Kafka retries.
	DefaultKafkaRetryBackoff = 2 * 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 Identity added in v0.1.24

func Identity[T any](a T) T

Identity is a generic function that returns the input value. It is a helper function to generate a function that returns the input value. It is used to provide a function as a interface.

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,
	rbacUsecase userport.RBACUsecase,
	userUsecase userport.UserUsecase,
	settings *config.ServerSettings,
	observabilityService *observability.Service,
	logger *slog.Logger,
) *gin.Engine

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

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,

	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