Documentation
¶
Index ¶
- type Application
- type Docs
- type MetricsConfig
- type Option
- func WithAllowUnknownFields(allow bool) Option
- func WithApplicationName(name string) Option
- func WithApplicationVersion(version string) Option
- func WithDocsUIPath(path string) Option
- func WithEnvGetter(getter func(string) string) Option
- func WithGenerateOpenAPIDocs(generate bool) Option
- func WithLogRequestBody(log bool) Option
- func WithLogger(logger *slog.Logger) Option
- func WithMetricsEnabled(enabled bool) Option
- func WithMetricsEndpoint(endpoint string) Option
- func WithMetricsExporter(exporter string) Option
- func WithMountDocsUIEndpoint(mount bool) Option
- func WithOpenAPIFilePath(path string) Option
- func WithServerHost(host string) Option
- func WithServerPort(port int) Option
- func WithTelemetryEnabled(enabled bool) Option
- func WithTelemetryEnvironment(environment string) Option
- func WithTelemetryServiceName(serviceName string) Option
- func WithTelemetryServiceVersion(serviceVersion string) Option
- func WithTraceIDMode(mode simbaModels.TraceIDMode) Option
- func WithTracingEndpoint(endpoint string) Option
- func WithTracingExporter(exporter string) Option
- type Request
- type Server
- type Simba
- type Telemetry
- type TracingConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Application ¶ added in v0.16.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 ¶
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
WithAllowUnknownFields sets whether to allow unknown fields
func WithApplicationName ¶ added in v0.16.0
WithApplicationName sets the application name
func WithApplicationVersion ¶ added in v0.16.0
WithApplicationVersion sets the application version
func WithDocsUIPath ¶ added in v0.16.0
WithDocsUIPath sets the docs UI path
func WithEnvGetter ¶ added in v0.16.0
WithEnvGetter is a test-only option to mock environment variable retrieval
func WithGenerateOpenAPIDocs ¶ added in v0.16.0
WithGenerateOpenAPIDocs sets whether to generate OpenAPI docs
func WithLogRequestBody ¶ added in v0.14.0
WithLogRequestBody sets whether to log request bodies
func WithLogger ¶ added in v0.14.0
WithLogger sets the logger
func WithMetricsEnabled ¶
WithMetricsEnabled sets whether metrics collection is enabled (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
func WithMetricsEndpoint ¶
WithMetricsEndpoint sets the metrics endpoint (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
func WithMetricsExporter ¶
WithMetricsExporter sets the metrics exporter type (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
func WithMountDocsUIEndpoint ¶ added in v0.16.0
WithMountDocsUIEndpoint sets whether to mount the docs endpoint
func WithOpenAPIFilePath ¶ added in v0.16.0
WithOpenAPIFilePath sets the OpenAPI JSON file path
func WithServerHost ¶ added in v0.14.0
WithServerHost sets the server host
func WithServerPort ¶ added in v0.14.0
WithServerPort sets the server port
func WithTelemetryEnabled ¶
WithTelemetryEnabled sets whether telemetry is enabled (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig) for modular, decoupled telemetry configuration.
func WithTelemetryEnvironment ¶
WithTelemetryEnvironment sets the telemetry environment (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
func WithTelemetryServiceName ¶
WithTelemetryServiceName sets the telemetry service name (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
func WithTelemetryServiceVersion ¶
WithTelemetryServiceVersion sets the telemetry service version (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
func WithTraceIDMode ¶ added in v0.27.2
func WithTraceIDMode(mode simbaModels.TraceIDMode) Option
WithTraceIDMode sets the trace ID mode
func WithTracingEndpoint ¶
WithTracingEndpoint sets the tracing endpoint (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig) for modular, decoupled telemetry configuration.
func WithTracingExporter ¶
WithTracingExporter sets the tracing exporter type (legacy Simba settings) DEPRECATED: Use WithTelemetry(*config.TelemetryConfig).
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 simbaModels.TraceIDMode `yaml:"trace-id-mode" env:"SIMBA_TRACE_ID_MODE" default:"AcceptFromHeader"`
}
Request holds the Simba for the Request processing
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"`
// Server settings
Server `yaml:"server"`
// Request settings
Request `yaml:"request"`
// Docs settings
Docs `yaml:"docs"`
// Telemetry settings
Telemetry `yaml:"telemetry"`
// Logger settings
Logger *slog.Logger `yaml:"-" env:"-"`
// contains filtered or unexported fields
}
Simba is a struct that holds the application settings
func LoadWithOptions ¶ added in v0.14.0
LoadWithOptions loads settings using the options pattern
type Telemetry ¶
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 ¶
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