app

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 2, 2025 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package app provides app logic for the opampcommander apiserver.

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
)

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 Identity added in v0.0.13

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 NewEngine

func NewEngine(controllers []Controller) *gin.Engine

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

func NewEtcdClient

func NewEtcdClient(settings *ServerSettings) (*clientv3.Client, error)

NewEtcdClient creates a new etcd client with the given settings.

func NewHTTPServer

func NewHTTPServer(
	lifecycle fx.Lifecycle,
	engine *gin.Engine,
	settings *ServerSettings,
	logger *slog.Logger,
	connContext func(context.Context, net.Conn) context.Context,
) *http.Server

NewHTTPServer creates a new HTTP server instance.

func NewLogger

func NewLogger() *slog.Logger

NewLogger creates a new logger instance with default settings.

Types

type Controller

type Controller interface {
	RoutesInfo() gin.RoutesInfo
}

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

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 NewServer

func NewServer(settings ServerSettings) *Server

NewServer creates a new instance of the Server struct.

type ServerSettings

type ServerSettings struct {
	Addr      string
	EtcdHosts []string
}

ServerSettings is a struct that holds the server settings.

Jump to

Keyboard shortcuts

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