Documentation
¶
Index ¶
- Constants
- func BeginningOfWakatime() time.Time
- func ChooseFS(localDir string, embeddedFS fs.FS) fs.FS
- func CloseQueues()
- func EventBus() *hub.Hub
- func GetDefaultQueue() *artifex.Dispatcher
- func GetQueue(name string) *artifex.Dispatcher
- func GetSessionStore() *sessions.CookieStore
- func InitLogger(isDev bool)
- func InitQueue(name string, workers int) error
- func IsDev(env string) bool
- func NewSessionStore() *sessions.CookieStore
- func RegisterOidcProvider(providerCfg *oidcProviderConfig)
- func Set(config *Config)
- func StartJobs()
- type ApplicationEvent
- type Config
- type IdTokenPayload
- type JobQueueMetrics
- type OidcProvider
- type SMTPMailConfig
- type SentryLogger
- type SharedData
- type SharedDataKey
- type WakapiDBOpts
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 KeySubscriptionNotificationSent = "sub_reminder" KeyNewsbox = "newsbox" KeyInviteCode = "invite" CookieKeySession = "wakapi_session" CookieKeyAuth = "wakapi_auth" SessionValueOidcState = "oidc_state" SessionValueOidcIdTokenPayload = "oidc_id_token" SimpleDateFormat = "2006-01-02" SimpleDateTimeFormat = "2006-01-02 15:04:05" 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" EventLanguageMappingsChanged = "language_mappings.changed" EventApiKeyCreate = "api_key.create" EventApiKeyDelete = "api_key.delete" FieldPayload = "payload" FieldUser = "user" FieldUserId = "user.id" )
View Source
const ( QueueDefault = "wakapi.default" QueueProcessing = "wakapi.processing" QueueProcessing2 = "wakapi.processing_2" QueueReports = "wakapi.reports" QueueMails = "wakapi.mail" QueueImports = "wakapi.imports" QueueHousekeeping = "wakapi.housekeeping" )
View Source
const ( MiddlewareKeyPrincipal = SharedDataKey("principal") MiddlewareKeyPrincipalId = SharedDataKey("principal_identity") )
View Source
const ( IndexTemplate = "index.tpl.html" LoginTemplate = "login.tpl.html" ImprintTemplate = "imprint.tpl.html" SetupTemplate = "setup.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 ChooseFS ¶
ChooseFS returns a local (DirFS) file system when on 'dev' environment and the given go-embed file system otherwise
func CloseQueues ¶
func CloseQueues()
func GetDefaultQueue ¶
func GetDefaultQueue() *artifex.Dispatcher
func GetQueue ¶
func GetQueue(name string) *artifex.Dispatcher
func GetSessionStore ¶
func GetSessionStore() *sessions.CookieStore
func InitLogger ¶
func InitLogger(isDev bool)
func NewSessionStore ¶
func NewSessionStore() *sessions.CookieStore
func RegisterOidcProvider ¶
func RegisterOidcProvider(providerCfg *oidcProviderConfig)
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 WithOidcProvider ¶
func (*Config) AppStartTimestamp ¶
type IdTokenPayload ¶
type IdTokenPayload struct {
Issuer string `json:"iss"`
Subject string `json:"sub"`
Expiry int64 `json:"exp"`
Name string `json:"name"`
Nickname string `json:"nickname"`
PreferredUsername string `json:"preferred_username"`
Email string `json:"email"`
EmailVerified bool `json:"email_verified"`
ProviderName string `json:"provider_name"` // custom field, not part of actual id token response
}
func (*IdTokenPayload) Exp ¶
func (token *IdTokenPayload) Exp() time.Time
func (*IdTokenPayload) IsValid ¶
func (token *IdTokenPayload) IsValid() bool
func (*IdTokenPayload) Username ¶
func (token *IdTokenPayload) Username() string
type JobQueueMetrics ¶
func GetQueueMetrics ¶
func GetQueueMetrics() []*JobQueueMetrics
type OidcProvider ¶
type OidcProvider struct {
Name string
DisplayName string
OAuth2 *oauth2.Config
Verifier *oidc.IDTokenVerifier
}
func GetOidcProvider ¶
func GetOidcProvider(name string) (*OidcProvider, error)
func MustGetOidcProvider ¶
func MustGetOidcProvider(name string) *OidcProvider
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"`
SkipVerify bool `env:"WAKAPI_MAIL_SMTP_SKIP_VERIFY"`
}
func (*SMTPMailConfig) ConnStr ¶
func (c *SMTPMailConfig) ConnStr() string
type SentryLogger ¶
SentryLogger wraps slog.Logger and provides a Fatal method
func Log ¶
func Log() *SentryLogger
func New ¶
func New() *SentryLogger
func (*SentryLogger) Fatal ¶
func (l *SentryLogger) Fatal(msg string, args ...any)
func (*SentryLogger) Request ¶
func (l *SentryLogger) Request(r *http.Request) *SentryLogger
type SharedData ¶
type SharedData struct {
*lib.ConcurrentMap[SharedDataKey, interface{}]
}
func NewSharedData ¶
func NewSharedData() *SharedData
type SharedDataKey ¶
type SharedDataKey string
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
Click to show internal directories.
Click to hide internal directories.