Documentation
¶
Overview ¶
Package apiserver provides app logic for the opampcommander apiserver.
Index ¶
- Constants
- func AsController(f any) any
- func AsRunner(f any) any
- func Identity[T any](a T) T
- func NewApplicationServiceModule() fx.Option
- func NewConfigModule(settings *config.ServerSettings) fx.Option
- func NewDomainServiceModule() fx.Option
- func NewEngine(controllers []Controller, securityService *security.Service, ...) *gin.Engine
- func NewEtcdClient(settings *config.ServerSettings, meterProvider metricapi.MeterProvider, ...) (*clientv3.Client, error)
- func NewHTTPServer(lifecycle fx.Lifecycle, engine *gin.Engine, settings *config.ServerSettings, ...) *http.Server
- func NewInPortModule() fx.Option
- func NewOutPortModule() fx.Option
- func NoInheritContext(_ context.Context) context.Context
- func PointerFunc[T any](a T) func() *T
- func ValueFunc[T any](a T) func() T
- type Controller
- type Executor
- type Server
Constants ¶
const ( // DefaultServerStartTimeout = 30 * time.Second. DefaultServerStartTimeout = 30 * time.Second // DefaultServerStopTimeout is the default timeout for stopping the server. DefaultServerStopTimeout = 30 * 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 AsController ¶
AsController is a helper function to annotate a function as a controller.
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 ¶
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 ¶
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 ¶
NewInPortModule creates a new module for controllers.
func NewOutPortModule ¶
NewOutPortModule creates a new module for output adapters.
func NoInheritContext ¶
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.
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.