settings

package
v0.30.0-dev.8 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Application added in v0.16.0

type Application struct {
	Name    string `yaml:"name" env:"APPLICATION_NAME" default:"Simba Application"`
	Version string `yaml:"version" env:"APPLICATION_VERSION" default:"0.1.0"`
}

type Docs added in v0.12.0

type Docs struct {

	// GenerateOpenAPIDocs will determine if the API documentation (YAML or JSON) will be generated
	GenerateOpenAPIDocs bool `yaml:"generate-docs" env:"SIMBA_DOCS_GENERATE" default:"true"`

	// MountDocsUIEndpoint will determine if the documentation UI will be mounted
	MountDocsUIEndpoint bool `yaml:"mount-docs-endpoint" env:"SIMBA_DOCS_MOUNT_DOCS_UI_ENDPOINT" default:"true"`

	// OpenAPIFilePath is the path to the OpenAPI YAML file
	OpenAPIFilePath string `yaml:"open-api-file-path" env:"SIMBA_DOCS_OPENAPI_FILE_PATH" default:"/openapi.json"`

	// DocsUIPath is the path to the API documentation
	DocsUIPath string `yaml:"docs-path" env:"SIMBA_DOCS_UI_PATH" default:"/docs"`

	// ServiceName is the name of the service
	ServiceName string
}

type MetricsConfig added in v0.30.0

type MetricsConfig struct {
	// Enabled determines if metrics collection is enabled (default: true when telemetry is enabled)
	Enabled bool `yaml:"enabled" env:"SIMBA_TELEMETRY_METRICS_ENABLED" default:"true"`

	// Exporter is the type of exporter to use (otlp, stdout)
	Exporter string `yaml:"exporter" env:"SIMBA_TELEMETRY_METRICS_EXPORTER" default:"otlp"`

	// Endpoint is the endpoint for the metrics exporter
	Endpoint string `yaml:"endpoint" env:"SIMBA_TELEMETRY_METRICS_ENDPOINT" default:"localhost:4317"`

	// Insecure determines if the connection should be insecure (default: true for local development)
	Insecure bool `yaml:"insecure" env:"SIMBA_TELEMETRY_METRICS_INSECURE" default:"true"`

	// ExportInterval is the interval in seconds for exporting metrics (default: 60 seconds)
	ExportInterval int `yaml:"export-interval" env:"SIMBA_TELEMETRY_METRICS_EXPORT_INTERVAL" default:"60"`
}

MetricsConfig holds the configuration for metrics collection.

type Option added in v0.14.0

type Option func(*Simba)

Option is a function that configures a Simba application settings struct.

func WithAllowUnknownFields added in v0.14.0

func WithAllowUnknownFields(allow bool) Option

WithAllowUnknownFields sets whether to allow unknown fields.

func WithApplicationName added in v0.16.0

func WithApplicationName(name string) Option

WithApplicationName sets the application name.

func WithApplicationVersion added in v0.16.0

func WithApplicationVersion(version string) Option

WithApplicationVersion sets the application version.

func WithDocsUIPath added in v0.16.0

func WithDocsUIPath(path string) Option

WithDocsUIPath sets the docs UI path.

func WithEnvGetter added in v0.16.0

func WithEnvGetter(getter func(string) string) Option

WithEnvGetter is a test-only option to mock environment variable retrieval.

func WithGenerateOpenAPIDocs added in v0.16.0

func WithGenerateOpenAPIDocs(generate bool) Option

WithGenerateOpenAPIDocs sets whether to generate OpenAPI docs.

func WithLogRequestBody added in v0.14.0

func WithLogRequestBody(log bool) Option

WithLogRequestBody sets whether to log request bodies.

func WithLogger added in v0.14.0

func WithLogger(logger *slog.Logger) Option

WithLogger sets the logger.

func WithMountDocsUIEndpoint added in v0.16.0

func WithMountDocsUIEndpoint(mount bool) Option

WithMountDocsUIEndpoint sets whether to mount the docs endpoint.

func WithOpenAPIFilePath added in v0.16.0

func WithOpenAPIFilePath(path string) Option

WithOpenAPIFilePath sets the OpenAPI JSON file path.

func WithServerHost added in v0.14.0

func WithServerHost(host string) Option

WithServerHost sets the server host.

func WithServerPort added in v0.14.0

func WithServerPort(port int) Option

WithServerPort sets the server port.

func WithTraceIDMode added in v0.27.2

func WithTraceIDMode(mode models.TraceIDMode) Option

WithTraceIDMode sets the trace ID mode.

