config

package
v0.0.0-...-dd4be11 Latest Latest
Warning

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

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

Documentation

Overview

Package config provides configuration management for Weblens server settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetMongoDBUri

func GetMongoDBUri() string

GetMongoDBUri returns the MongoDB connection URI from the current configuration.

func SetDoCache

func SetDoCache(doCache bool)

SetDoCache sets the caching flag in the configuration.

func SetLogLevel

func SetLogLevel(level zerolog.Level)

SetLogLevel sets the global log level in the configuration.

Types

type Provider

type Provider struct {
	// Router settings //
	Host         string
	Port         string
	ProxyAddress string

	// Database settings //
	MongoDBUri  string
	MongoDBName string

	// External resource identifiers //
	UIPath            string
	DataPath          string
	CachePath         string
	StaticContentPath string
	// HdirURI is the URI for the HDIR (high dimension image recognition) service, used for machine learning on images to allow semantic search and other features. This is expected to be a separate service, and the endpoint for that service should be provided here.
	HdirURI string

	// Logging settings
	LogLevel  zerolog.Level
	LogFormat string
	LogPath   string

	// Tower auto-initialization config options //
	// If set, the server will attempt to initialize itself with the specified role on first startup.
	InitRole string
	// The address of the Core tower to connect to when initializing as a Backup tower.
	CoreAddress string
	// The API token to use when connecting to the Core tower during initialization as a Backup tower.
	CoreToken string
	// Whether to generate an initial admin API token on first startup (Core server only). Useful for automated testing that uses the API, but should be used with extreme caution (see: never) in production environments.
	GenerateAdminAPIToken bool
	// DangerouslyInsecurePasswordHashing is a flag that, when set to true, will use a much faster bcrypt hashing cost for password hashing. This is intended for testing purposes only, as it significantly reduces the security of stored passwords. It should never be enabled in production environments.
	DangerouslyInsecurePasswordHashing bool

	// Misc config options //
	// BackupInterval specifies how often the server should perform backups of its data. This is only relevant for Backup towers
	BackupInterval time.Duration
	// WorkerCount specifies the number of worker goroutines to use for processing tasks. If set to 0, it will default to the number of CPU cores.
	WorkerCount int
	// DoCache indicates whether to use caching for database operations.
	DoCache bool
	// DoProfile Indicates whether to enable profiling endpoints.
	DoProfile bool
	// DoFileDiscovery Indicates whether to perform file discovery on startup. This is only set to true when running the main Weblens server,
	// and not during tests or other auxiliary binaries.
	DoFileDiscovery bool
	// DoAutomaticBackup indicates whether to start the automatic backup daemon on startup.
	// When false, manual backups via BackupOne still work. Defaults to true in production.
	DoAutomaticBackup bool
}

Provider provides configuration for Weblens options. All values provided are external to the application, and are expected to be set prior to initial startup using environment variables, etc. For management of runtime/mutable server settings, those will be stored in the database at /models/settings/...

func GetConfig

func GetConfig() Provider

GetConfig returns the current configuration for the Weblens server.

func (Provider) Merge

func (c Provider) Merge(o Provider) Provider

Merge merges another Provider into the current one, overriding any non-zero values.

Jump to

Keyboard shortcuts

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