diff --git a/engine/calldesc.go b/engine/calldesc.go index 78da15fa5..b0f2e4f80 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -39,9 +39,9 @@ func init() { //db_server := "127.0.0.1" //db_server := "192.168.0.17" m, _ := NewMapStorage() + //m, _ = NewMongoStorage(db_server, "27017", "cgrates_test", "", "") + //m, _ = NewRedisStorage(db_server+":6379", 11, "") storageGetter, _ = m.(DataStorage) - //storageGetter, _ = NewMongoStorage(db_server, "27017", "cgrates_test", "", "") - //storageGetter, _ = NewRedisStorage(db_server+":6379", 11, "") storageLogger = storageGetter.(LogStorage) } diff --git a/engine/storage_mongo.go b/engine/storage_mongo.go index 7bf735a60..f39fea872 100644 --- a/engine/storage_mongo.go +++ b/engine/storage_mongo.go @@ -19,10 +19,8 @@ along with this program. If not, see package engine import ( - "errors" "fmt" "github.com/cgrates/cgrates/history" - "github.com/cgrates/cgrates/utils" "labix.org/v2/mgo" "labix.org/v2/mgo/bson" "log" @@ -156,163 +154,6 @@ func (ms *MongoStorage) SetDestination(dest *Destination) error { return ms.db.C("destinations").Insert(dest) } -func (ms *MongoStorage) GetTPIds() ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPTiming(tpid string, tm *Timing) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPTiming(tpid, tmId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPTiming(tpid, tmId string) (*Timing, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPTimingIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPDestinationIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPDestination(tpid, destTag string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -// Extracts destinations from StorDB on specific tariffplan id -func (ms *MongoStorage) GetTPDestination(tpid, destTag string) (*Destination, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPDestination(tpid string, dest *Destination) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPRate(tpid, rtId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPRates(tpid string, rts map[string][]*Rate) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPRateIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPDestinationRate(tpid, drId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPDestinationRates(tpid string, drs map[string][]*DestinationRate) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPDestinationRate(tpid, drId string) (*utils.TPDestinationRate, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPDestinationRateIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPDestRateTimings(tpid string, drts map[string][]*DestinationRateTiming) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPDestRateTimingIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPRatingProfile(tpid, rpId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPRatingProfiles(tpid string, rps map[string][]*RatingProfile) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPRatingProfile(tpid, rpId string) (*utils.TPRatingProfile, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPRatingProfileIds(filters *utils.AttrTPRatingProfileIds) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPActions(tpid, aId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPActions(tpid string, acts map[string][]*Action) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPActions(tpid, aId string) (*utils.TPActions, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPActionIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPActionTimings(tpid, atId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPActionTimings(tpid string, ats map[string][]*ActionTiming) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTimingsRow, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPActionTimingIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPActionTriggers(tpid, atId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPActionTriggers(tpid string, ats map[string][]*ActionTrigger) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPActionTriggerIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) ExistsTPAccountActions(tpid, aaId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) SetTPAccountActions(tpid string, aa map[string]*AccountAction) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetTPAccountActionIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - func (ms *MongoStorage) GetActions(key string) (as Actions, err error) { result := AcKeyValue{} err = ms.db.C("actions").Find(bson.M{"key": key}).One(&result) @@ -375,51 +216,3 @@ func (ms *MongoStorage) LogActionTiming(source string, at *ActionTiming, as Acti func (ms *MongoStorage) LogError(uuid, source, errstr string) (err error) { return ms.db.C("errlog").Insert(&LogErrEntry{uuid, errstr, source}) } - -func (ms *MongoStorage) SetCdr(utils.CDR) error { - return nil -} - -func (ms *MongoStorage) SetRatedCdr(cdr utils.CDR, cc *CallCost, extraInfo string) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (ms *MongoStorage) GetAllRatedCdr() ([]utils.CDR, error) { - return nil, nil -} - -func (ms *MongoStorage) GetDestinations(tpid string) ([]*Destination, error) { - return nil, nil -} - -func (ms *MongoStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error) { - return nil, nil -} - -func (ms *MongoStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpActions(tpid, tag string) (map[string][]*Action, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpActionTimings(tpid, tag string) (map[string][]*ActionTiming, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*ActionTrigger, error) { - return nil, nil -} -func (ms *MongoStorage) GetTpAccountActions(tpid, tag string) (map[string]*AccountAction, error) { - return nil, nil -} diff --git a/engine/storage_redis.go b/engine/storage_redis.go index 572ca34ac..e49294844 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -19,10 +19,8 @@ along with this program. If not, see package engine import ( - "errors" "fmt" "github.com/cgrates/cgrates/history" - "github.com/cgrates/cgrates/utils" "menteslibres.net/gosexy/redis" "strconv" "strings" @@ -110,163 +108,6 @@ func (rs *RedisStorage) SetDestination(dest *Destination) (err error) { return } -func (rs *RedisStorage) GetTPIds() ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPTiming(tpid string, tm *Timing) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPTiming(tpid, tmId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPTiming(tpid, tmId string) (*Timing, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPTimingIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPDestinationIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPDestination(tpid, destTag string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -// Extracts destinations from StorDB on specific tariffplan id -func (rs *RedisStorage) GetTPDestination(tpid, destTag string) (*Destination, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPDestination(tpid string, dest *Destination) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPRate(tpid, rtId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPRates(tpid string, rts map[string][]*Rate) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPRateIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPDestinationRate(tpid, drId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPDestinationRates(tpid string, drs map[string][]*DestinationRate) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPDestinationRate(tpid, drId string) (*utils.TPDestinationRate, error) { - return nil, nil -} - -func (rs *RedisStorage) GetTPDestinationRateIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPDestRateTimings(tpid string, drts map[string][]*DestinationRateTiming) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPDestRateTimingIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPRatingProfile(tpid, rpId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPRatingProfiles(tpid string, rps map[string][]*RatingProfile) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPRatingProfile(tpid, rpId string) (*utils.TPRatingProfile, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPRatingProfileIds(filters *utils.AttrTPRatingProfileIds) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPActions(tpid, aId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPActions(tpid string, acts map[string][]*Action) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPActions(tpid, aId string) (*utils.TPActions, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPActionIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPActionTimings(tpid, atId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPActionTimings(tpid string, ats map[string][]*ActionTiming) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTimingsRow, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPActionTimingIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPActionTriggers(tpid, atId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPActionTriggers(tpid string, ats map[string][]*ActionTrigger) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPActionTriggerIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) ExistsTPAccountActions(tpid, aaId string) (bool, error) { - return false, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) SetTPAccountActions(tpid string, aa map[string]*AccountAction) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetTPAccountActionIds(tpid string) ([]string, error) { - return nil, errors.New(utils.ERR_NOT_IMPLEMENTED) -} - func (rs *RedisStorage) GetActions(key string) (as Actions, err error) { var values string if values, err = rs.db.Get(ACTION_PREFIX + key); err == nil { @@ -383,48 +224,3 @@ func (rs *RedisStorage) LogError(uuid, source, errstr string) (err error) { _, err = rs.db.Set(LOG_ERR+source+"_"+uuid, errstr) return } - -func (rs *RedisStorage) SetCdr(utils.CDR) error { - return nil -} - -func (rs *RedisStorage) SetRatedCdr(cdr utils.CDR, cc *CallCost, extraInfo string) error { - return errors.New(utils.ERR_NOT_IMPLEMENTED) -} - -func (rs *RedisStorage) GetAllRatedCdr() ([]utils.CDR, error) { - return nil, nil -} - -func (rs *RedisStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error) { - return nil, nil -} - -func (rs *RedisStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error) { - return nil, nil -} - -func (ms *RedisStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpActions(tpid, tag string) (map[string][]*Action, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpActionTimings(tpid, tag string) (map[string][]*ActionTiming, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*ActionTrigger, error) { - return nil, nil -} -func (rs *RedisStorage) GetTpAccountActions(tpid, tag string) (map[string]*AccountAction, error) { - return nil, nil -} diff --git a/engine/storage_sql.go b/engine/storage_sql.go index 00674df31..7c83e7756 100644 --- a/engine/storage_sql.go +++ b/engine/storage_sql.go @@ -38,25 +38,6 @@ func (self *SQLStorage) Flush() (err error) { return } -func (self *SQLStorage) GetRatingProfile(string) (rp *RatingProfile, err error) { - /*row := self.Db.QueryRow(fmt.Sprintf("SELECT * FROM ratingprofiles WHERE id='%s'", id)) - err = row.Scan(&rp, &cc.Direction, &cc.Tenant, &cc.TOR, &cc.Subject, &cc.Destination, &cc.Cost, &cc.ConnectFee, ×pansJson) - err = json.Unmarshal([]byte(timespansJson), cc.Timespans)*/ - return -} - -func (self *SQLStorage) SetRatingProfile(rp *RatingProfile) (err error) { - return -} - -func (self *SQLStorage) GetDestination(string) (d *Destination, err error) { - return -} - -func (self *SQLStorage) SetDestination(d *Destination) (err error) { - return -} - // Return a list with all TPids defined in the system, even if incomplete, isolated in some table. func (self *SQLStorage) GetTPIds() ([]string, error) { rows, err := self.Db.Query( @@ -800,24 +781,6 @@ func (self *SQLStorage) GetTPAccountActionIds(tpid string) ([]string, error) { return ids, nil } -func (self *SQLStorage) GetUserBalance(string) (ub *UserBalance, err error) { return } - -func (self *SQLStorage) SetUserBalance(ub *UserBalance) (err error) { return } - -func (self *SQLStorage) GetActions(string) (as Actions, err error) { - return -} - -func (self *SQLStorage) SetActions(key string, as Actions) (err error) { return } - -func (self *SQLStorage) GetActionTimings(key string) (ats ActionTimings, err error) { return } - -func (self *SQLStorage) SetActionTimings(key string, ats ActionTimings) (err error) { return } - -func (self *SQLStorage) GetAllActionTimings() (ats map[string]ActionTimings, err error) { - return -} - func (self *SQLStorage) LogCallCost(uuid, source string, cc *CallCost) (err error) { //ToDo: Add cgrid to logCallCost if self.Db == nil {