Large API Refactor in prep for autobindings #494

Merged
sarah merged 7 commits from autobindings into eventhooks 2023-02-28 18:09:40 +00:00
1 changed files with 7 additions and 0 deletions
Showing only changes of commit b22b8f3297 - Show all commits

View File

@ -1,10 +1,13 @@
package model
import "sync"
// Experiments are optional functionality that can be enabled/disabled by an application either completely or individually.
// examples of experiments include File Sharing, Profile Images and Groups.
type Experiments struct {
enabled bool
experiments map[string]bool
lock sync.Mutex
}
// InitExperiments encapsulates a set of experiments separate from their storage in GlobalSettings.
@ -24,6 +27,10 @@ func (e *Experiments) IsEnabled(experiment string) bool {
// todo handle default-enabled functionality
return false
}
// go will sometimes panic if we do not lock this read-only map...
e.lock.Lock()
defer e.lock.Unlock()
enabled, exists := e.experiments[experiment]
if !exists {
return false