config

package
v0.0.0-...-d4bbf0a Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath = "config.yml"

	SQLDialectMysql    = "mysql"
	SQLDialectPostgres = "postgres"
	SQLDialectSqlite   = "sqlite3"
	SQLDialectMssql    = "mssql"

	KeyLatestTotalTime              = "latest_total_time"
	KeyLatestTotalUsers             = "latest_total_users"
	KeyLastImport                   = "last_import"            // import attempt
	KeyLastImportSuccess            = "last_successful_import" // last actual successful import
	KeyFirstHeartbeat               = "first_heartbeat"
	KeySubscriptionNotificationSent = "sub_reminder"
	KeyNewsbox                      = "newsbox"
	KeyInviteCode                   = "invite"

	SessionKeyDefault = "default"

	SimpleDateFormat     = "2006-01-02"
	SimpleDateTimeFormat = "2006-01-02 15:04:05"

	ErrUnauthorized        = "401 unauthorized"
	ErrBadRequest          = "400 bad request"
	ErrNotFound            = "404 not found"
	ErrInternalServerError = "500 internal server error"
)
View Source
const (
	WakatimeApiUrl               = "https://api.wakatime.com/api/v1"
	WakatimeApiUserUrl           = "/users/current"
	WakatimeApiAllTimeUrl        = "/users/current/all_time_since_today"
	WakatimeApiHeartbeatsUrl     = "/users/current/heartbeats"
	WakatimeApiHeartbeatsBulkUrl = "/users/current/heartbeats.bulk"
	WakatimeApiUserAgentsUrl     = "/users/current/user_agents"
	WakatimeApiMachineNamesUrl   = "/users/current/machine_names"
	WakatimeApiDataDumpUrl       = "/users/current/data_dumps"
)
View Source
const (
	TopicUser               = "user.*"
	TopicHeartbeat          = "heartbeat.*"
	TopicProjectLabel       = "project_label.*"
	EventUserUpdate         = "user.update"
	EventUserDelete         = "user.delete"
	EventHeartbeatCreate    = "heartbeat.create"
	EventProjectLabelCreate = "project_label.create"
	EventProjectLabelDelete = "project_label.delete"
	EventWakatimeFailure    = "wakatime.failure"
	FieldPayload            = "payload"
	FieldUser               = "user"
	FieldUserId             = "user.id"
)
View Source
const (
	QueueDefault      = "wakapi.default"
	QueueProcessing   = "wakapi.processing"
	QueueReports      = "wakapi.reports"
	QueueMails        = "wakapi.mail"
	QueueImports      = "wakapi.imports"
	QueueHousekeeping = "wakapi.housekeeping"
)
View Source
const (
	IndexTemplate         = "index.tpl.html"
	LoginTemplate         = "login.tpl.html"
	ImprintTemplate       = "imprint.tpl.html"
	SignupTemplate        = "signup.tpl.html"
	SetPasswordTemplate   = "set-password.tpl.html"
	ResetPasswordTemplate = "reset-password.tpl.html"
	SettingsTemplate      = "settings.tpl.html"
	SummaryTemplate       = "summary.tpl.html"
	LeaderboardTemplate   = "leaderboard.tpl.html"
	ProjectsTemplate      = "projects.tpl.html"
)
View Source
const (
	MailProviderSmtp = "smtp"
)

Variables

This section is empty.

Functions

func BeginningOfWakatime

func BeginningOfWakatime() time.Time

func ChooseFS

func ChooseFS(localDir string, embeddedFS fs.FS) fs.FS

ChooseFS returns a local (DirFS) file system when on 'dev' environment and the given go-embed file system otherwise

func CloseQueues

func CloseQueues()

func EventBus

func EventBus() *hub.Hub

func GetDefaultQueue

func GetDefaultQueue() *artifex.Dispatcher

func GetQueue

func GetQueue(name string) *artifex.Dispatcher

func GetSessionStore

func GetSessionStore() *sessions.CookieStore

func InitQueue

func InitQueue(name string, workers int) error

func IsDev

func IsDev(env string) bool

func Set

func Set(config *Config)

func StartJobs

func StartJobs()

Types

type ApplicationEvent

type ApplicationEvent struct {
	Type    string
	Payload interface{}
}

type Config

type Config struct {
	Env            string `default:"dev" env:"ENVIRONMENT"`
	Version        string `yaml:"-"`
	QuickStart     bool   `yaml:"quick_start" env:"WAKAPI_QUICK_START"`
	SkipMigrations bool   `yaml:"skip_migrations" env:"WAKAPI_SKIP_MIGRATIONS"`
	InstanceId     string `yaml:"-"` // only temporary, changes between runs
	EnablePprof    bool   `yaml:"enable_pprof" env:"WAKAPI_ENABLE_PPROF"`
	App            appConfig
	Security       securityConfig
	Db             dbConfig
	Server         serverConfig
	Subscriptions  subscriptionsConfig
	Sentry         sentryConfig
	Mail           mailConfig
}

func Empty

func Empty() *Config

func Get

func Get() *Config

func Load

func Load(configFlag string, version string) *Config

func (*Config) CreateCookie

func (c *Config) CreateCookie(name, value string) *http.Cookie

func (*Config) GetClearCookie

func (c *Config) GetClearCookie(name string) *http.Cookie

func (*Config) IsDev

func (c *Config) IsDev() bool

func (*Config) UseTLS

func (c *Config) UseTLS() bool

type JobQueueMetrics

type JobQueueMetrics struct {
	Queue        string
	EnqueuedJobs int
	FinishedJobs int
}

func GetQueueMetrics

func GetQueueMetrics() []*JobQueueMetrics

type SMTPMailConfig

type SMTPMailConfig struct {
	Host     string `env:"WAKAPI_MAIL_SMTP_HOST"`
	Port     uint   `env:"WAKAPI_MAIL_SMTP_PORT"`
	Username string `env:"WAKAPI_MAIL_SMTP_USER"`
	Password string `env:"WAKAPI_MAIL_SMTP_PASS"`
	TLS      bool   `env:"WAKAPI_MAIL_SMTP_TLS"`
}

func (*SMTPMailConfig) ConnStr

func (c *SMTPMailConfig) ConnStr() string

type SentryWrapperLogger

type SentryWrapperLogger struct {
	*logbuch.Logger
	// contains filtered or unexported fields
}

SentryWrapperLogger is a wrapper around a logbuch.Logger that forwards events to Sentry in addition and optionally allows to attach a request context

func Log

func Log() *SentryWrapperLogger

func (*SentryWrapperLogger) Debug

func (l *SentryWrapperLogger) Debug(msg string, params ...interface{})

func (*SentryWrapperLogger) Error

func (l *SentryWrapperLogger) Error(msg string, params ...interface{})

func (*SentryWrapperLogger) Fatal

func (l *SentryWrapperLogger) Fatal(msg string, params ...interface{})

func (*SentryWrapperLogger) Info

func (l *SentryWrapperLogger) Info(msg string, params ...interface{})

func (*SentryWrapperLogger) Request

func (*SentryWrapperLogger) Warn

func (l *SentryWrapperLogger) Warn(msg string, params ...interface{})

type WakapiDBOpts

type WakapiDBOpts struct {
	// contains filtered or unexported fields
}

func GetWakapiDBOpts

func GetWakapiDBOpts(dbConfig *dbConfig) *WakapiDBOpts

func (WakapiDBOpts) AfterInitialize

func (opts WakapiDBOpts) AfterInitialize(db *gorm.DB) error

func (WakapiDBOpts) Apply

func (opts WakapiDBOpts) Apply(config *gorm.Config) error

Jump to

Keyboard shortcuts

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