• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

OneBusAway / watchdog / 16304548909

15 Jul 2025 09:08PM UTC coverage: 59.36% (+0.2%) from 59.189%
16304548909

Pull #75

github

Abo-Omar-74
chore: format code using go fmt
Pull Request #75: Encapsulate Config Access with Internal Locking and Thread-Safe Getters

74 of 199 new or added lines in 10 files covered. (37.19%)

12 existing lines in 1 file now uncovered.

723 of 1218 relevant lines covered (59.36%)

0.65 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.18
/internal/server/server.go
1
package server
2

3
import (
4
        "sync"
5

6
        "watchdog.onebusaway.org/internal/models"
7
)
8

9
// Config Holds all the configuration settings for our application
10
type Config struct {
11
        Port    int
12
        Env     string
13
        Mu      sync.RWMutex
14
        Servers []models.ObaServer
15
}
16

17
// NewConfig creates a new instance of a Config struct.
18
func NewConfig(port int, env string, servers []models.ObaServer) *Config {
1✔
19
        return &Config{
1✔
20
                Port:    port,
1✔
21
                Env:     env,
1✔
22
                Servers: servers,
1✔
23
        }
1✔
24
}
1✔
25

26
// updateConfig safely updates the config servers.
NEW
27
func (cfg *Config) UpdateConfig(newServers []models.ObaServer) {
×
NEW
28
        cfg.Mu.Lock()
×
NEW
29
        defer cfg.Mu.Unlock()
×
NEW
30
        cfg.Servers = newServers
×
NEW
31
}
×
32

33
// GetServers safely returns a copy of the servers slice to avoid
34
// concurrent modification issues.
35
// This method should be used to access the servers from other parts of the application.
36
// It returns a copy of the servers slice to ensure thread safety.
NEW
37
func (cfg *Config) GetServers() []models.ObaServer {
×
NEW
38
        cfg.Mu.RLock()
×
NEW
39
        defer cfg.Mu.RUnlock()
×
NEW
40
        return append([]models.ObaServer(nil), cfg.Servers...)
×
NEW
41
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc