2 ms·
I don't use any of them services, but any config that has multiple readers and a single writer (who updates it when it changes) can just be protected by a sync.
by Philip-J-Fry 5y ago
I don't use any of them services, but any config that has multiple readers and a single writer (who updates it when it changes) can just be protected by a sync.RWMutex.
The easiest thing to do would be to add a RWMutex to your Config struct. Then have public accessor methods which RLock the mutex while retrieving a field value.
Then when you want to update the config have something like a `Set(c Config)` method which allows you to overwrite the config stored in pointer. This Locks the RWMutex for writing of course.