2024-08-11 17:08:27 +07:00
package config
import (
"path"
"github.com/adrg/xdg"
)
var Version string = "unknown"
2024-08-11 19:50:43 +07:00
type Entry struct {
Key string
Value any
Desc string
Hidden bool
}
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
type Entries [ ] Entry
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
func ( e Entries ) ToMap ( ) map [ string ] any {
m := make ( map [ string ] any , len ( e ) )
for _ , entry := range e {
m [ entry . Key ] = entry . Value
}
return m
}
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
var DefaultConfig = Entries {
2024-08-11 21:45:11 +07:00
{ "log.enable" , true , ` Enable console logging. If TTY is detected, a pretty logging will be used. Otherwise uses JSON format. ` , false } ,
{ "log.file.path" , path . Join ( xdg . CacheHome , "bluemage" , "bluemage.log" ) , "Log file path" , false } ,
2024-08-11 19:50:43 +07:00
{ "log.file.enable" , true , "Enable file logging" , false } ,
{ "log.level" , "info" , ` Log level. Possible values: "debug", "info", "warn", "error" ` , false } ,
{ "log.output" , "stderr" , "Log output. Possible values: \"stdout\", \"stderr\"" , false } ,
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
{ "db.driver" , "sqlite3" , "Database driver" , false } ,
{ "db.path" , path . Join ( xdg . Home , ".local" , "share" , "bluemage" , "data.db" ) , "Database path" , false } ,
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
{ "pubsub.db.path" , path . Join ( xdg . Home , ".local" , "share" , "bluemage" , "pubsub.db" ) , "PubSub database path" , false } ,
{ "pubsub.db.timeout" , "5s" , "PubSub database timeout" , false } ,
{ "pubsub.ack.deadline" , "30m" , "PubSub ack deadline" , false } ,
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
{ "download.concurrency" , 5 , "Number of concurrent image downloads" , false } ,
{ "download.directory" , path . Join ( xdg . UserDirs . Pictures , "bluemage" ) , "Download directory" , false } ,
{ "download.timeout.headers" , "10s" , "How long to wait for Reddit to response with data after opening connection. To prevent download connection getting clogged up for too long" , false } ,
{ "download.timeout.idle" , "5s" , "Download idle timeout. Whenever a download speed is under idlespeed for this duration, the download is cancelled. To prevent slow download speed from clogging up the queue" , false } ,
{ "download.timeout.idlespeed" , "10KB" , "Threshold for the download speed to be considered 'idle'" , false } ,
{ "download.useragent" , "bluemage/v1" , "Download user agent. Must not be empty. Avoid common user agent values like 'curl'" , false } ,
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
{ "http.port" , "8080" , "HTTP server port" , false } ,
{ "http.host" , "0.0.0.0" , "HTTP server host" , false } ,
{ "http.shutdown_timeout" , "5s" , "Timeout to wait closing i/o connections until the server force closes everything" , false } ,
2024-08-11 17:08:27 +07:00
2024-08-11 19:50:43 +07:00
{ "telemetry.openobserve.enable" , false , "Wether to enable telemetry support to OpenObserve server. Setting this to false, disables all other 'telemetry.openobserve' options (default false)" , false } ,
{ "telemetry.openobserve.log.enable" , true , "Wether to enable logging telemetry to OpenObserve server" , false } ,
{ "telemetry.openobserve.log.level" , "info" , "Log level for telemetry logging" , false } ,
{ "telemetry.openobserve.log.source" , true , "Wether to include source code in the log" , false } ,
{ "telemetry.openobserve.log.endpoint" , "http://localhost:5080/api/default/default/_json" , "OpenObserve log endpoint" , false } ,
{ "telemetry.openobserve.log.concurrency" , 4 , "Number of allowed concurrent connections to send logs to the server" , false } ,
{ "telemetry.openobserve.log.buffer.size" , 2 * 1024 , "Buffer size (in bytes) to wait before being sent to the server" , false } ,
{ "telemetry.openobserve.log.buffer.timeout" , "2s" , "Timeout to send logs if the buffer is not empty but not yet filled" , false } ,
{ "telemetry.openobserve.log.username" , "root@example.com" , "OpenObserve logging endpoint username" , false } ,
{ "telemetry.openobserve.log.password" , "Complexpass#123" , "OpenObserve logging endpoint password" , false } ,
2024-08-12 20:20:12 +07:00
{ "telemetry.openobserve.traces.enable" , true , "Wether to enable sending tracing to OpenObserve server" , false } ,
{ "telemetry.openobserve.traces.url" , "http://localhost:5080/api/default/v1/traces" , "Endpoint url to send traces to" , false } ,
{ "telemetry.openobserve.traces.auth" , "Basic AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" , "Authorization token for the Endpoint URL" , false } ,
{ "telemetry.openobserve.metrics.enable" , true , "Wether to enable sending metrics to OpenObserve server" , false } ,
{ "telemetry.openobserve.metrics.url" , "http://localhost:5080/api/default/v1/metrics" , "Endpoint url to send traces to" , false } ,
{ "telemetry.openobserve.metrics.auth" , "Basic AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" , "Authorization token for the Endpoint URL" , false } ,
2024-08-12 22:00:21 +07:00
{ "telemetry.openobserve.metrics.interval" , "5s" , "Interval of metrics being sent" , false } ,
2024-08-12 20:20:12 +07:00
{ "telemetry.traces.ratio" , float64 ( 1 ) , "Sampling ratio between 0 to 1 on how many traces are sent to the server. Value of 1 will send everything" , false } ,
2024-08-11 17:08:27 +07:00
2024-08-11 21:45:11 +07:00
{ "telemetry.service.name" , "bluemage" , "Name of the service to send to telemetry server" , true } ,
2024-08-11 19:50:43 +07:00
{ "runtime.version" , Version , "current server version" , true } ,
{ "runtime.environment" , "development" , "runtime environment" , true } ,
{ "flags.containerized" , false , "Indicates the application is running in a container" , true } ,
2024-08-11 17:08:27 +07:00
}