Documentation
¶
Overview ¶
Package mnd provides reusable constants for the Notifiarr application packages.
Index ¶
- Constants
- Variables
- func DurationAge(when time.Time) string
- func FormatBytes(size any) string
- func GetID(ctx context.Context) string
- func GetKeys(mapName *expvar.Map) map[string]any
- func GetMap(name string) *expvar.Map
- func GetSplitKeys(mapName *expvar.Map) map[string]map[string]any
- func PrintVersionInfo(program string) string
- func ReqID() string
- func SetID(ctx context.Context) context.Context
- func TodaysEmoji() string
- func WithID(ctx context.Context, id string) context.Context
- type AllData
- type Enabled
- type InstancePinger
- type Logger
Constants ¶
const ( Mode0755 = 0o755 Mode0750 = 0o750 Mode0600 = 0o600 Mode0644 = 0o644 Kilobyte = 1024 Megabyte = Kilobyte * Kilobyte KB100 = Kilobyte * 100 OneDay = 24 * time.Hour Base10 = 10 Base8 = 8 Bits64 = 64 Bits32 = 32 True = "true" False = "false" Windows = "windows" Disabled = "disabled" Success = "success" Status = "Status" BytesReceived = " Bytes Received" BytesSent = " Bytes Sent" Matched = " Matched" Requests = " Requests" Deleted = "deleted:" HelpLink = "Notifiarr Discord: https://notifiarr.com/discord" UserRepo = "Notifiarr/notifiarr" BugIssue = "This is a bug please report it on github: https://github.com/" + UserRepo + "/issues/new" Synology = "/etc/synoinfo.conf" // Synology is the path to the syno config file. IsLinux = runtime.GOOS == "linux" IsWindows = runtime.GOOS == Windows IsFreeBSD = runtime.GOOS == "freebsd" IsDarwin = runtime.GOOS == "darwin" ContentTypeJSON = "application/json; charset=utf-8" FakeAPIKey = "api-key-from-notifiarr.com" )
Application Constants.
const ( Title = "Notifiarr" DefaultName = "notifiarr" DefaultLogFileMb = 5 DefaultLogFiles = 10 DefaultEnvPrefix = "DN" DefaultTimeout = time.Minute DefaultBindAddr = "0.0.0.0:5454" )
Application Defaults.
Variables ¶
var ( LogFiles = GetMap("Log File Information").Init() APIHits = GetMap("Incoming API Requests").Init() HTTPRequests = GetMap("Incoming HTTP Requests").Init() TimerEvents = GetMap("Triggers and Timers Executed").Init() TimerCounts = GetMap("Triggers and Timers Counters").Init() Website = GetMap("Outbound Requests to Website").Init() ServiceChecks = GetMap("Service Check Responses").Init() Apps = GetMap("Starr App Requests").Init() FileWatcher = GetMap("File Watcher").Init() )
var ( // IsSynology tells us if this we're running on a Synology. IsSynology = isSynology() // IsDocker tells us if this is a Docker container. IsDocker = isDocker() IsUnstable = strings.HasPrefix(version.Branch, "unstable") DurafmtUnits, _ = durafmt.DefaultUnitsCoder.Decode("year,week,day,hour,min,sec,ms:ms,µs:µs") DurafmtShort, _ = durafmt.DefaultUnitsCoder.Decode("y:y,w:w,d:d,h:h,m:m,s:s,ms:ms,µs:µs") // ConfigPostDecoder is a package global, because it caches // meta-data about structs, and an instance can be shared safely. ConfigPostDecoder = schema.NewDecoder() )
var ErrDisabledInstance = errors.New("instance is administratively disabled")
ErrDisabledInstance is returned when a request for a disabled instance is performed.
Functions ¶
func DurationAge ¶ added in v0.8.0
DurationAge returns an elapsed-time formatted for humans. Print this after a date to show how long ago it was.
func FormatBytes ¶ added in v0.5.0
FormatBytes converts a byte counter into a pretty UI string. The input val must be int, int64, uint64 or float64.
func GetID ¶ added in v0.9.3
GetID returns the request ID from the context. If no ID is found, a new one is created.
func GetSplitKeys ¶ added in v0.4.1
func PrintVersionInfo ¶ added in v0.8.0
PrintVersionInfo returns version information.
func ReqID ¶ added in v0.9.3
func ReqID() string
ReqID returns a brand new random request ID. Used for logging. Try to avoid calling this directly.
func TodaysEmoji ¶ added in v0.3.3
func TodaysEmoji() string
TodaysEmoji returns an emoji specific to the month (or perhaps date).
Types ¶
type AllData ¶ added in v0.4.1
type AllData struct {
LogFiles map[string]any `json:"logFiles"`
APIHits map[string]any `json:"apiHits"`
HTTPRequests map[string]any `json:"httpRequests"`
TimerEvents map[string]map[string]any `json:"timerEvents"`
TimerCounts map[string]any `json:"timerCounts"`
Website map[string]any `json:"website"`
ServiceChecks map[string]map[string]any `json:"serviceChecks"`
Apps map[string]map[string]any `json:"apps"`
FileWatcher map[string]any `json:"fileWatcher"`
}
func GetAllData ¶ added in v0.4.1
func GetAllData() AllData
type InstancePinger ¶ added in v0.9.0
InstancePinger is an interface for pinging a server instance. Used between apps and client.
type Logger ¶ added in v0.3.2
type Logger interface {
Trace(reqID string, v ...any) string
Print(reqID string, v ...any)
Printf(reqID string, msg string, v ...any)
Error(reqID string, v ...any)
Errorf(reqID string, msg string, v ...any)
Debug(reqID string, v ...any)
Debugf(reqID string, msg string, v ...any)
DebugEnabled() bool
CapturePanic()
}
Logger is an interface for our logs package. We use this to avoid an import cycle.
var Log Logger
Log is created here to avoid an import cycle between website and logs.