Documentation
¶
Overview ¶
Package infrastructure provides infrastructure components module for the API server.
Index ¶
- Constants
- func Identity[T any](a T) T
- func New() fx.Option
- func NewEngine(controllers []helper.Controller, securityService *security.Service, ...) *gin.Engine
- func NewHTTPServer(lifecycle fx.Lifecycle, engine *gin.Engine, settings *config.ServerSettings, ...) *http.Server
- func NewMongoDBClient(settings *config.ServerSettings, traceProvider traceapi.TracerProvider, ...) (*mongo.Client, error)
- func NewMongoDatabase(client *mongo.Client, settings *config.ServerSettings, lifecycle fx.Lifecycle) (*mongo.Database, error)
- type MongoDBHealthIndicator
- type UnsupportedEventProtocolError
Constants ¶
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 )
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 ¶
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 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.
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 ¶
func (m *MongoDBHealthIndicator) Health(context.Context) healthcheck.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 ¶
func (m *MongoDBHealthIndicator) Readiness(ctx context.Context) healthcheck.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 ¶
func (e *UnsupportedEventProtocolError) Error() string
Error implements the error interface.