diff --git a/utils/consts.go b/utils/consts.go index cf49047e5..802120051 100755 --- a/utils/consts.go +++ b/utils/consts.go @@ -42,29 +42,32 @@ var ( MetaS3jsonMap: ContentJSON, } - // CachePartitions enables creation of cache partitions - CachePartitions = NewStringSet([]string{CacheDestinations, CacheReverseDestinations, - CacheRatingPlans, CacheRatingProfiles, CacheActions, CacheActionPlans, - CacheAccountActionPlans, CacheActionTriggers, CacheSharedGroups, CacheTimings, - CacheResourceProfiles, CacheResources, CacheEventResources, CacheStatQueueProfiles, - CacheStatQueues, CacheThresholdProfiles, CacheThresholds, CacheFilters, - CacheRouteProfiles, CacheAttributeProfiles, CacheChargerProfiles, CacheActionProfiles, - CacheDispatcherProfiles, CacheDispatcherHosts, CacheDispatchers, CacheResourceFilterIndexes, - CacheStatFilterIndexes, CacheThresholdFilterIndexes, CacheRouteFilterIndexes, - CacheAttributeFilterIndexes, CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, - CacheDispatcherRoutes, CacheDispatcherLoads, CacheDiameterMessages, CacheRPCResponses, - CacheClosedSessions, CacheCDRIDs, CacheLoadIDs, CacheRPCConnections, CacheRatingProfilesTmp, - CacheUCH, CacheSTIR, CacheEventCharges, CacheRateProfiles, CacheRateProfilesFilterIndexes, - CacheRateFilterIndexes, CacheActionProfilesFilterIndexes, CacheAccountProfilesFilterIndexes, - CacheAccountProfiles, CacheReverseFilterIndexes, MetaAPIBan, CacheCapsEvents, - // only internalDB - CacheVersions, CacheAccounts, - CacheTBLTPTimings, CacheTBLTPDestinations, CacheTBLTPRates, CacheTBLTPDestinationRates, + extraDBPartition = NewStringSet([]string{CacheDispatchers, + CacheDispatcherRoutes, CacheDispatcherLoads, CacheDiameterMessages, CacheRPCResponses, CacheClosedSessions, + CacheCDRIDs, CacheRPCConnections, CacheUCH, CacheSTIR, CacheEventCharges, MetaAPIBan, + CacheCapsEvents, CacheVersions}) + + dataDBPartition = NewStringSet([]string{CacheDestinations, CacheReverseDestinations, CacheRatingPlans, + CacheRatingProfiles, CacheActions, CacheActionTriggers, CacheSharedGroups, CacheTimings, + CacheResourceProfiles, CacheResources, CacheEventResources, CacheStatQueueProfiles, CacheStatQueues, + CacheThresholdProfiles, CacheThresholds, CacheFilters, CacheRouteProfiles, CacheAttributeProfiles, + CacheChargerProfiles, CacheActionProfiles, CacheDispatcherProfiles, CacheDispatcherHosts, + CacheResourceFilterIndexes, CacheStatFilterIndexes, CacheThresholdFilterIndexes, CacheRouteFilterIndexes, + CacheAttributeFilterIndexes, CacheChargerFilterIndexes, CacheDispatcherFilterIndexes, CacheLoadIDs, + CacheRatingProfilesTmp, CacheRateProfiles, CacheRateProfilesFilterIndexes, CacheRateFilterIndexes, + CacheActionProfilesFilterIndexes, CacheAccountProfilesFilterIndexes, CacheReverseFilterIndexes, + CacheActionPlans, CacheAccountActionPlans, CacheAccountProfiles, CacheAccounts}) + + storDBPartition = NewStringSet([]string{CacheTBLTPTimings, CacheTBLTPDestinations, CacheTBLTPRates, CacheTBLTPDestinationRates, CacheTBLTPRatingPlans, CacheTBLTPRatingProfiles, CacheTBLTPSharedGroups, CacheTBLTPActions, CacheTBLTPActionPlans, CacheTBLTPActionTriggers, CacheTBLTPAccountActions, CacheTBLTPResources, CacheTBLTPStats, CacheTBLTPThresholds, CacheTBLTPFilters, CacheSessionCostsTBL, CacheCDRsTBL, CacheTBLTPRoutes, CacheTBLTPAttributes, CacheTBLTPChargers, CacheTBLTPDispatchers, CacheTBLTPDispatcherHosts, CacheTBLTPRateProfiles, CacheTBLTPActionProfiles, CacheTBLTPAccountProfiles}) + + // CachePartitions enables creation of cache partitions + CachePartitions = Join(extraDBPartition, dataDBPartition, storDBPartition) + CacheInstanceToPrefix = map[string]string{ CacheDestinations: DestinationPrefix, CacheReverseDestinations: ReverseDestinationPrefix, diff --git a/utils/set.go b/utils/stringset.go similarity index 93% rename from utils/set.go rename to utils/stringset.go index 494ad3b21..6bb25f958 100644 --- a/utils/set.go +++ b/utils/stringset.go @@ -18,7 +18,9 @@ along with this program. If not, see package utils -import "sort" +import ( + "sort" +) // NewStringSet returns a new StringSet func NewStringSet(dataSlice []string) (s StringSet) { @@ -109,3 +111,13 @@ func (s StringSet) GetOne() string { } return EmptyString } + +func Join(s ...StringSet) (conc StringSet) { + conc = make(StringSet) + for _, k := range s { + for key := range k { + conc.Add(key) + } + } + return +} diff --git a/utils/set_test.go b/utils/stringset_test.go similarity index 92% rename from utils/set_test.go rename to utils/stringset_test.go index 48357fdfa..2185df9cf 100644 --- a/utils/set_test.go +++ b/utils/stringset_test.go @@ -235,3 +235,27 @@ func TestGetOne(t *testing.T) { t.Errorf("Expected %+v, received %+v", EmptyString, value) } } + +func TestStringSetJoin(t *testing.T) { + set1 := StringSet{ + "test1": struct{}{}, + } + set2 := StringSet{ + "test2": struct{}{}, + "test5": struct{}{}, + } + set3 := StringSet{ + "test3": struct{}{}, + } + rcv := Join(set1, set2, set3) + + expected := StringSet{ + "test1": struct{}{}, + "test2": struct{}{}, + "test3": struct{}{}, + "test5": struct{}{}, + } + if !reflect.DeepEqual(rcv, expected) { + t.Errorf("Expected %+v, received %+v", ToJSON(expected), ToJSON(rcv)) + } +}