primary

package
v0.1.41 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Package primary provides inbound (driving) adapters for the API server: the HTTP server with its controllers and the scheduler executor that runs background runners.

Index

Constants

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

	// DefaultHTTPIdleTimeout is how long a keep-alive connection stays open
	// between requests. It must be longer than the OpAMP HTTP client's poll
	// interval (default 30s) — otherwise the server can close an idle
	// keep-alive connection exactly as the client tries to reuse it, which
	// surfaces as `Post ... : EOF` on the agent. When unset, net/http falls
	// back to ReadTimeout, which produces that exact race.
	DefaultHTTPIdleTimeout = 120 * time.Second
)

Variables

View Source
var ErrServerIDRequired = errors.New("server ID is required for kafka messaging consumer group")

ErrServerIDRequired is returned when Kafka messaging is configured without a server ID.

Functions

func AsController

func AsController(f any) any

AsController annotates a controller constructor so its result is provided as the Controller interface into the "controllers" group consumed by NewEngine.

func New

func New() fx.Option

New creates the primary adapter module.

func NewEngine

func NewEngine(
	controllers []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 NewHTTP

func NewHTTP() fx.Option

NewHTTP provides the HTTP server, the Gin engine, and every controller registered into it.

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.

Types

type Controller

type Controller interface {
	RoutesInfo() gin.RoutesInfo
}

Controller is an interface that defines the methods for handling HTTP requests.

type Executor

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

Executor is a struct that schedules and manages the execution of runners. It uses a WaitGroup to wait for all runners to finish before stopping.

func NewExecutor

func NewExecutor(
	lifecycle fx.Lifecycle,
	runners []scheduler.Scheduler,
	logger *slog.Logger,
) *Executor

NewExecutor creates a new Executor instance.

Jump to

Keyboard shortcuts

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