Skip to content

Commit d964391

Browse files
IIamasecondsSean-Der
authored andcommitted
Use environment variables instead of string values
1 parent c0fdb49 commit d964391

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

internal/chat/chat.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import (
44
"os"
55
"strconv"
66
"time"
7+
8+
"github.com/glimesh/broadcast-box/internal/environment"
79
)
810

911
const (
@@ -53,21 +55,21 @@ type Manager struct {
5355

5456
func NewManager() *Manager {
5557
maxHistory := DefaultMaxHistory
56-
if val := os.Getenv("CHAT_MAX_HISTORY"); val != "" {
58+
if val := os.Getenv(environment.ChatMaxHistory); val != "" {
5759
if i, err := strconv.Atoi(val); err == nil {
5860
maxHistory = i
5961
}
6062
}
6163

6264
defaultTTL := DefaultTTL
63-
if val := os.Getenv("CHAT_DEFAULT_TTL"); val != "" {
65+
if val := os.Getenv(environment.ChatDefaultTTL); val != "" {
6466
if d, err := time.ParseDuration(val); err == nil {
6567
defaultTTL = d
6668
}
6769
}
6870

6971
cleanupInterval := DefaultCleanupInterval
70-
if val := os.Getenv("CHAT_CLEANUP_INTERVAL"); val != "" {
72+
if val := os.Getenv(environment.ChatCleanupInterval); val != "" {
7173
if d, err := time.ParseDuration(val); err == nil && d > 0 {
7274
cleanupInterval = d
7375
}

internal/environment/variables.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const (
1212
EnableProfiling = "ENABLE_PROFILING"
1313

1414
// SSL
15-
useSSL = "USE_SSL"
1615
SSLKey = "SSL_KEY"
1716
SSLCert = "SSL_CERT"
1817

@@ -26,6 +25,11 @@ const (
2625
frontendPath = "FRONTEND_PATH"
2726
FrontendAdminToken = "FRONTEND_ADMIN_TOKEN"
2827

28+
// CHAT
29+
ChatMaxHistory = "CHAT_MAX_HISTORY"
30+
ChatDefaultTTL = "CHAT_DEFAULT_TTL"
31+
ChatCleanupInterval = "CHAT_CLEANUP_INTERVAL"
32+
2933
// WEBRTC
3034
IncludeLoopbackCandidate = "INCLUDE_LOOPBACK_CANDIDATE"
3135
NetworkTypes = "NETWORK_TYPES"

0 commit comments

Comments
 (0)