fix: cassandra + mongo + arangodb issues with webhook

This commit is contained in:
Lakhan Samani
2022-07-12 11:48:42 +05:30
parent bfbeb6add2
commit 6b57bce6d9
19 changed files with 167 additions and 94 deletions

View File

@@ -1,10 +1,7 @@
package stores
import (
"os"
"sync"
"github.com/authorizerdev/authorizer/server/constants"
)
// EnvStore struct to store the env variables
@@ -23,12 +20,10 @@ func NewEnvStore() *EnvStore {
// UpdateEnvStore to update the whole env store object
func (e *EnvStore) UpdateStore(store map[string]interface{}) {
if os.Getenv("ENV") != constants.TestEnv {
e.mutex.Lock()
defer e.mutex.Unlock()
}
// just override the keys + new keys
e.mutex.Lock()
defer e.mutex.Unlock()
// just override the keys + new keys
for key, value := range store {
e.store[key] = value
}
@@ -46,9 +41,8 @@ func (e *EnvStore) Get(key string) interface{} {
// Set sets the value of the key in env store
func (e *EnvStore) Set(key string, value interface{}) {
if os.Getenv("ENV") != constants.TestEnv {
e.mutex.Lock()
defer e.mutex.Unlock()
}
e.mutex.Lock()
defer e.mutex.Unlock()
e.store[key] = value
}

View File

@@ -1,11 +1,8 @@
package stores
import (
"os"
"strings"
"sync"
"github.com/authorizerdev/authorizer/server/constants"
)
// SessionStore struct to store the env variables
@@ -29,10 +26,9 @@ func (s *SessionStore) Get(key, subKey string) string {
// Set sets the value of the key in state store
func (s *SessionStore) Set(key string, subKey, value string) {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
s.mutex.Lock()
defer s.mutex.Unlock()
if _, ok := s.store[key]; !ok {
s.store[key] = make(map[string]string)
}
@@ -41,19 +37,15 @@ func (s *SessionStore) Set(key string, subKey, value string) {
// RemoveAll all values for given key
func (s *SessionStore) RemoveAll(key string) {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
s.mutex.Lock()
defer s.mutex.Unlock()
delete(s.store, key)
}
// Remove value for given key and subkey
func (s *SessionStore) Remove(key, subKey string) {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
s.mutex.Lock()
defer s.mutex.Unlock()
if _, ok := s.store[key]; ok {
delete(s.store[key], subKey)
}
@@ -69,11 +61,8 @@ func (s *SessionStore) GetAll(key string) map[string]string {
// RemoveByNamespace to delete session for a given namespace example google,github
func (s *SessionStore) RemoveByNamespace(namespace string) error {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
s.mutex.Lock()
defer s.mutex.Unlock()
for key := range s.store {
if strings.Contains(key, namespace+":") {
delete(s.store, key)

View File

@@ -1,10 +1,7 @@
package stores
import (
"os"
"sync"
"github.com/authorizerdev/authorizer/server/constants"
)
// StateStore struct to store the env variables
@@ -28,19 +25,16 @@ func (s *StateStore) Get(key string) string {
// Set sets the value of the key in state store
func (s *StateStore) Set(key string, value string) {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
s.mutex.Lock()
defer s.mutex.Unlock()
s.store[key] = value
}
// Remove removes the key from state store
func (s *StateStore) Remove(key string) {
if os.Getenv("ENV") != constants.TestEnv {
s.mutex.Lock()
defer s.mutex.Unlock()
}
s.mutex.Lock()
defer s.mutex.Unlock()
delete(s.store, key)
}