fix: fix parallel access of env vars
This commit is contained in:
parent
e0d8644264
commit
78a673e4ad
|
@ -26,20 +26,11 @@ func (e *EnvStore) UpdateStore(store map[string]interface{}) {
|
||||||
|
|
||||||
// GetStore returns the env store
|
// GetStore returns the env store
|
||||||
func (e *EnvStore) GetStore() map[string]interface{} {
|
func (e *EnvStore) GetStore() map[string]interface{} {
|
||||||
if os.Getenv("ENV") != "test" {
|
|
||||||
e.mutex.Lock()
|
|
||||||
defer e.mutex.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
return e.store
|
return e.store
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get returns the value of the key in evn store
|
// Get returns the value of the key in evn store
|
||||||
func (e *EnvStore) Get(key string) interface{} {
|
func (e *EnvStore) Get(key string) interface{} {
|
||||||
if os.Getenv("ENV") != "test" {
|
|
||||||
e.mutex.Lock()
|
|
||||||
defer e.mutex.Unlock()
|
|
||||||
}
|
|
||||||
return e.store[key]
|
return e.store[key]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,10 +19,6 @@ func (c *provider) ClearStore() error {
|
||||||
|
|
||||||
// GetUserSessions returns all the user session token from the in-memory store.
|
// GetUserSessions returns all the user session token from the in-memory store.
|
||||||
func (c *provider) GetUserSessions(userId string) map[string]string {
|
func (c *provider) GetUserSessions(userId string) map[string]string {
|
||||||
if os.Getenv("ENV") != "test" {
|
|
||||||
c.mutex.Lock()
|
|
||||||
defer c.mutex.Unlock()
|
|
||||||
}
|
|
||||||
res := map[string]string{}
|
res := map[string]string{}
|
||||||
for k, v := range c.stateStore {
|
for k, v := range c.stateStore {
|
||||||
split := strings.Split(v, "@")
|
split := strings.Split(v, "@")
|
||||||
|
@ -61,11 +57,6 @@ func (c *provider) SetState(key, state string) error {
|
||||||
|
|
||||||
// GetState gets the state from the in-memory store.
|
// GetState gets the state from the in-memory store.
|
||||||
func (c *provider) GetState(key string) (string, error) {
|
func (c *provider) GetState(key string) (string, error) {
|
||||||
if os.Getenv("ENV") != "test" {
|
|
||||||
c.mutex.Lock()
|
|
||||||
defer c.mutex.Unlock()
|
|
||||||
}
|
|
||||||
|
|
||||||
state := ""
|
state := ""
|
||||||
if stateVal, ok := c.stateStore[key]; ok {
|
if stateVal, ok := c.stateStore[key]; ok {
|
||||||
state = stateVal
|
state = stateVal
|
||||||
|
|
Loading…
Reference in New Issue
Block a user