Commit 6838c5e6 authored by Ajit Jagtap's avatar Ajit Jagtap
Browse files

Merge branch 'ab_Fix_SLSImports' into 'devbranch'

Fix: CoreSLS is required as a dependency fro v2

Closes MKCLOS/coreosv3/corestudio#448

See merge request !204
parents 1991d384 af39c11d
Branches
Tags
2 merge requests!210Staging mepdeployment05072020,!204Fix: CoreSLS is required as a dependency fro v2
Showing with 29 additions and 95 deletions
......@@ -11,9 +11,6 @@ package sessionmdl
import (
"errors"
"time"
"coresls/servers/coresls/app/models"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/cachemdl"
)
......@@ -33,25 +30,6 @@ var (
ErrSessionValidationFailed = errors.New("session validation failed")
)
// InitUserSessionCache initializes the cache with provided configuration. Need to provide a cache type to use.
func InitUserSessionCache(chacheType int) {
cacheConfig := cachemdl.CacheConfig{
Type: chacheType,
RedisCache: &cachemdl.RedisCache{
Addr: "", // empty takes default redis address 6379
DB: models.RedisDBSessionManager,
Prefix: models.ProjectID,
},
FastCache: &cachemdl.FastCacheHelper{
CleanupTime: 60 * time.Minute,
MaxEntries: 1000,
Expiration: -1,
},
}
store = cachemdl.GetCacheInstance(&cacheConfig)
}
// Init initializes sessions with provided cache. Subsequent calls will not have any effect after first initialization.
func Init(cache cachemdl.Cacher) {
if store != nil {
......
package cachemdl
import (
"errors"
"time"
)
......@@ -12,11 +11,6 @@ const (
TypeRedisCache
)
var (
// ErrInvalidCacheType indicates provided cache type is not supported
ErrInvalidCacheType = errors.New("invalid cache type provided")
)
// Cacher provides access to underlying cache, make sure all caches implement these methods.
//
// The return types of data can be different. Ex. In case of redis cache it is `string`. The caller needs to handle this with the help of Type() method.
......@@ -42,26 +36,3 @@ type Cacher interface {
Type() int
}
// GetCacheInstance returns a cache instance, panics if invalid cache type is provided
func GetCacheInstance(cfg *CacheConfig) Cacher {
switch cfg.Type {
case TypeFastCache:
cfg.FastCache.Setup(cfg.FastCache.MaxEntries, cfg.FastCache.Expiration, cfg.FastCache.CleanupTime)
return cfg.FastCache
case TypeRedisCache:
cfg.RedisCache.Setup(cfg.RedisCache.Addr, cfg.RedisCache.Password, cfg.RedisCache.Prefix, cfg.RedisCache.DB, cfg.RedisCache.Expiration)
return cfg.RedisCache
default:
panic(ErrInvalidCacheType)
}
}
// CacheConfig -
type CacheConfig struct {
Type int
FastCache *FastCacheHelper
RedisCache *RedisCache
}
package dalmdl
const (
MONGODB = "MONGO"
MYSQL = "MYSQL"
FDB = "FDB"
SQLSERVER = "SQLSERVER"
GraphDB = "GRAPHDB"
)
......@@ -4,21 +4,19 @@ package routebuildermdl
import (
"context"
"coresls/servers/coresls/app/modules/constantmdl"
"strings"
"github.com/pquerna/ffjson/ffjson"
routing "github.com/qiangxue/fasthttp-routing"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/statemdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/authmdl/jwtmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/authmdl/roleenforcemdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/dalmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/servicebuildermdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/statemdl"
version "github.com/hashicorp/go-version"
"github.com/pquerna/ffjson/ffjson"
routing "github.com/qiangxue/fasthttp-routing"
"github.com/tidwall/gjson"
)
......@@ -72,7 +70,7 @@ func commonHandler(c *routing.Context, isRestricted, isRoleBased, heavyDataActiv
var err error
// database transaction rollback if transaction is enabled
switch ab.DatabaseType {
case constantmdl.MYSQL:
case dalmdl.MYSQL:
if ab.TXN != nil {
loggermdl.LogError("MYSQL Transaction Rollbacked")
err = ab.TXN.Rollback()
......@@ -82,7 +80,7 @@ func commonHandler(c *routing.Context, isRestricted, isRoleBased, heavyDataActiv
}
}
case constantmdl.SQLSERVER:
case dalmdl.SQLSERVER:
if ab.SQLServerTXN != nil {
loggermdl.LogError("SQLSERVER Transaction Rollbacked")
err = ab.SQLServerTXN.Rollback()
......@@ -92,7 +90,7 @@ func commonHandler(c *routing.Context, isRestricted, isRoleBased, heavyDataActiv
}
}
case constantmdl.GraphDB:
case dalmdl.GraphDB:
if ab.GraphDbTXN != nil {
loggermdl.LogError("GRAPHDB Transaction Rollbacked")
err = ab.GraphDbTXN.Discard(context.TODO())
......@@ -116,7 +114,7 @@ func commonHandler(c *routing.Context, isRestricted, isRoleBased, heavyDataActiv
var err error
switch ab.DatabaseType {
case constantmdl.MYSQL:
case dalmdl.MYSQL:
if ab.TXN != nil {
loggermdl.LogError("MYSQL Transaction Commit")
err = ab.TXN.Commit()
......@@ -129,7 +127,7 @@ func commonHandler(c *routing.Context, isRestricted, isRoleBased, heavyDataActiv
}
}
case constantmdl.SQLSERVER:
case dalmdl.SQLSERVER:
if ab.SQLServerTXN != nil {
loggermdl.LogError("SQLSERVER Transaction Commit")
err = ab.SQLServerTXN.Commit()
......@@ -142,7 +140,7 @@ func commonHandler(c *routing.Context, isRestricted, isRoleBased, heavyDataActiv
}
}
case constantmdl.GraphDB:
case dalmdl.GraphDB:
if ab.SQLServerTXN != nil {
loggermdl.LogError("GRAPHDB Transaction Commit")
err = ab.GraphDbTXN.Commit(context.TODO())
......
......@@ -4,19 +4,18 @@ package routebuildermdl
import (
"context"
"coresls/servers/coresls/app/modules/constantmdl"
"io/ioutil"
"net/http"
"strings"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/authmdl/roleenforcemdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/statemdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/authmdl/jwtmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/authmdl/roleenforcemdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/dalmdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/errormdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/loggermdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/servicebuildermdl"
"corelab.mkcl.org/MKCLOS/coredevelopmentplatform/corepkgv2/statemdl"
"github.com/gin-gonic/gin"
version "github.com/hashicorp/go-version"
"github.com/tidwall/gjson"
......@@ -81,7 +80,7 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased, heavyDataActivity
var err error
// database transaction rollback if transaction is enabled
switch ab.DatabaseType {
case constantmdl.MYSQL:
case dalmdl.MYSQL:
if ab.TXN != nil {
loggermdl.LogError("MYSQL Transaction Rollbacked")
err = ab.TXN.Rollback()
......@@ -91,7 +90,7 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased, heavyDataActivity
}
}
case constantmdl.SQLSERVER:
case dalmdl.SQLSERVER:
if ab.SQLServerTXN != nil {
loggermdl.LogError("SQLSERVER Transaction Rollbacked")
err = ab.SQLServerTXN.Rollback()
......@@ -101,7 +100,7 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased, heavyDataActivity
}
}
case constantmdl.GraphDB:
case dalmdl.GraphDB:
if ab.GraphDbTXN != nil {
loggermdl.LogError("GRAPHDB Transaction Rollbacked")
err = ab.GraphDbTXN.Discard(context.TODO())
......@@ -125,7 +124,7 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased, heavyDataActivity
var err error
switch ab.DatabaseType {
case constantmdl.MYSQL:
case dalmdl.MYSQL:
if ab.TXN != nil {
loggermdl.LogError("MYSQL Transaction Commit")
err = ab.TXN.Commit()
......@@ -138,7 +137,7 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased, heavyDataActivity
}
}
case constantmdl.SQLSERVER:
case dalmdl.SQLSERVER:
if ab.SQLServerTXN != nil {
loggermdl.LogError("SQLSERVER Transaction Commit")
err = ab.SQLServerTXN.Commit()
......@@ -151,7 +150,7 @@ func commonHandler(c *gin.Context, isRestricted, isRoleBased, heavyDataActivity
}
}
case constantmdl.GraphDB:
case dalmdl.GraphDB:
if ab.SQLServerTXN != nil {
loggermdl.LogError("GRAPHDB Transaction Commit")
err = ab.GraphDbTXN.Commit(context.TODO())
......
package sessionmanagermdl
import (
"coresls/servers/coresls/app/models"
"errors"
"time"
......@@ -30,25 +29,6 @@ var store cachemdl.Cacher
var ErrSessionNotFound = errors.New("SESSION_NOT_FOUND")
var ErrInvalidDataType = errors.New("INVALID_DATA_Type")
// InitSessionManagerCache initializes the cache with provided configuration. Need to provide a cache type to use.
func InitSessionManagerCache(chacheType int) {
cacheConfig := cachemdl.CacheConfig{
Type: chacheType,
RedisCache: &cachemdl.RedisCache{
Addr: "", // empty takes default redis address 6379
DB: models.RedisDBSessionManager,
Prefix: models.ProjectID,
},
FastCache: &cachemdl.FastCacheHelper{
CleanupTime: 60 * time.Minute,
MaxEntries: 1000,
Expiration: -1,
},
}
store = cachemdl.GetCacheInstance(&cacheConfig)
}
// Init initializes session manager with provided cache. Subsequent calls will not have any effect after first initialization.
func Init(cache cachemdl.Cacher) {
if store != nil {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment