apiserver

package
v0.1.21 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: MIT Imports: 44 Imported by: 0

Documentation

Overview

Package apiserver provides app logic for the opampcommander apiserver.

Index

Constants

View Source
const (
	// DefaultServerStartTimeout = 30 * time.Second.
	DefaultServerStartTimeout = 30 * time.Second

	// DefaultServerStopTimeout is the default timeout for stopping the server.
	DefaultServerStopTimeout = 30 * 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 AsController

func AsController(f any) any

AsController is a helper function to annotate a function as a controller.

func AsRunner

func AsRunner(f any) any

AsRunner is a helper function to annotate a function as a runner.

func Identity

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 NewApplicationServiceModule

func NewApplicationServiceModule() fx.Option

NewApplicationServiceModule creates a new module for application services.

func NewConfigModule

func NewConfigModule(settings *config.ServerSettings) fx.Option

NewConfigModule creates a new module for configuration.

func NewDomainServiceModule

func NewDomainServiceModule() fx.Option

NewDomainServiceModule creates a new module for domain services.

func NewEngine

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

func NewEtcdClient(
	settings *config.ServerSettings,
	meterProvider metricapi.MeterProvider,
	traceProvider traceapi.TracerProvider,
	textMapPropagator otelpropagation.TextMapPropagator,
	lifecycle fx.Lifecycle,
) (*clientv3.Client, error)

NewEtcdClient creates a new etcd client with the given settings.

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 NewInPortModule

func NewInPortModule() fx.Option

NewInPortModule creates a new module for controllers.

func NewOutPortModule

func NewOutPortModule() fx.Option

NewOutPortModule creates a new module for output adapters.

func NoInheritContext

func NoInheritContext(_ context.Context) context.Context

NoInheritContext provides a non-inherit context. It's a marker function for code readers. It's from https://github.com/kkHAIKE/contextcheck?tab=readme-ov-file#need-break-ctx-inheritance

func PointerFunc added in v0.1.6

func PointerFunc[T any](a T) func() *T

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

func ValueFunc added in v0.1.6

func ValueFunc[T any](a T) func() T

ValueFunc is a generic function that returns a function that returns the input value. It is a helper function to generate a function that returns the input value.

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 []helper.Runner,
	logger *slog.Logger,
) *Executor

NewExecutor creates a new Executor instance.

type Server

type Server struct {
	*fx.App
	// contains filtered or unexported fields
}

Server is a struct that represents the server application. It embeds the fx.App struct from the Uber Fx framework.

func New

func New(settings config.ServerSettings) *Server

New creates a new instance of the Server struct.

func (*Server) Run

func (s *Server) Run(ctx context.Context) error

Run starts the server and blocks until the context is done.

Directories

Path Synopsis
Package config provides the configuration for the opampcommander application.
Package config provides the configuration for the opampcommander application.
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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