1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-10-31 17:11:13 +01:00
ntfy/config/config.go

44 lines
1.1 KiB
Go
Raw Normal View History

// Package config provides the main configuration
package config
2021-10-24 04:49:50 +02:00
import (
"golang.org/x/time/rate"
"time"
)
// Defines default config settings
const (
DefaultListenHTTP = ":80"
DefaultKeepaliveInterval = 30 * time.Second
defaultManagerInterval = time.Minute
2021-10-24 04:49:50 +02:00
)
// Defines the max number of requests, here:
// 50 requests bucket, replenished at a rate of 1 per second
var (
defaultLimit = rate.Every(time.Second)
defaultLimitBurst = 50
)
// Config is the main config struct for the application. Use New to instantiate a default config struct.
type Config struct {
ListenHTTP string
Limit rate.Limit
LimitBurst int
2021-10-29 05:50:38 +02:00
FirebaseKeyFile string
KeepaliveInterval time.Duration
ManagerInterval time.Duration
}
// New instantiates a default new config
func New(listenHTTP string) *Config {
return &Config{
ListenHTTP: listenHTTP,
Limit: defaultLimit,
LimitBurst: defaultLimitBurst,
2021-10-29 05:50:38 +02:00
FirebaseKeyFile: "",
KeepaliveInterval: DefaultKeepaliveInterval,
ManagerInterval: defaultManagerInterval,
}
}