type Request added in v0.8.0

type Request struct {

	// AllowUnknownFields will set the behavior for unknown fields in the Request body,
	// resulting in a 400 Bad Request response if a field is present that cannot be
	// mapped to the model struct.
	AllowUnknownFields bool `yaml:"allow-unknown-fields" env:"SIMBA_REQUEST_ALLOW_UNKNOWN_FIELDS" default:"true"`

	// LogRequestBody will determine if the Request body will be logged
	// If set to "disabled", the Request body will not be logged, which is also the default
	LogRequestBody bool `yaml:"log-request-body" env:"SIMBA_REQUEST_LOG_REQUEST_BODY" default:"false"`

	// TraceIDMode determines how the Trace ID will be handled
	TraceIDMode models.TraceIDMode `yaml:"trace-id-mode" env:"SIMBA_TRACE_ID_MODE" default:"AcceptFromHeader"`
}

Request holds the Simba for the Request processing.

func DefaultRequestSettings added in v0.30.0

func DefaultRequestSettings() Request

type Server added in v0.8.0

type Server struct {

	// Host is the host the server will listen on
	Host string `yaml:"host" env:"SIMBA_SERVER_HOST" default:"0.0.0.0"`

	// Addr is the address the server will listen on
	Port int `yaml:"port" env:"SIMBA_SERVER_PORT" default:"9999"`
}

Server holds the Simba for the application server.

type Simba added in v0.14.0

type Simba struct {

	// Application settings
	Application `yaml:"application" exhaustruct:"optional"`

	// Server settings
	Server `yaml:"server"`

	// Request settings
	Request `yaml:"request"`

	// Docs settings
	Docs `yaml:"docs"`

	// Telemetry settings
	Telemetry `yaml:"telemetry" exhaustruct:"optional"`

	// Logger settings
	Logger *slog.Logger `yaml:"-" env:"-"`
	// contains filtered or unexported fields
}

Simba is a struct that holds the application settings.

func Load

func Load(opts ...Option) (*Simba, error)

Load loads the application settings.

func LoadWithOptions added in v0.14.0

func LoadWithOptions(opts ...Option) (*Simba, error)

LoadWithOptions loads settings using the options pattern.

type Telemetry added in v0.30.0

type Telemetry struct {
	// Enabled determines if telemetry is enabled (opt-in, default: false)
	Enabled bool `yaml:"enabled" env:"SIMBA_TELEMETRY_ENABLED" default:"false"`

	// Tracing configuration
	Tracing TracingConfig `yaml:"tracing"`

	// Metrics configuration
	Metrics MetricsConfig `yaml:"metrics"`

	// ServiceName is the name of the service for telemetry (defaults to Application.Name)
	ServiceName string `yaml:"service-name" env:"SIMBA_TELEMETRY_SERVICE_NAME"`

	// ServiceVersion is the version of the service for telemetry (defaults to Application.Version)
	ServiceVersion string `yaml:"service-version" env:"SIMBA_TELEMETRY_SERVICE_VERSION"`

	// Environment is the deployment environment (development, staging, production, etc.)
	Environment string `yaml:"environment" env:"SIMBA_TELEMETRY_ENVIRONMENT" default:"development"`
}

Telemetry holds the settings for OpenTelemetry integration.

type TracingConfig added in v0.30.0

type TracingConfig struct {
	// Enabled determines if tracing is enabled (default: true when telemetry is enabled)
	Enabled bool `yaml:"enabled" env:"SIMBA_TELEMETRY_TRACING_ENABLED" default:"true"`

	// Exporter is the type of exporter to use (otlp, stdout)
	Exporter string `yaml:"exporter" env:"SIMBA_TELEMETRY_TRACING_EXPORTER" default:"otlp"`

	// Endpoint is the endpoint for the trace exporter
	Endpoint string `yaml:"endpoint" env:"SIMBA_TELEMETRY_TRACING_ENDPOINT" default:"localhost:4317"`

	// Insecure determines if the connection should be insecure (default: true for local development)
	Insecure bool `yaml:"insecure" env:"SIMBA_TELEMETRY_TRACING_INSECURE" default:"true"`

	// SamplingRate is the sampling rate for traces (0.0 to 1.0, default: 1.0 = 100%)
	SamplingRate float64 `yaml:"sampling-rate" env:"SIMBA_TELEMETRY_TRACING_SAMPLING_RATE" default:"1.0"`
}

TracingConfig holds the configuration for distributed tracing.

Jump to

Keyboard shortcuts

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