engine

package
v0.0.0-...-48d1953 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2013 License: GPL-3.0 Imports: 34 Imported by: 0

Documentation

Overview

Rating system designed to be used in VoIP Carriers World Copyright (C) 2013 ITsysCOM

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>

Index

Constants

View Source
const (
	LOG            = "*log"
	RESET_TRIGGERS = "*reset_triggers"
	SET_POSTPAID   = "*set_postpaid"
	RESET_POSTPAID = "*reset_postpaid"
	SET_PREPAID    = "*set_prepaid"
	RESET_PREPAID  = "*reset_prepaid"
	TOPUP_RESET    = "*topup_reset"
	TOPUP          = "*topup"
	DEBIT          = "*debit"
	RESET_COUNTER  = "*reset_counter"
	RESET_COUNTERS = "*reset_counters"
)
View Source
const (
	FORMAT     = "2006-1-2 15:04:05 MST"
	ASAP       = "*asap"
	ASAP_DELAY = "1m"
)
View Source
const (
	RECURSION_MAX_DEPTH = 10
	FALLBACK_SUBJECT    = "*any"
	FALLBACK_SEP        = ";"
)
View Source
const (
	PERCENT  = "*percent"
	ABSOLUTE = "*absolute"
)
View Source
const (
	ACTION_TIMING_PREFIX      = "atm_"
	RATING_PROFILE_PREFIX     = "rpf_"
	ACTION_PREFIX             = "act_"
	USER_BALANCE_PREFIX       = "ubl_"
	DESTINATION_PREFIX        = "dst_"
	LOG_CALL_COST_PREFIX      = "cco_"
	LOG_ACTION_TIMMING_PREFIX = "ltm_"
	LOG_ACTION_TRIGGER_PREFIX = "ltr_"
	LOG_ERR                   = "ler_"
	LOG_CDR                   = "cdr_"
	LOG_MEDIATED_CDR          = "mcd_"
	// sources
	SESSION_MANAGER_SOURCE = "SMR"
	MEDIATOR_SOURCE        = "MED"
	SCHED_SOURCE           = "SCH"
	RATER_SOURCE           = "RAT"
)
View Source
const (
	UB_TYPE_POSTPAID = "*postpaid"
	UB_TYPE_PREPAID  = "*prepaid"
	// Direction type
	INBOUND  = "*in"
	OUTBOUND = "*out"
	// Balance types
	CREDIT       = "*monetary"
	SMS          = "*sms"
	TRAFFIC      = "*internet"
	TRAFFIC_TIME = "*internet_time"
	MINUTES      = "*minutes"
)
View Source
const (
	// the minimum length for a destination prefix to be matched.
	MIN_PREFIX_LENGTH = 2
)

Variables

View Source
var (
	AMOUNT_TOO_BIG = errors.New("Amount excedes balance!")
)
View Source
var FileValidators = map[string]*FileLineRegexValidator{
	utils.DESTINATIONS_CSV: &FileLineRegexValidator{utils.DESTINATIONS_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\+?\d+.?\d*){1}$`),
		"Tag([0-9A-Za-z_]),Prefix([0-9])"},
	utils.TIMINGS_CSV: &FileLineRegexValidator{utils.TIMINGS_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\*any\s*,\s*|(?:\d{1,4};?)+\s*,\s*|\s*,\s*){4}(?:\d{2}:\d{2}:\d{2}|\*asap){1}$`),
		"Tag([0-9A-Za-z_]),Years([0-9;]|*all|<empty>),Months([0-9;]|*all|<empty>),MonthDays([0-9;]|*all|<empty>),WeekDays([0-9;]|*all|<empty>),Time([0-9:]|*asap)"},
	utils.RATES_CSV: &FileLineRegexValidator{utils.RATES_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\d+\.?\d*,){2}(?:\d+s*,){3}(?:\*\w+,){1}(?:\d+\.?\d*,?){2}$`),
		"Tag([0-9A-Za-z_]),ConnectFee([0-9.]),Rate([0-9.]),RateUnit([0-9.]),RateIncrementStart([0-9.])"},
	utils.DESTINATION_RATES_CSV: &FileLineRegexValidator{utils.DESTINATION_RATES_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,?\s*){3}$`),
		"Tag([0-9A-Za-z_]),DestinationsTag([0-9A-Za-z_]),RateTag([0-9A-Za-z_])"},
	utils.DESTRATE_TIMINGS_CSV: &FileLineRegexValidator{utils.DESTRATE_TIMINGS_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){3}(?:\d+.?\d*){1}$`),
		"Tag([0-9A-Za-z_]),DestinationRatesTag([0-9A-Za-z_]),TimingProfile([0-9A-Za-z_]),Weight([0-9.])"},
	utils.RATE_PROFILES_CSV: &FileLineRegexValidator{utils.RATE_PROFILES_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){2}(?:\*out\s*,\s*){1}(?:\*any\s*,\s*|\w+\s*,\s*){1}(?:\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z){1}(?:\w*\s*,?\s*){2}$`),
		"Tenant([0-9A-Za-z_]),TOR([0-9A-Za-z_]),Direction(*out),Subject([0-9A-Za-z_]|*all),RatesFallbackSubject([0-9A-Za-z_]|<empty>),RatesTimingTag([0-9A-Za-z_]),ActivationTime([0-9T:X])"},
	utils.ACTIONS_CSV: &FileLineRegexValidator{utils.ACTIONS_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*),(?:\*\w+\s*),(?:\*\w+\s*),(?:\*out\s*),(?:\d+\s*),(?:\*\w+\s*|\+\d+[smh]\s*|\d+\s*),(?:\*any|\w+\s*),(?:\*\w+\s*)?,(?:\d+\.?\d*\s*)?,(?:\d+\.?\d*\s*)?,(?:\d+\.?\d*\s*)$`),
		"Tag([0-9A-Za-z_]),Action([0-9A-Za-z_]),BalanceType([*a-z_]),Direction(*out),Units([0-9]),ExpiryTime(*[a-z_]|+[0-9][smh]|[0-9])DestinationTag([0-9A-Za-z_]|*all),RateType(*[a-z_]),RateValue([0-9.]),MinutesWeight([0-9.]),Weight([0-9.])"},
	utils.ACTION_TIMINGS_CSV: &FileLineRegexValidator{utils.ACTION_TIMINGS_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){3}(?:\d+\.?\d*){1}`),
		"Tag([0-9A-Za-z_]),ActionsTag([0-9A-Za-z_]),TimingTag([0-9A-Za-z_]),Weight([0-9.])"},
	utils.ACTION_TRIGGERS_CSV: &FileLineRegexValidator{utils.ACTION_TRIGGERS_NRCOLS,
		regexp.MustCompile(`(?:\w+),(?:\*\w+),(?:\*out),(?:\*\w+),(?:\d+\.?\d*),(?:\w+|\*any)?,(?:\w+),(?:\d+\.?\d*)$`),
		"Tag([0-9A-Za-z_]),BalanceType(*[a-z_]),Direction(*out),ThresholdType(*[a-z_]),ThresholdValue([0-9]+),DestinationTag([0-9A-Za-z_]|*all),ActionsTag([0-9A-Za-z_]),Weight([0-9]+)"},
	utils.ACCOUNT_ACTIONS_CSV: &FileLineRegexValidator{utils.ACCOUNT_ACTIONS_NRCOLS,
		regexp.MustCompile(`(?:\w+\s*,\s*){1}(?:\w+\s*,\s*){1}(?:\*out\s*,\s*){1}(?:\w+\s*,?\s*){2}$`),
		"Tenant([0-9A-Za-z_]),Account([0-9A-Za-z_.]),Direction(*out),ActionTimingsTag([0-9A-Za-z_]),ActionTriggersTag([0-9A-Za-z_])"},
}

Functions

func SetDataStorage

func SetDataStorage(sg DataStorage)

Exported method to set the storage getter.

func SetDebitPeriod

func SetDebitPeriod(d time.Duration)

Exported method to set the debit period for caching purposes.

func SetHistoryScribe

func SetHistoryScribe(scribe history.Scribe)

Exported method to set the history scribe.

func SetRoundingMethodAndDecimals

func SetRoundingMethodAndDecimals(rm string, rd int)

Sets the global rounding method and decimal precision for GetCost method

func SetStorageLogger

func SetStorageLogger(sg DataStorage)

Sets the database for logging (can be de same as storage getter or different db)

func ValidateCSVData

func ValidateCSVData(fn string, re *regexp.Regexp) (err error)

Types

type AcKeyValue

type AcKeyValue struct {
	Key   string
	Value Actions
}

type AccountAction

type AccountAction struct {
	Tenant, Account, Direction, ActionTimingsTag, ActionTriggersTag string
}

type AccountLock

type AccountLock struct {
	sync.Mutex
	// contains filtered or unexported fields
}
var AccLock *AccountLock

func NewAccountLock

func NewAccountLock() *AccountLock

func (*AccountLock) Guard

func (cm *AccountLock) Guard(name string, handler func() (float64, error)) (reply float64, err error)

func (*AccountLock) GuardGetCost

func (cm *AccountLock) GuardGetCost(name string, handler func() (*CallCost, error)) (reply *CallCost, err error)

type Action

type Action struct {
	Id                       string
	ActionType               string
	BalanceId                string
	Direction                string
	ExpirationString         string
	ExpirationDate           time.Time
	Units                    float64
	Weight                   float64
	MinuteBucket             *MinuteBucket
	DestinationTag, RateType string // From here for import/load purposes only
	RateValue, MinutesWeight float64
}

Structure to be filled for each tariff plan with the bonus value for received calls minutes.

type ActionTiming

type ActionTiming struct {
	Id             string // uniquely identify the timing
	Tag            string // informative purpose only
	UserBalanceIds []string
	Timing         *Interval
	Weight         float64
	ActionsId      string

	ActionsTag, TimingsTag string // used only for loading
	// contains filtered or unexported fields
}

func (*ActionTiming) CheckForASAP

func (at *ActionTiming) CheckForASAP() bool

checks for *asap string as start time and replaces it wit an actual time in the newar future returns true if the *asap string was found

func (*ActionTiming) Execute

func (at *ActionTiming) Execute() (err error)

func (*ActionTiming) GetNextStartTime

func (at *ActionTiming) GetNextStartTime() (t time.Time)

func (*ActionTiming) IsOneTimeRun

func (at *ActionTiming) IsOneTimeRun() bool

returns true if only the starting time was is filled in the Timing field

func (*ActionTiming) SetActions

func (at *ActionTiming) SetActions(as Actions)

func (*ActionTiming) String

func (at *ActionTiming) String() string

type ActionTimingPriotityList

type ActionTimingPriotityList []*ActionTiming

Structure to store actions according to weight

func (ActionTimingPriotityList) Len

func (atpl ActionTimingPriotityList) Len() int

func (ActionTimingPriotityList) Less

func (atpl ActionTimingPriotityList) Less(i, j int) bool

func (ActionTimingPriotityList) Sort

func (atpl ActionTimingPriotityList) Sort()

func (ActionTimingPriotityList) Swap

func (atpl ActionTimingPriotityList) Swap(i, j int)

type ActionTimings

type ActionTimings []*ActionTiming

type ActionTrigger

type ActionTrigger struct {
	Id             string // uniquely identify the trigger
	BalanceId      string
	Direction      string
	ThresholdType  string
	ThresholdValue float64
	DestinationId  string
	Weight         float64
	ActionsId      string
	Executed       bool
}

func (*ActionTrigger) Execute

func (at *ActionTrigger) Execute(ub *UserBalance) (err error)

type ActionTriggerPriotityList

type ActionTriggerPriotityList []*ActionTrigger

Structure to store actions according to weight

func (ActionTriggerPriotityList) Len

func (atpl ActionTriggerPriotityList) Len() int

func (ActionTriggerPriotityList) Less

func (atpl ActionTriggerPriotityList) Less(i, j int) bool

func (ActionTriggerPriotityList) Sort

func (atpl ActionTriggerPriotityList) Sort()

func (ActionTriggerPriotityList) Swap

func (atpl ActionTriggerPriotityList) Swap(i, j int)

type Actions

type Actions []*Action

Structure to store actions according to weight

func (Actions) Len

func (apl Actions) Len() int

func (Actions) Less

func (apl Actions) Less(i, j int) bool

func (Actions) Sort

func (apl Actions) Sort()

func (Actions) Swap

func (apl Actions) Swap(i, j int)

type ActivationPeriod

type ActivationPeriod struct {
	ActivationTime time.Time
	Intervals      IntervalList
}

The struture that is saved to storage.

func (*ActivationPeriod) AddInterval

func (ap *ActivationPeriod) AddInterval(is ...*Interval)

Adds one ore more intervals to the internal interval list only if it is not allready in the list.

func (*ActivationPeriod) Equal

func (ap *ActivationPeriod) Equal(o *ActivationPeriod) bool

type AtKeyValue

type AtKeyValue struct {
	Key   string
	Value ActionTimings
}

type BSONMarshaler

type BSONMarshaler struct{}

func (*BSONMarshaler) Marshal

func (jm *BSONMarshaler) Marshal(v interface{}) ([]byte, error)

func (*BSONMarshaler) Unmarshal

func (jm *BSONMarshaler) Unmarshal(data []byte, v interface{}) error

type Balance

type Balance struct {
	Id             string
	Value          float64
	ExpirationDate time.Time
	Weight         float64
}

func (*Balance) Clone

func (b *Balance) Clone() *Balance

func (*Balance) Equal

func (b *Balance) Equal(o *Balance) bool

func (*Balance) IsExpired

func (b *Balance) IsExpired() bool

type BalanceChain

type BalanceChain []*Balance

Structure to store minute buckets according to weight, precision or price.

func (BalanceChain) Clone

func (bc BalanceChain) Clone() BalanceChain

func (BalanceChain) Debit

func (bc BalanceChain) Debit(amount float64) float64

func (BalanceChain) Equal

func (bc BalanceChain) Equal(o BalanceChain) bool

func (BalanceChain) GetTotalValue

func (bc BalanceChain) GetTotalValue() (total float64)

func (BalanceChain) Len

func (bc BalanceChain) Len() int

func (BalanceChain) Less

func (bc BalanceChain) Less(j, i int) bool

func (BalanceChain) Sort

func (bc BalanceChain) Sort()

func (BalanceChain) Swap

func (bc BalanceChain) Swap(i, j int)

type BincMarshaler

type BincMarshaler struct {
	// contains filtered or unexported fields
}

func NewBincMarshaler

func NewBincMarshaler() *BincMarshaler

func (*BincMarshaler) Marshal

func (bm *BincMarshaler) Marshal(v interface{}) (b []byte, err error)

func (*BincMarshaler) Unmarshal

func (bm *BincMarshaler) Unmarshal(data []byte, v interface{}) error

type CSVReader

type CSVReader struct {
	// contains filtered or unexported fields
}

func NewFileCSVReader

func NewFileCSVReader(storage DataStorage, sep rune, destinationsFn, timingsFn, ratesFn, destinationratesFn, destinationratetimingsFn, ratingprofilesFn, actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn string) *CSVReader

func NewStringCSVReader

func NewStringCSVReader(storage DataStorage, sep rune, destinationsFn, timingsFn, ratesFn, destinationratesFn, destinationratetimingsFn, ratingprofilesFn, actionsFn, actiontimingsFn, actiontriggersFn, accountactionsFn string) *CSVReader

func (*CSVReader) LoadAccountActions

func (csvr *CSVReader) LoadAccountActions() (err error)

func (*CSVReader) LoadActionTimings

func (csvr *CSVReader) LoadActionTimings() (err error)

func (*CSVReader) LoadActionTriggers

func (csvr *CSVReader) LoadActionTriggers() (err error)

func (*CSVReader) LoadActions

func (csvr *CSVReader) LoadActions() (err error)

func (*CSVReader) LoadDestinationRateTimings

func (csvr *CSVReader) LoadDestinationRateTimings() (err error)

func (*CSVReader) LoadDestinationRates

func (csvr *CSVReader) LoadDestinationRates() (err error)

func (*CSVReader) LoadDestinations

func (csvr *CSVReader) LoadDestinations() (err error)

func (*CSVReader) LoadRates

func (csvr *CSVReader) LoadRates() (err error)

func (*CSVReader) LoadRatingProfiles

func (csvr *CSVReader) LoadRatingProfiles() (err error)

func (*CSVReader) LoadTimings

func (csvr *CSVReader) LoadTimings() (err error)

func (*CSVReader) WriteToDatabase

func (csvr *CSVReader) WriteToDatabase(flush, verbose bool) (err error)

type CallCost

type CallCost struct {
	Direction, TOR, Tenant, Subject, Account, Destination string
	Cost, ConnectFee                                      float64
	Timespans                                             []*TimeSpan
}

The output structure that will be returned with the call cost information.

func (*CallCost) GetStartTime

func (cc *CallCost) GetStartTime() time.Time

func (*CallCost) Merge

func (cc *CallCost) Merge(other *CallCost)

Merges the received timespan if they are similar (same activation period, same interval, same minute info.

func (*CallCost) String

func (cc *CallCost) String() (r string)

Pretty printing for call cost

type CallDescriptor

type CallDescriptor struct {
	Direction                             string
	TOR                                   string
	Tenant, Subject, Account, Destination string
	TimeStart, TimeEnd                    time.Time
	LoopIndex                             float64       // indicates the postion of this segment in a cost request loop
	CallDuration                          time.Duration // the call duration so far (partial or final)
	Amount                                float64
	FallbackSubject                       string // the subject to check for destination if not found on primary subject
	ActivationPeriods                     []*ActivationPeriod
	// contains filtered or unexported fields
}

The input stucture that contains call information.

func (*CallDescriptor) AddActivationPeriod

func (cd *CallDescriptor) AddActivationPeriod(aps ...*ActivationPeriod)

Adds an activation period that applyes to current call descriptor.

func (*CallDescriptor) AddRecievedCallSeconds

func (cd *CallDescriptor) AddRecievedCallSeconds() (err error)

Adds the specified amount of seconds to the received call seconds. When the threshold specified in the user's tariff plan is reached then the received call balance is reseted and the bonus specified in the tariff plan is applied. The amount filed has to be filled in call descriptor.

func (*CallDescriptor) Debit

func (cd *CallDescriptor) Debit() (cc *CallCost, err error)

Interface method used to add/substract an amount of cents or bonus seconds (as returned by GetCost method) from user's money balance.

func (*CallDescriptor) DebitCents

func (cd *CallDescriptor) DebitCents() (left float64, err error)

Interface method used to add/substract an amount of cents from user's money balance. The amount filed has to be filled in call descriptor.

func (*CallDescriptor) DebitSMS

func (cd *CallDescriptor) DebitSMS() (left float64, err error)

Interface method used to add/substract an amount of units from user's sms balance. The amount filed has to be filled in call descriptor.

func (*CallDescriptor) DebitSeconds

func (cd *CallDescriptor) DebitSeconds() (err error)

Interface method used to add/substract an amount of seconds from user's minutes balance. The amount filed has to be filled in call descriptor.

func (*CallDescriptor) FlushCache

func (cd *CallDescriptor) FlushCache() (err error)

Cleans all chached data

func (*CallDescriptor) GetCost

func (cd *CallDescriptor) GetCost() (*CallCost, error)

Creates a CallCost structure with the cost information calculated for the received CallDescriptor.

func (*CallDescriptor) GetKey

func (cd *CallDescriptor) GetKey() string

Constructs the key for the storage lookup. The prefixLen is limiting the length of the destination prefix.

func (*CallDescriptor) GetMaxSessionTime

func (cd *CallDescriptor) GetMaxSessionTime(startTime time.Time) (seconds float64, err error)

Returns the approximate max allowed session for user balance. It will try the max amount received in the call descriptor and will decrease it by 10% for nine times. So if the user has little credit it will still allow 10% of the initial amount. If the user has no credit then it will return 0. If the user has postpayed plan it returns -1.

func (*CallDescriptor) GetUserBalanceKey

func (cd *CallDescriptor) GetUserBalanceKey() string

Returns the key used to retrive the user balance involved in this call

func (*CallDescriptor) LoadActivationPeriods

func (cd *CallDescriptor) LoadActivationPeriods() (destPrefix string, err error)

Restores the activation periods for the specified prefix from storage.

func (*CallDescriptor) MaxDebit

func (cd *CallDescriptor) MaxDebit(startTime time.Time) (cc *CallCost, err error)

Interface method used to add/substract an amount of cents or bonus seconds (as returned by GetCost method) from user's money balance. This methods combines the Debit and GetMaxSessionTime and will debit the max available time as returned by the GetMaxSessionTime method. The amount filed has to be filled in call descriptor.

type CodecMsgpackMarshaler

type CodecMsgpackMarshaler struct {
	// contains filtered or unexported fields
}

func NewCodecMsgpackMarshaler

func NewCodecMsgpackMarshaler() *CodecMsgpackMarshaler

func (*CodecMsgpackMarshaler) Marshal

func (cmm *CodecMsgpackMarshaler) Marshal(v interface{}) (b []byte, err error)

func (*CodecMsgpackMarshaler) Unmarshal

func (cmm *CodecMsgpackMarshaler) Unmarshal(data []byte, v interface{}) error

type Connector

type Connector interface {
	GetCost(CallDescriptor, *CallCost) error
	Debit(CallDescriptor, *CallCost) error
	MaxDebit(CallDescriptor, *CallCost) error
	DebitCents(CallDescriptor, *float64) error
	DebitSeconds(CallDescriptor, *float64) error
	GetMaxSessionTime(CallDescriptor, *float64) error
}

type DataStorage

type DataStorage interface {
	Close()
	Flush() error
	GetRatingProfile(string) (*RatingProfile, error)
	SetRatingProfile(*RatingProfile) error
	GetDestination(string) (*Destination, error)
	SetDestination(*Destination) error
	// Apier functions
	GetTPIds() ([]string, error)
	SetTPTiming(string, *Timing) error
	ExistsTPTiming(string, string) (bool, error)
	GetTPTiming(string, string) (*Timing, error)
	GetTPTimingIds(string) ([]string, error)
	SetTPDestination(string, *Destination) error
	ExistsTPDestination(string, string) (bool, error)
	GetTPDestination(string, string) (*Destination, error)
	GetTPDestinationIds(string) ([]string, error)
	ExistsTPRate(string, string) (bool, error)
	SetTPRates(string, map[string][]*Rate) error
	GetTPRate(string, string) (*utils.TPRate, error)
	GetTPRateIds(string) ([]string, error)
	ExistsTPDestinationRate(string, string) (bool, error)
	SetTPDestinationRates(string, map[string][]*DestinationRate) error
	GetTPDestinationRate(string, string) (*utils.TPDestinationRate, error)
	GetTPDestinationRateIds(string) ([]string, error)
	ExistsTPDestRateTiming(string, string) (bool, error)
	SetTPDestRateTimings(string, map[string][]*DestinationRateTiming) error
	GetTPDestRateTiming(string, string) (*utils.TPDestRateTiming, error)
	GetTPDestRateTimingIds(string) ([]string, error)
	ExistsTPRatingProfile(string, string) (bool, error)
	SetTPRatingProfiles(string, map[string][]*RatingProfile) error
	GetTPRatingProfile(string, string) (*utils.TPRatingProfile, error)
	GetTPRatingProfileIds(*utils.AttrTPRatingProfileIds) ([]string, error)
	ExistsTPActions(string, string) (bool, error)
	SetTPActions(string, map[string][]*Action) error
	GetTPActions(string, string) (*utils.TPActions, error)
	GetTPActionIds(string) ([]string, error)
	ExistsTPActionTimings(string, string) (bool, error)
	SetTPActionTimings(string, map[string][]*ActionTiming) error
	GetTPActionTimings(string, string) (map[string][]*utils.TPActionTimingsRow, error)
	GetTPActionTimingIds(string) ([]string, error)
	ExistsTPActionTriggers(string, string) (bool, error)
	SetTPActionTriggers(string, map[string][]*ActionTrigger) error
	GetTPActionTriggerIds(string) ([]string, error)
	ExistsTPAccountActions(string, string) (bool, error)
	SetTPAccountActions(string, map[string]*AccountAction) error
	GetTPAccountActionIds(string) ([]string, error)
	// End Apier functions
	GetActions(string) (Actions, error)
	SetActions(string, Actions) error
	GetUserBalance(string) (*UserBalance, error)
	SetUserBalance(*UserBalance) error
	GetActionTimings(string) (ActionTimings, error)
	SetActionTimings(string, ActionTimings) error
	GetAllActionTimings() (map[string]ActionTimings, error)
	SetCdr(utils.CDR) error
	SetRatedCdr(utils.CDR, *CallCost, string) error
	GetAllRatedCdr() ([]utils.CDR, error)
	//GetAllActionTimingsLogs() (map[string]ActionsTimings, error)
	LogCallCost(uuid, source string, cc *CallCost) error
	LogError(uuid, source, errstr string) error
	LogActionTrigger(ubId, source string, at *ActionTrigger, as Actions) error
	LogActionTiming(source string, at *ActionTiming, as Actions) error
	GetCallCostLog(uuid, source string) (*CallCost, error)
	// loader functions
	GetTpDestinations(string, string) ([]*Destination, error)
	GetTpTimings(string, string) (map[string]*Timing, error)
	GetTpRates(string, string) (map[string]*Rate, error)
	GetTpDestinationRates(string, string) (map[string][]*DestinationRate, error)
	GetTpDestinationRateTimings(string, string) ([]*DestinationRateTiming, error)
	GetTpRatingProfiles(string, string) (map[string]*RatingProfile, error)
	GetTpActions(string, string) (map[string][]*Action, error)
	GetTpActionTimings(string, string) (map[string][]*ActionTiming, error)
	GetTpActionTriggers(string, string) (map[string][]*ActionTrigger, error)
	GetTpAccountActions(string, string) (map[string]*AccountAction, error)
}

Interface for storage providers.

func ConfigureDatabase

func ConfigureDatabase(db_type, host, port, name, user, pass string) (db DataStorage, err error)

func NewMapStorage

func NewMapStorage() (DataStorage, error)

func NewMongoStorage

func NewMongoStorage(host, port, db, user, pass string) (DataStorage, error)

func NewMySQLStorage

func NewMySQLStorage(host, port, name, user, password string) (DataStorage, error)

func NewPostgresStorage

func NewPostgresStorage(host, port, name, user, password string) (DataStorage, error)

func NewRedisStorage

func NewRedisStorage(address string, db int, pass string) (DataStorage, error)

type DbReader

type DbReader struct {
	// contains filtered or unexported fields
}

func NewDbReader

func NewDbReader(storDB DataStorage, storage DataStorage, tpid string) *DbReader

func (*DbReader) LoadAccountActions

func (dbr *DbReader) LoadAccountActions() (err error)

func (*DbReader) LoadAccountActionsByTag

func (dbr *DbReader) LoadAccountActionsByTag(tag string) error

func (*DbReader) LoadActionTimings

func (dbr *DbReader) LoadActionTimings() (err error)

func (*DbReader) LoadActionTriggers

func (dbr *DbReader) LoadActionTriggers() (err error)

func (*DbReader) LoadActions

func (dbr *DbReader) LoadActions() (err error)

func (*DbReader) LoadDestinationRateTimings

func (dbr *DbReader) LoadDestinationRateTimings() error

func (*DbReader) LoadDestinationRates

func (dbr *DbReader) LoadDestinationRates() (err error)

func (*DbReader) LoadDestinations

func (dbr *DbReader) LoadDestinations() (err error)

func (*DbReader) LoadRates

func (dbr *DbReader) LoadRates() (err error)

func (*DbReader) LoadRatingProfileByTag

func (dbr *DbReader) LoadRatingProfileByTag(tag string) error

func (*DbReader) LoadRatingProfiles

func (dbr *DbReader) LoadRatingProfiles() error

func (*DbReader) LoadTimings

func (dbr *DbReader) LoadTimings() (err error)

func (*DbReader) WriteToDatabase

func (dbr *DbReader) WriteToDatabase(flush, verbose bool) (err error)

type Destination

type Destination struct {
	Id       string
	Prefixes []string
}

Structure that gathers multiple destination prefixes under a common id.

func GetDestination

func GetDestination(dId string) (d *Destination, err error)

Gets the specified destination from the storage and caches it.

func (*Destination) String

func (d *Destination) String() (result string)

type DestinationRate

type DestinationRate struct {
	Tag             string
	DestinationsTag string
	RateTag         string
	Rate            *Rate
}

type DestinationRateTiming

type DestinationRateTiming struct {
	Tag                 string
	DestinationRatesTag string
	Weight              float64
	TimingsTag          string // intermediary used when loading from db
	// contains filtered or unexported fields
}

func NewDestinationRateTiming

func NewDestinationRateTiming(destinationRatesTag string, timing *Timing, weight string) (rt *DestinationRateTiming)

func (*DestinationRateTiming) GetInterval

func (rt *DestinationRateTiming) GetInterval(dr *DestinationRate) (i *Interval)

type FileLineRegexValidator

type FileLineRegexValidator struct {
	FieldsPerRecord int            // Number of fields in one record, useful for crosschecks
	Rule            *regexp.Regexp // Regexp rule
	Message         string         // Pass this message as helper
}

type GOBMarshaler

type GOBMarshaler struct{}

func (*GOBMarshaler) Marshal

func (gm *GOBMarshaler) Marshal(v interface{}) (data []byte, err error)

func (*GOBMarshaler) Unmarshal

func (gm *GOBMarshaler) Unmarshal(data []byte, v interface{}) error

type Interval

type Interval struct {
	Years              Years
	Months             Months
	MonthDays          MonthDays
	WeekDays           WeekDays
	StartTime, EndTime string // ##:##:## format
	Weight, ConnectFee float64
	Prices             PriceGroups // GroupInterval (start time): Price
	RoundingMethod     string
	RoundingDecimals   int
}

Defines a time interval for which a certain set of prices will apply

func (*Interval) Contains

func (i *Interval) Contains(t time.Time) bool

Returns true if the received time result inside the interval

func (*Interval) Equal

func (i *Interval) Equal(o *Interval) bool

func (*Interval) GetCost

func (i *Interval) GetCost(duration, startSecond time.Duration) (cost float64)

func (*Interval) GetPriceParameters

func (i *Interval) GetPriceParameters(startSecond time.Duration) (price float64, rateIncrement, rateUnit time.Duration)

Gets the price for a the provided start second

func (*Interval) String

func (i *Interval) String() string

type IntervalList

type IntervalList []*Interval

Structure to store intervals according to weight

func (IntervalList) Len

func (il IntervalList) Len() int

func (IntervalList) Less

func (il IntervalList) Less(i, j int) bool

func (IntervalList) Sort

func (il IntervalList) Sort()

func (IntervalList) Swap

func (il IntervalList) Swap(i, j int)

type JSONBufMarshaler

type JSONBufMarshaler struct{}

func (*JSONBufMarshaler) Marshal

func (jbm *JSONBufMarshaler) Marshal(v interface{}) (data []byte, err error)

func (*JSONBufMarshaler) Unmarshal

func (jbm *JSONBufMarshaler) Unmarshal(data []byte, v interface{}) error

type JSONMarshaler

type JSONMarshaler struct{}

func (*JSONMarshaler) Marshal

func (jm *JSONMarshaler) Marshal(v interface{}) ([]byte, error)

func (*JSONMarshaler) Unmarshal

func (jm *JSONMarshaler) Unmarshal(data []byte, v interface{}) error

type LogCostEntry

type LogCostEntry struct {
	Id       string `bson:"_id,omitempty"`
	CallCost *CallCost
	Source   string
}

type LogErrEntry

type LogErrEntry struct {
	Id     string `bson:"_id,omitempty"`
	ErrStr string
	Source string
}

type LogTimingEntry

type LogTimingEntry struct {
	ActionTiming *ActionTiming
	Actions      Actions
	LogTime      time.Time
	Source       string
}

type LogTriggerEntry

type LogTriggerEntry struct {
	ActionTrigger *ActionTrigger
	Actions       Actions
	LogTime       time.Time
	Source        string
	// contains filtered or unexported fields
}

type MapStorage

type MapStorage struct {
	// contains filtered or unexported fields
}

func (*MapStorage) Close

func (ms *MapStorage) Close()

func (*MapStorage) ExistsTPAccountActions

func (ms *MapStorage) ExistsTPAccountActions(tpid, aaId string) (bool, error)

func (*MapStorage) ExistsTPActionTimings

func (ms *MapStorage) ExistsTPActionTimings(tpid, atId string) (bool, error)

func (*MapStorage) ExistsTPActionTriggers

func (ms *MapStorage) ExistsTPActionTriggers(tpid, atId string) (bool, error)

func (*MapStorage) ExistsTPActions

func (ms *MapStorage) ExistsTPActions(tpid, aId string) (bool, error)

func (*MapStorage) ExistsTPDestRateTiming

func (ms *MapStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error)

func (*MapStorage) ExistsTPDestination

func (ms *MapStorage) ExistsTPDestination(tpid, destTag string) (bool, error)

func (*MapStorage) ExistsTPDestinationRate

func (ms *MapStorage) ExistsTPDestinationRate(tpid, drId string) (bool, error)

func (*MapStorage) ExistsTPRate

func (ms *MapStorage) ExistsTPRate(tpid, rtId string) (bool, error)

func (*MapStorage) ExistsTPRatingProfile

func (ms *MapStorage) ExistsTPRatingProfile(tpid, rpId string) (bool, error)

func (*MapStorage) ExistsTPTiming

func (ms *MapStorage) ExistsTPTiming(tpid, tmId string) (bool, error)

func (*MapStorage) Flush

func (ms *MapStorage) Flush() error

func (*MapStorage) GetActionTimings

func (ms *MapStorage) GetActionTimings(key string) (ats ActionTimings, err error)

func (*MapStorage) GetActions

func (ms *MapStorage) GetActions(key string) (as Actions, err error)

func (*MapStorage) GetAllActionTimings

func (ms *MapStorage) GetAllActionTimings() (ats map[string]ActionTimings, err error)

func (*MapStorage) GetAllRatedCdr

func (ms *MapStorage) GetAllRatedCdr() ([]utils.CDR, error)

func (*MapStorage) GetCallCostLog

func (ms *MapStorage) GetCallCostLog(uuid, source string) (cc *CallCost, err error)

func (*MapStorage) GetDestination

func (ms *MapStorage) GetDestination(key string) (dest *Destination, err error)

func (*MapStorage) GetRatingProfile

func (ms *MapStorage) GetRatingProfile(key string) (rp *RatingProfile, err error)

func (*MapStorage) GetTPAccountActionIds

func (ms *MapStorage) GetTPAccountActionIds(tpid string) ([]string, error)

func (*MapStorage) GetTPActionIds

func (ms *MapStorage) GetTPActionIds(tpid string) ([]string, error)

func (*MapStorage) GetTPActionTimingIds

func (ms *MapStorage) GetTPActionTimingIds(tpid string) ([]string, error)

func (*MapStorage) GetTPActionTimings

func (ms *MapStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTimingsRow, error)

func (*MapStorage) GetTPActionTriggerIds

func (ms *MapStorage) GetTPActionTriggerIds(tpid string) ([]string, error)

func (*MapStorage) GetTPActions

func (ms *MapStorage) GetTPActions(tpid, aId string) (*utils.TPActions, error)

func (*MapStorage) GetTPDestRateTiming

func (ms *MapStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error)

func (*MapStorage) GetTPDestRateTimingIds

func (ms *MapStorage) GetTPDestRateTimingIds(tpid string) ([]string, error)

func (*MapStorage) GetTPDestination

func (ms *MapStorage) GetTPDestination(tpid, destTag string) (*Destination, error)

func (*MapStorage) GetTPDestinationIds

func (ms *MapStorage) GetTPDestinationIds(tpid string) ([]string, error)

func (*MapStorage) GetTPDestinationRate

func (ms *MapStorage) GetTPDestinationRate(tpid, drId string) (*utils.TPDestinationRate, error)

func (*MapStorage) GetTPDestinationRateIds

func (ms *MapStorage) GetTPDestinationRateIds(tpid string) ([]string, error)

func (*MapStorage) GetTPIds

func (ms *MapStorage) GetTPIds() ([]string, error)

func (*MapStorage) GetTPRate

func (ms *MapStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error)

func (*MapStorage) GetTPRateIds

func (ms *MapStorage) GetTPRateIds(tpid string) ([]string, error)

func (*MapStorage) GetTPRatingProfile

func (ms *MapStorage) GetTPRatingProfile(tpid, rpId string) (*utils.TPRatingProfile, error)

func (*MapStorage) GetTPRatingProfileIds

func (ms *MapStorage) GetTPRatingProfileIds(filters *utils.AttrTPRatingProfileIds) ([]string, error)

func (*MapStorage) GetTPTiming

func (ms *MapStorage) GetTPTiming(tpid, tmId string) (*Timing, error)

func (*MapStorage) GetTPTimingIds

func (ms *MapStorage) GetTPTimingIds(tpid string) ([]string, error)

func (*MapStorage) GetTpAccountActions

func (ms *MapStorage) GetTpAccountActions(tpid, tag string) (map[string]*AccountAction, error)

func (*MapStorage) GetTpActionTimings

func (ms *MapStorage) GetTpActionTimings(tpid, tag string) (map[string][]*ActionTiming, error)

func (*MapStorage) GetTpActionTriggers

func (ms *MapStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*ActionTrigger, error)

func (*MapStorage) GetTpActions

func (ms *MapStorage) GetTpActions(tpid, tag string) (map[string][]*Action, error)

func (*MapStorage) GetTpDestinationRateTimings

func (ms *MapStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error)

func (*MapStorage) GetTpDestinationRates

func (ms *MapStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error)

func (*MapStorage) GetTpDestinations

func (ms *MapStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error)

func (*MapStorage) GetTpRates

func (ms *MapStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error)

func (*MapStorage) GetTpRatingProfiles

func (ms *MapStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error)

func (*MapStorage) GetTpTimings

func (ms *MapStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error)

func (*MapStorage) GetUserBalance

func (ms *MapStorage) GetUserBalance(key string) (ub *UserBalance, err error)

func (*MapStorage) LogActionTiming

func (ms *MapStorage) LogActionTiming(source string, at *ActionTiming, as Actions) (err error)

func (*MapStorage) LogActionTrigger

func (ms *MapStorage) LogActionTrigger(ubId, source string, at *ActionTrigger, as Actions) (err error)

func (*MapStorage) LogCallCost

func (ms *MapStorage) LogCallCost(uuid, source string, cc *CallCost) error

func (*MapStorage) LogError

func (ms *MapStorage) LogError(uuid, source, errstr string) (err error)

func (*MapStorage) SetActionTimings

func (ms *MapStorage) SetActionTimings(key string, ats ActionTimings) (err error)

func (*MapStorage) SetActions

func (ms *MapStorage) SetActions(key string, as Actions) (err error)

func (*MapStorage) SetCdr

func (ms *MapStorage) SetCdr(utils.CDR) error

func (*MapStorage) SetDestination

func (ms *MapStorage) SetDestination(dest *Destination) (err error)

func (*MapStorage) SetRatedCdr

func (ms *MapStorage) SetRatedCdr(cdr utils.CDR, cc *CallCost, extraInfo string) error

func (*MapStorage) SetRatingProfile

func (ms *MapStorage) SetRatingProfile(rp *RatingProfile) (err error)

func (*MapStorage) SetTPAccountActions

func (ms *MapStorage) SetTPAccountActions(tpid string, aa map[string]*AccountAction) error

func (*MapStorage) SetTPActionTimings

func (ms *MapStorage) SetTPActionTimings(tpid string, ats map[string][]*ActionTiming) error

func (*MapStorage) SetTPActionTriggers

func (ms *MapStorage) SetTPActionTriggers(tpid string, ats map[string][]*ActionTrigger) error

func (*MapStorage) SetTPActions

func (ms *MapStorage) SetTPActions(tpid string, acts map[string][]*Action) error

func (*MapStorage) SetTPDestRateTimings

func (ms *MapStorage) SetTPDestRateTimings(tpid string, drts map[string][]*DestinationRateTiming) error

func (*MapStorage) SetTPDestination

func (ms *MapStorage) SetTPDestination(tpid string, dest *Destination) error

func (*MapStorage) SetTPDestinationRates

func (ms *MapStorage) SetTPDestinationRates(tpid string, drs map[string][]*DestinationRate) error

func (*MapStorage) SetTPRates

func (ms *MapStorage) SetTPRates(tpid string, rts map[string][]*Rate) error

func (*MapStorage) SetTPRatingProfiles

func (ms *MapStorage) SetTPRatingProfiles(tpid string, rps map[string][]*RatingProfile) error

func (*MapStorage) SetTPTiming

func (ms *MapStorage) SetTPTiming(tpid string, tm *Timing) error

func (*MapStorage) SetUserBalance

func (ms *MapStorage) SetUserBalance(ub *UserBalance) (err error)

type Marshaler

type Marshaler interface {
	Marshal(v interface{}) ([]byte, error)
	Unmarshal(data []byte, v interface{}) error
}

type MinuteBucket

type MinuteBucket struct {
	Seconds        float64
	Weight         float64
	Price          float64 // percentage from standard price or absolute value depending on Type
	PriceType      string
	DestinationId  string
	ExpirationDate time.Time
	// contains filtered or unexported fields
}

func (*MinuteBucket) Clone

func (mb *MinuteBucket) Clone() *MinuteBucket

Creates a similar minute

func (*MinuteBucket) Equal

func (mb *MinuteBucket) Equal(o *MinuteBucket) bool

Equal method

func (*MinuteBucket) GetSecondsForCredit

func (mb *MinuteBucket) GetSecondsForCredit(credit float64) (seconds float64)

Returns the available number of seconds for a specified credit

func (*MinuteBucket) IsExpired

func (mb *MinuteBucket) IsExpired() bool

type MinuteInfo

type MinuteInfo struct {
	DestinationId string
	Quantity      float64
	Price         float64
}

Holds the bonus minute information related to a specified timespan

type MongoStorage

type MongoStorage struct {
	// contains filtered or unexported fields
}

func (*MongoStorage) Close

func (ms *MongoStorage) Close()

func (*MongoStorage) ExistsTPAccountActions

func (ms *MongoStorage) ExistsTPAccountActions(tpid, aaId string) (bool, error)

func (*MongoStorage) ExistsTPActionTimings

func (ms *MongoStorage) ExistsTPActionTimings(tpid, atId string) (bool, error)

func (*MongoStorage) ExistsTPActionTriggers

func (ms *MongoStorage) ExistsTPActionTriggers(tpid, atId string) (bool, error)

func (*MongoStorage) ExistsTPActions

func (ms *MongoStorage) ExistsTPActions(tpid, aId string) (bool, error)

func (*MongoStorage) ExistsTPDestRateTiming

func (ms *MongoStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error)

func (*MongoStorage) ExistsTPDestination

func (ms *MongoStorage) ExistsTPDestination(tpid, destTag string) (bool, error)

func (*MongoStorage) ExistsTPDestinationRate

func (ms *MongoStorage) ExistsTPDestinationRate(tpid, drId string) (bool, error)

func (*MongoStorage) ExistsTPRate

func (ms *MongoStorage) ExistsTPRate(tpid, rtId string) (bool, error)

func (*MongoStorage) ExistsTPRatingProfile

func (ms *MongoStorage) ExistsTPRatingProfile(tpid, rpId string) (bool, error)

func (*MongoStorage) ExistsTPTiming

func (ms *MongoStorage) ExistsTPTiming(tpid, tmId string) (bool, error)

func (*MongoStorage) Flush

func (ms *MongoStorage) Flush() (err error)

func (*MongoStorage) GetActionTimings

func (ms *MongoStorage) GetActionTimings(key string) (ats ActionTimings, err error)

func (*MongoStorage) GetActions

func (ms *MongoStorage) GetActions(key string) (as Actions, err error)

func (*MongoStorage) GetAllActionTimings

func (ms *MongoStorage) GetAllActionTimings() (ats map[string]ActionTimings, err error)

func (*MongoStorage) GetAllRatedCdr

func (ms *MongoStorage) GetAllRatedCdr() ([]utils.CDR, error)

func (*MongoStorage) GetCallCostLog

func (ms *MongoStorage) GetCallCostLog(uuid, source string) (cc *CallCost, err error)

func (*MongoStorage) GetDestination

func (ms *MongoStorage) GetDestination(key string) (result *Destination, err error)

func (*MongoStorage) GetDestinations

func (ms *MongoStorage) GetDestinations(tpid string) ([]*Destination, error)

func (*MongoStorage) GetRatingProfile

func (ms *MongoStorage) GetRatingProfile(key string) (rp *RatingProfile, err error)

func (*MongoStorage) GetTPAccountActionIds

func (ms *MongoStorage) GetTPAccountActionIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPActionIds

func (ms *MongoStorage) GetTPActionIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPActionTimingIds

func (ms *MongoStorage) GetTPActionTimingIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPActionTimings

func (ms *MongoStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTimingsRow, error)

func (*MongoStorage) GetTPActionTriggerIds

func (ms *MongoStorage) GetTPActionTriggerIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPActions

func (ms *MongoStorage) GetTPActions(tpid, aId string) (*utils.TPActions, error)

func (*MongoStorage) GetTPDestRateTiming

func (ms *MongoStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error)

func (*MongoStorage) GetTPDestRateTimingIds

func (ms *MongoStorage) GetTPDestRateTimingIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPDestination

func (ms *MongoStorage) GetTPDestination(tpid, destTag string) (*Destination, error)

Extracts destinations from StorDB on specific tariffplan id

func (*MongoStorage) GetTPDestinationIds

func (ms *MongoStorage) GetTPDestinationIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPDestinationRate

func (ms *MongoStorage) GetTPDestinationRate(tpid, drId string) (*utils.TPDestinationRate, error)

func (*MongoStorage) GetTPDestinationRateIds

func (ms *MongoStorage) GetTPDestinationRateIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPIds

func (ms *MongoStorage) GetTPIds() ([]string, error)

func (*MongoStorage) GetTPRate

func (ms *MongoStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error)

func (*MongoStorage) GetTPRateIds

func (ms *MongoStorage) GetTPRateIds(tpid string) ([]string, error)

func (*MongoStorage) GetTPRatingProfile

func (ms *MongoStorage) GetTPRatingProfile(tpid, rpId string) (*utils.TPRatingProfile, error)

func (*MongoStorage) GetTPRatingProfileIds

func (ms *MongoStorage) GetTPRatingProfileIds(filters *utils.AttrTPRatingProfileIds) ([]string, error)

func (*MongoStorage) GetTPTiming

func (ms *MongoStorage) GetTPTiming(tpid, tmId string) (*Timing, error)

func (*MongoStorage) GetTPTimingIds

func (ms *MongoStorage) GetTPTimingIds(tpid string) ([]string, error)

func (*MongoStorage) GetTpAccountActions

func (ms *MongoStorage) GetTpAccountActions(tpid, tag string) (map[string]*AccountAction, error)

func (*MongoStorage) GetTpActionTimings

func (ms *MongoStorage) GetTpActionTimings(tpid, tag string) (map[string][]*ActionTiming, error)

func (*MongoStorage) GetTpActionTriggers

func (ms *MongoStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*ActionTrigger, error)

func (*MongoStorage) GetTpActions

func (ms *MongoStorage) GetTpActions(tpid, tag string) (map[string][]*Action, error)

func (*MongoStorage) GetTpDestinationRateTimings

func (ms *MongoStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error)

func (*MongoStorage) GetTpDestinationRates

func (ms *MongoStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error)

func (*MongoStorage) GetTpDestinations

func (ms *MongoStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error)

func (*MongoStorage) GetTpRates

func (ms *MongoStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error)

func (*MongoStorage) GetTpRatingProfiles

func (ms *MongoStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error)

func (*MongoStorage) GetTpTimings

func (ms *MongoStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error)

func (*MongoStorage) GetUserBalance

func (ms *MongoStorage) GetUserBalance(key string) (result *UserBalance, err error)

func (*MongoStorage) LogActionTiming

func (ms *MongoStorage) LogActionTiming(source string, at *ActionTiming, as Actions) (err error)

func (*MongoStorage) LogActionTrigger

func (ms *MongoStorage) LogActionTrigger(ubId, source string, at *ActionTrigger, as Actions) (err error)

func (*MongoStorage) LogCallCost

func (ms *MongoStorage) LogCallCost(uuid, source string, cc *CallCost) error

func (*MongoStorage) LogError

func (ms *MongoStorage) LogError(uuid, source, errstr string) (err error)

func (*MongoStorage) SetActionTimings

func (ms *MongoStorage) SetActionTimings(key string, ats ActionTimings) error

func (*MongoStorage) SetActions

func (ms *MongoStorage) SetActions(key string, as Actions) error

func (*MongoStorage) SetCdr

func (ms *MongoStorage) SetCdr(utils.CDR) error

func (*MongoStorage) SetDestination

func (ms *MongoStorage) SetDestination(dest *Destination) error

func (*MongoStorage) SetRatedCdr

func (ms *MongoStorage) SetRatedCdr(cdr utils.CDR, cc *CallCost, extraInfo string) error

func (*MongoStorage) SetRatingProfile

func (ms *MongoStorage) SetRatingProfile(rp *RatingProfile) error

func (*MongoStorage) SetTPAccountActions

func (ms *MongoStorage) SetTPAccountActions(tpid string, aa map[string]*AccountAction) error

func (*MongoStorage) SetTPActionTimings

func (ms *MongoStorage) SetTPActionTimings(tpid string, ats map[string][]*ActionTiming) error

func (*MongoStorage) SetTPActionTriggers

func (ms *MongoStorage) SetTPActionTriggers(tpid string, ats map[string][]*ActionTrigger) error

func (*MongoStorage) SetTPActions

func (ms *MongoStorage) SetTPActions(tpid string, acts map[string][]*Action) error

func (*MongoStorage) SetTPDestRateTimings

func (ms *MongoStorage) SetTPDestRateTimings(tpid string, drts map[string][]*DestinationRateTiming) error

func (*MongoStorage) SetTPDestination

func (ms *MongoStorage) SetTPDestination(tpid string, dest *Destination) error

func (*MongoStorage) SetTPDestinationRates

func (ms *MongoStorage) SetTPDestinationRates(tpid string, drs map[string][]*DestinationRate) error

func (*MongoStorage) SetTPRates

func (ms *MongoStorage) SetTPRates(tpid string, rts map[string][]*Rate) error

func (*MongoStorage) SetTPRatingProfiles

func (ms *MongoStorage) SetTPRatingProfiles(tpid string, rps map[string][]*RatingProfile) error

func (*MongoStorage) SetTPTiming

func (ms *MongoStorage) SetTPTiming(tpid string, tm *Timing) error

func (*MongoStorage) SetUserBalance

func (ms *MongoStorage) SetUserBalance(ub *UserBalance) error

type MonthDays

type MonthDays []int

Defines month days series

func (MonthDays) Contains

func (md MonthDays) Contains(monthDay int) (result bool)

Return true if the specified date is inside the series

func (MonthDays) Len

func (md MonthDays) Len() int

func (MonthDays) Less

func (md MonthDays) Less(j, i int) bool

func (*MonthDays) Parse

func (md *MonthDays) Parse(input, sep string)

Parse MonthDay elements from string separated by sep.

func (MonthDays) Serialize

func (md MonthDays) Serialize(sep string) string

Dumps the month days in a serialized string, similar to the one parsed

func (MonthDays) Sort

func (md MonthDays) Sort()

func (MonthDays) Swap

func (md MonthDays) Swap(i, j int)

type Months

type Months []time.Month

Defines months series

func (Months) Contains

func (m Months) Contains(month time.Month) (result bool)

Return true if the specified date is inside the series

func (Months) Len

func (m Months) Len() int

func (Months) Less

func (m Months) Less(j, i int) bool

func (*Months) Parse

func (m *Months) Parse(input, sep string)

Loades Month elemnents from a string separated by sep.

func (Months) Serialize

func (m Months) Serialize(sep string) string

Dumps the months in a serialized string, similar to the one parsed

func (Months) Sort

func (m Months) Sort()

func (Months) Swap

func (m Months) Swap(i, j int)

type MySQLStorage

type MySQLStorage struct {
	*SQLStorage
}

type PostgresStorage

type PostgresStorage struct {
	*SQLStorage
}

type Price

type Price struct {
	GroupIntervalStart time.Duration
	Value              float64
	RateIncrement      time.Duration
	RateUnit           time.Duration
}

func (*Price) Equal

func (p *Price) Equal(o *Price) bool

type PriceGroups

type PriceGroups []*Price

func (*PriceGroups) AddPrice

func (pg *PriceGroups) AddPrice(ps ...*Price)

func (PriceGroups) Equal

func (pg PriceGroups) Equal(og PriceGroups) bool

func (PriceGroups) Len

func (pg PriceGroups) Len() int

func (PriceGroups) Less

func (pg PriceGroups) Less(i, j int) bool

func (PriceGroups) Sort

func (pg PriceGroups) Sort()

func (PriceGroups) Swap

func (pg PriceGroups) Swap(i, j int)

type RPCClientConnector

type RPCClientConnector struct {
	Client *rpc.Client
}

func (*RPCClientConnector) Debit

func (rcc *RPCClientConnector) Debit(cd CallDescriptor, cc *CallCost) error

func (*RPCClientConnector) DebitCents

func (rcc *RPCClientConnector) DebitCents(cd CallDescriptor, resp *float64) error

func (*RPCClientConnector) DebitSeconds

func (rcc *RPCClientConnector) DebitSeconds(cd CallDescriptor, resp *float64) error

func (*RPCClientConnector) GetCost

func (rcc *RPCClientConnector) GetCost(cd CallDescriptor, cc *CallCost) error

func (*RPCClientConnector) GetMaxSessionTime

func (rcc *RPCClientConnector) GetMaxSessionTime(cd CallDescriptor, resp *float64) error

func (*RPCClientConnector) MaxDebit

func (rcc *RPCClientConnector) MaxDebit(cd CallDescriptor, cc *CallCost) error

type Rate

type Rate struct {
	Tag                                         string
	ConnectFee, Price                           float64
	RateUnit, RateIncrement, GroupIntervalStart time.Duration
	RoundingMethod                              string
	RoundingDecimals                            int
	Weight                                      float64
}

func NewRate

func NewRate(tag, connectFee, price, ratedUnits, rateIncrements, groupInterval, roundingMethod, roundingDecimals, weight string) (r *Rate, err error)

type RatingProfile

type RatingProfile struct {
	Id                                                                                             string
	FallbackKey                                                                                    string // FallbackKey is used as complete combination of Tenant:TOR:Direction:Subject
	DestinationMap                                                                                 map[string][]*ActivationPeriod
	Tag, Tenant, TOR, Direction, Subject, DestRatesTimingTag, RatesFallbackSubject, ActivationTime string // used only for loading
}

func (*RatingProfile) AddActivationPeriodIfNotPresent

func (rp *RatingProfile) AddActivationPeriodIfNotPresent(destInfo string, aps ...*ActivationPeriod)

Adds an activation period that applyes to current rating profile if not already present.

func (*RatingProfile) GetActivationPeriodsForPrefix

func (rp *RatingProfile) GetActivationPeriodsForPrefix(destPrefix string) (foundPrefix string, aps []*ActivationPeriod, err error)

type RedisStorage

type RedisStorage struct {
	// contains filtered or unexported fields
}

func (*RedisStorage) Close

func (rs *RedisStorage) Close()

func (*RedisStorage) ExistsTPAccountActions

func (rs *RedisStorage) ExistsTPAccountActions(tpid, aaId string) (bool, error)

func (*RedisStorage) ExistsTPActionTimings

func (rs *RedisStorage) ExistsTPActionTimings(tpid, atId string) (bool, error)

func (*RedisStorage) ExistsTPActionTriggers

func (rs *RedisStorage) ExistsTPActionTriggers(tpid, atId string) (bool, error)

func (*RedisStorage) ExistsTPActions

func (rs *RedisStorage) ExistsTPActions(tpid, aId string) (bool, error)

func (*RedisStorage) ExistsTPDestRateTiming

func (rs *RedisStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error)

func (*RedisStorage) ExistsTPDestination

func (rs *RedisStorage) ExistsTPDestination(tpid, destTag string) (bool, error)

func (*RedisStorage) ExistsTPDestinationRate

func (rs *RedisStorage) ExistsTPDestinationRate(tpid, drId string) (bool, error)

func (*RedisStorage) ExistsTPRate

func (rs *RedisStorage) ExistsTPRate(tpid, rtId string) (bool, error)

func (*RedisStorage) ExistsTPRatingProfile

func (rs *RedisStorage) ExistsTPRatingProfile(tpid, rpId string) (bool, error)

func (*RedisStorage) ExistsTPTiming

func (rs *RedisStorage) ExistsTPTiming(tpid, tmId string) (bool, error)

func (*RedisStorage) Flush

func (rs *RedisStorage) Flush() (err error)

func (*RedisStorage) GetActionTimings

func (rs *RedisStorage) GetActionTimings(key string) (ats ActionTimings, err error)

func (*RedisStorage) GetActions

func (rs *RedisStorage) GetActions(key string) (as Actions, err error)

func (*RedisStorage) GetAllActionTimings

func (rs *RedisStorage) GetAllActionTimings() (ats map[string]ActionTimings, err error)

func (*RedisStorage) GetAllRatedCdr

func (rs *RedisStorage) GetAllRatedCdr() ([]utils.CDR, error)

func (*RedisStorage) GetCallCostLog

func (rs *RedisStorage) GetCallCostLog(uuid, source string) (cc *CallCost, err error)

func (*RedisStorage) GetDestination

func (rs *RedisStorage) GetDestination(key string) (dest *Destination, err error)

func (*RedisStorage) GetRatingProfile

func (rs *RedisStorage) GetRatingProfile(key string) (rp *RatingProfile, err error)

func (*RedisStorage) GetTPAccountActionIds

func (rs *RedisStorage) GetTPAccountActionIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPActionIds

func (rs *RedisStorage) GetTPActionIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPActionTimingIds

func (rs *RedisStorage) GetTPActionTimingIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPActionTimings

func (rs *RedisStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTimingsRow, error)

func (*RedisStorage) GetTPActionTriggerIds

func (rs *RedisStorage) GetTPActionTriggerIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPActions

func (rs *RedisStorage) GetTPActions(tpid, aId string) (*utils.TPActions, error)

func (*RedisStorage) GetTPDestRateTiming

func (rs *RedisStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error)

func (*RedisStorage) GetTPDestRateTimingIds

func (rs *RedisStorage) GetTPDestRateTimingIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPDestination

func (rs *RedisStorage) GetTPDestination(tpid, destTag string) (*Destination, error)

Extracts destinations from StorDB on specific tariffplan id

func (*RedisStorage) GetTPDestinationIds

func (rs *RedisStorage) GetTPDestinationIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPDestinationRate

func (rs *RedisStorage) GetTPDestinationRate(tpid, drId string) (*utils.TPDestinationRate, error)

func (*RedisStorage) GetTPDestinationRateIds

func (rs *RedisStorage) GetTPDestinationRateIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPIds

func (rs *RedisStorage) GetTPIds() ([]string, error)

func (*RedisStorage) GetTPRate

func (rs *RedisStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error)

func (*RedisStorage) GetTPRateIds

func (rs *RedisStorage) GetTPRateIds(tpid string) ([]string, error)

func (*RedisStorage) GetTPRatingProfile

func (rs *RedisStorage) GetTPRatingProfile(tpid, rpId string) (*utils.TPRatingProfile, error)

func (*RedisStorage) GetTPRatingProfileIds

func (rs *RedisStorage) GetTPRatingProfileIds(filters *utils.AttrTPRatingProfileIds) ([]string, error)

func (*RedisStorage) GetTPTiming

func (rs *RedisStorage) GetTPTiming(tpid, tmId string) (*Timing, error)

func (*RedisStorage) GetTPTimingIds

func (rs *RedisStorage) GetTPTimingIds(tpid string) ([]string, error)

func (*RedisStorage) GetTpAccountActions

func (rs *RedisStorage) GetTpAccountActions(tpid, tag string) (map[string]*AccountAction, error)

func (*RedisStorage) GetTpActionTimings

func (rs *RedisStorage) GetTpActionTimings(tpid, tag string) (map[string][]*ActionTiming, error)

func (*RedisStorage) GetTpActionTriggers

func (rs *RedisStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*ActionTrigger, error)

func (*RedisStorage) GetTpActions

func (rs *RedisStorage) GetTpActions(tpid, tag string) (map[string][]*Action, error)

func (*RedisStorage) GetTpDestinationRateTimings

func (rs *RedisStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error)

func (*RedisStorage) GetTpDestinationRates

func (ms *RedisStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error)

func (*RedisStorage) GetTpDestinations

func (rs *RedisStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error)

func (*RedisStorage) GetTpRates

func (rs *RedisStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error)

func (*RedisStorage) GetTpRatingProfiles

func (rs *RedisStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error)

func (*RedisStorage) GetTpTimings

func (rs *RedisStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error)

func (*RedisStorage) GetUserBalance

func (rs *RedisStorage) GetUserBalance(key string) (ub *UserBalance, err error)

func (*RedisStorage) LogActionTiming

func (rs *RedisStorage) LogActionTiming(source string, at *ActionTiming, as Actions) (err error)

func (*RedisStorage) LogActionTrigger

func (rs *RedisStorage) LogActionTrigger(ubId, source string, at *ActionTrigger, as Actions) (err error)

func (*RedisStorage) LogCallCost

func (rs *RedisStorage) LogCallCost(uuid, source string, cc *CallCost) (err error)

func (*RedisStorage) LogError

func (rs *RedisStorage) LogError(uuid, source, errstr string) (err error)

func (*RedisStorage) SetActionTimings

func (rs *RedisStorage) SetActionTimings(key string, ats ActionTimings) (err error)

func (*RedisStorage) SetActions

func (rs *RedisStorage) SetActions(key string, as Actions) (err error)

func (*RedisStorage) SetCdr

func (rs *RedisStorage) SetCdr(utils.CDR) error

func (*RedisStorage) SetDestination

func (rs *RedisStorage) SetDestination(dest *Destination) (err error)

func (*RedisStorage) SetRatedCdr

func (rs *RedisStorage) SetRatedCdr(cdr utils.CDR, cc *CallCost, extraInfo string) error

func (*RedisStorage) SetRatingProfile

func (rs *RedisStorage) SetRatingProfile(rp *RatingProfile) (err error)

func (*RedisStorage) SetTPAccountActions

func (rs *RedisStorage) SetTPAccountActions(tpid string, aa map[string]*AccountAction) error

func (*RedisStorage) SetTPActionTimings

func (rs *RedisStorage) SetTPActionTimings(tpid string, ats map[string][]*ActionTiming) error

func (*RedisStorage) SetTPActionTriggers

func (rs *RedisStorage) SetTPActionTriggers(tpid string, ats map[string][]*ActionTrigger) error

func (*RedisStorage) SetTPActions

func (rs *RedisStorage) SetTPActions(tpid string, acts map[string][]*Action) error

func (*RedisStorage) SetTPDestRateTimings

func (rs *RedisStorage) SetTPDestRateTimings(tpid string, drts map[string][]*DestinationRateTiming) error

func (*RedisStorage) SetTPDestination

func (rs *RedisStorage) SetTPDestination(tpid string, dest *Destination) error

func (*RedisStorage) SetTPDestinationRates

func (rs *RedisStorage) SetTPDestinationRates(tpid string, drs map[string][]*DestinationRate) error

func (*RedisStorage) SetTPRates

func (rs *RedisStorage) SetTPRates(tpid string, rts map[string][]*Rate) error

func (*RedisStorage) SetTPRatingProfiles

func (rs *RedisStorage) SetTPRatingProfiles(tpid string, rps map[string][]*RatingProfile) error

func (*RedisStorage) SetTPTiming

func (rs *RedisStorage) SetTPTiming(tpid string, tm *Timing) error

func (*RedisStorage) SetUserBalance

func (rs *RedisStorage) SetUserBalance(ub *UserBalance) (err error)

type Responder

type Responder struct {
	Bal      *balancer2go.Balancer
	ExitChan chan bool
}

func (*Responder) AddRecievedCallSeconds

func (rs *Responder) AddRecievedCallSeconds(arg CallDescriptor, reply *float64) (err error)

func (*Responder) Debit

func (rs *Responder) Debit(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) DebitCents

func (rs *Responder) DebitCents(arg CallDescriptor, reply *float64) (err error)

func (*Responder) DebitSMS

func (rs *Responder) DebitSMS(arg CallDescriptor, reply *float64) (err error)

func (*Responder) DebitSeconds

func (rs *Responder) DebitSeconds(arg CallDescriptor, reply *float64) (err error)

func (*Responder) FlushCache

func (rs *Responder) FlushCache(arg CallDescriptor, reply *float64) (err error)

func (*Responder) GetCost

func (rs *Responder) GetCost(arg CallDescriptor, reply *CallCost) (err error)

RPC method thet provides the external RPC interface for getting the rating information.

func (*Responder) GetInternet

func (rs *Responder) GetInternet(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) GetInternetTime

func (rs *Responder) GetInternetTime(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) GetMaxSessionTime

func (rs *Responder) GetMaxSessionTime(arg CallDescriptor, reply *float64) (err error)

func (*Responder) GetMinutes

func (rs *Responder) GetMinutes(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) GetMonetary

func (rs *Responder) GetMonetary(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) GetSMS

func (rs *Responder) GetSMS(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) MaxDebit

func (rs *Responder) MaxDebit(arg CallDescriptor, reply *CallCost) (err error)

func (*Responder) RegisterRater

func (rs *Responder) RegisterRater(clientAddress string, replay *int) error

RPC method that receives a rater address, connects to it and ads the pair to the rater list for balancing

func (*Responder) Shutdown

func (rs *Responder) Shutdown(arg string, reply *string) (err error)

func (*Responder) Status

func (rs *Responder) Status(arg string, reply *string) (err error)

func (*Responder) UnRegisterRater

func (rs *Responder) UnRegisterRater(clientAddress string, replay *int) error

RPC method that recives a rater addres gets the connections and closes it and removes the pair from rater list.

type ResponderWorker

type ResponderWorker struct{}

Reflection worker type for not standalone balancer

func (*ResponderWorker) Call

func (rw *ResponderWorker) Call(serviceMethod string, args interface{}, reply interface{}) error

func (*ResponderWorker) Close

func (rw *ResponderWorker) Close() error

type SQLStorage

type SQLStorage struct {
	Db *sql.DB
}

func (*SQLStorage) Close

func (self *SQLStorage) Close()

func (*SQLStorage) ExistsTPAccountActions

func (self *SQLStorage) ExistsTPAccountActions(tpid, aaId string) (bool, error)

func (*SQLStorage) ExistsTPActionTimings

func (self *SQLStorage) ExistsTPActionTimings(tpid, atId string) (bool, error)

func (*SQLStorage) ExistsTPActionTriggers

func (self *SQLStorage) ExistsTPActionTriggers(tpid, atId string) (bool, error)

func (*SQLStorage) ExistsTPActions

func (self *SQLStorage) ExistsTPActions(tpid, actsId string) (bool, error)

func (*SQLStorage) ExistsTPDestRateTiming

func (self *SQLStorage) ExistsTPDestRateTiming(tpid, drtId string) (bool, error)

func (*SQLStorage) ExistsTPDestination

func (self *SQLStorage) ExistsTPDestination(tpid, destTag string) (bool, error)

func (*SQLStorage) ExistsTPDestinationRate

func (self *SQLStorage) ExistsTPDestinationRate(tpid, drId string) (bool, error)

func (*SQLStorage) ExistsTPRate

func (self *SQLStorage) ExistsTPRate(tpid, rtId string) (bool, error)

func (*SQLStorage) ExistsTPRatingProfile

func (self *SQLStorage) ExistsTPRatingProfile(tpid, rpId string) (bool, error)

func (*SQLStorage) ExistsTPTiming

func (self *SQLStorage) ExistsTPTiming(tpid, tmId string) (bool, error)

func (*SQLStorage) Flush

func (self *SQLStorage) Flush() (err error)

func (*SQLStorage) GetActionTimings

func (self *SQLStorage) GetActionTimings(key string) (ats ActionTimings, err error)

func (*SQLStorage) GetActions

func (self *SQLStorage) GetActions(string) (as Actions, err error)

func (*SQLStorage) GetAllActionTimings

func (self *SQLStorage) GetAllActionTimings() (ats map[string]ActionTimings, err error)

func (*SQLStorage) GetAllRatedCdr

func (self *SQLStorage) GetAllRatedCdr() ([]utils.CDR, error)

func (*SQLStorage) GetCallCostLog

func (self *SQLStorage) GetCallCostLog(cgrid, source string) (cc *CallCost, err error)

func (*SQLStorage) GetDestination

func (self *SQLStorage) GetDestination(string) (d *Destination, err error)

func (*SQLStorage) GetRatingProfile

func (self *SQLStorage) GetRatingProfile(string) (rp *RatingProfile, err error)

func (*SQLStorage) GetTPAccountActionIds

func (self *SQLStorage) GetTPAccountActionIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPActionIds

func (self *SQLStorage) GetTPActionIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPActionTimingIds

func (self *SQLStorage) GetTPActionTimingIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPActionTimings

func (self *SQLStorage) GetTPActionTimings(tpid, atId string) (map[string][]*utils.TPActionTimingsRow, error)

func (*SQLStorage) GetTPActionTriggerIds

func (self *SQLStorage) GetTPActionTriggerIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPActions

func (self *SQLStorage) GetTPActions(tpid, actsId string) (*utils.TPActions, error)

func (*SQLStorage) GetTPDestRateTiming

func (self *SQLStorage) GetTPDestRateTiming(tpid, drtId string) (*utils.TPDestRateTiming, error)

func (*SQLStorage) GetTPDestRateTimingIds

func (self *SQLStorage) GetTPDestRateTimingIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPDestination

func (self *SQLStorage) GetTPDestination(tpid, destTag string) (*Destination, error)

Extracts destinations from StorDB on specific tariffplan id

func (*SQLStorage) GetTPDestinationIds

func (self *SQLStorage) GetTPDestinationIds(tpid string) ([]string, error)

Extracts destinations from StorDB on specific tariffplan id

func (*SQLStorage) GetTPDestinationRate

func (self *SQLStorage) GetTPDestinationRate(tpid, drId string) (*utils.TPDestinationRate, error)

func (*SQLStorage) GetTPDestinationRateIds

func (self *SQLStorage) GetTPDestinationRateIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPIds

func (self *SQLStorage) GetTPIds() ([]string, error)

Return a list with all TPids defined in the system, even if incomplete, isolated in some table.

func (*SQLStorage) GetTPRate

func (self *SQLStorage) GetTPRate(tpid, rtId string) (*utils.TPRate, error)

func (*SQLStorage) GetTPRateIds

func (self *SQLStorage) GetTPRateIds(tpid string) ([]string, error)

func (*SQLStorage) GetTPRatingProfile

func (self *SQLStorage) GetTPRatingProfile(tpid, rpId string) (*utils.TPRatingProfile, error)

func (*SQLStorage) GetTPRatingProfileIds

func (self *SQLStorage) GetTPRatingProfileIds(filters *utils.AttrTPRatingProfileIds) ([]string, error)

func (*SQLStorage) GetTPTiming

func (self *SQLStorage) GetTPTiming(tpid, tmId string) (*Timing, error)

func (*SQLStorage) GetTPTimingIds

func (self *SQLStorage) GetTPTimingIds(tpid string) ([]string, error)

func (*SQLStorage) GetTpAccountActions

func (self *SQLStorage) GetTpAccountActions(tpid, tag string) (map[string]*AccountAction, error)

func (*SQLStorage) GetTpActionTimings

func (self *SQLStorage) GetTpActionTimings(tpid, tag string) (ats map[string][]*ActionTiming, err error)

func (*SQLStorage) GetTpActionTriggers

func (self *SQLStorage) GetTpActionTriggers(tpid, tag string) (map[string][]*ActionTrigger, error)

func (*SQLStorage) GetTpActions

func (self *SQLStorage) GetTpActions(tpid, tag string) (map[string][]*Action, error)

func (*SQLStorage) GetTpDestinationRateTimings

func (self *SQLStorage) GetTpDestinationRateTimings(tpid, tag string) ([]*DestinationRateTiming, error)

func (*SQLStorage) GetTpDestinationRates

func (self *SQLStorage) GetTpDestinationRates(tpid, tag string) (map[string][]*DestinationRate, error)

func (*SQLStorage) GetTpDestinations

func (self *SQLStorage) GetTpDestinations(tpid, tag string) ([]*Destination, error)

func (*SQLStorage) GetTpRates

func (self *SQLStorage) GetTpRates(tpid, tag string) (map[string]*Rate, error)

func (*SQLStorage) GetTpRatingProfiles

func (self *SQLStorage) GetTpRatingProfiles(tpid, tag string) (map[string]*RatingProfile, error)

func (*SQLStorage) GetTpTimings

func (self *SQLStorage) GetTpTimings(tpid, tag string) (map[string]*Timing, error)

func (*SQLStorage) GetUserBalance

func (self *SQLStorage) GetUserBalance(string) (ub *UserBalance, err error)

func (*SQLStorage) LogActionTiming

func (self *SQLStorage) LogActionTiming(source string, at *ActionTiming, as Actions) (err error)

func (*SQLStorage) LogActionTrigger

func (self *SQLStorage) LogActionTrigger(ubId, source string, at *ActionTrigger, as Actions) (err error)

func (*SQLStorage) LogCallCost

func (self *SQLStorage) LogCallCost(uuid, source string, cc *CallCost) (err error)

func (*SQLStorage) LogError

func (self *SQLStorage) LogError(uuid, source, errstr string) (err error)

func (*SQLStorage) SetActionTimings

func (self *SQLStorage) SetActionTimings(key string, ats ActionTimings) (err error)

func (*SQLStorage) SetActions

func (self *SQLStorage) SetActions(key string, as Actions) (err error)

func (*SQLStorage) SetCdr

func (self *SQLStorage) SetCdr(cdr utils.CDR) (err error)

func (*SQLStorage) SetDestination

func (self *SQLStorage) SetDestination(d *Destination) (err error)

func (*SQLStorage) SetRatedCdr

func (self *SQLStorage) SetRatedCdr(cdr utils.CDR, cc *CallCost, extraInfo string) (err error)

func (*SQLStorage) SetRatingProfile

func (self *SQLStorage) SetRatingProfile(rp *RatingProfile) (err error)

func (*SQLStorage) SetTPAccountActions

func (self *SQLStorage) SetTPAccountActions(tpid string, aa map[string]*AccountAction) error

func (*SQLStorage) SetTPActionTimings

func (self *SQLStorage) SetTPActionTimings(tpid string, ats map[string][]*ActionTiming) error

Sets actionTimings in sqlDB. Imput is expected in form map[actionTimingId][]rows, eg a full .csv file content

func (*SQLStorage) SetTPActionTriggers

func (self *SQLStorage) SetTPActionTriggers(tpid string, ats map[string][]*ActionTrigger) error

func (*SQLStorage) SetTPActions

func (self *SQLStorage) SetTPActions(tpid string, acts map[string][]*Action) error

func (*SQLStorage) SetTPDestRateTimings

func (self *SQLStorage) SetTPDestRateTimings(tpid string, drts map[string][]*DestinationRateTiming) error

func (*SQLStorage) SetTPDestination

func (self *SQLStorage) SetTPDestination(tpid string, dest *Destination) error

func (*SQLStorage) SetTPDestinationRates

func (self *SQLStorage) SetTPDestinationRates(tpid string, drs map[string][]*DestinationRate) error

func (*SQLStorage) SetTPRates

func (self *SQLStorage) SetTPRates(tpid string, rts map[string][]*Rate) error

func (*SQLStorage) SetTPRatingProfiles

func (self *SQLStorage) SetTPRatingProfiles(tpid string, rps map[string][]*RatingProfile) error

func (*SQLStorage) SetTPTiming

func (self *SQLStorage) SetTPTiming(tpid string, tm *Timing) error

func (*SQLStorage) SetUserBalance

func (self *SQLStorage) SetUserBalance(ub *UserBalance) (err error)

type TPCSVFileParser

type TPCSVFileParser struct {
	// contains filtered or unexported fields
}

Opens the connection to a file and returns the parsed lines one by one when ParseNextLine() is called

func NewTPCSVFileParser

func NewTPCSVFileParser(dirPath, fileName string) (*TPCSVFileParser, error)

func (*TPCSVFileParser) ParseNextLine

func (self *TPCSVFileParser) ParseNextLine() ([]string, error)

type TPCSVImporter

type TPCSVImporter struct {
	TPid     string      // Load data on this tpid
	StorDb   DataStorage // StorDb connection handle
	DirPath  string      // Directory path to import from
	Sep      rune        // Separator in the csv file
	Verbose  bool        // If true will print a detailed information instead of silently discarding it
	ImportId string      // Use this to differentiate between imports (eg: when autogenerating fields like RatingProfileId
}

Import tariff plan from csv into storDb

func (*TPCSVImporter) Run

func (self *TPCSVImporter) Run() error

type TPLoader

type TPLoader interface {
	LoadDestinations() error
	LoadRates() error
	LoadDestinationRates() error
	LoadTimings() error
	LoadDestinationRateTimings() error
	LoadRatingProfiles() error
	LoadActions() error
	LoadActionTimings() error
	LoadActionTriggers() error
	LoadAccountActions() error
	WriteToDatabase(bool, bool) error
}

type TimeSpan

type TimeSpan struct {
	TimeStart, TimeEnd time.Time
	Cost               float64
	ActivationPeriod   *ActivationPeriod
	Interval           *Interval
	MinuteInfo         *MinuteInfo
	CallDuration       time.Duration // the call duration so far till TimeEnd
}

A unit in which a call will be split that has a specific price related interval attached to it.

func (*TimeSpan) Contains

func (ts *TimeSpan) Contains(t time.Time) bool

Returns true if the given time is inside timespan range.

func (*TimeSpan) GetDuration

func (ts *TimeSpan) GetDuration() time.Duration

Returns the duration of the timespan

func (*TimeSpan) GetGroupEnd

func (ts *TimeSpan) GetGroupEnd() time.Duration

func (*TimeSpan) GetGroupStart

func (ts *TimeSpan) GetGroupStart() time.Duration

func (*TimeSpan) SetInterval

func (ts *TimeSpan) SetInterval(i *Interval)

Will set the interval as spans's interval if new Weight is greater then span's interval Weight or if the Weights are equal and new price is lower then spans's interval price

func (*TimeSpan) SetNewCallDuration

func (ts *TimeSpan) SetNewCallDuration(nts *TimeSpan)

func (*TimeSpan) SplitByActivationPeriod

func (ts *TimeSpan) SplitByActivationPeriod(ap *ActivationPeriod) (newTs *TimeSpan)

Splits the given timespan on activation period's activation time.

func (*TimeSpan) SplitByInterval

func (ts *TimeSpan) SplitByInterval(i *Interval) (nts *TimeSpan)

Splits the given timespan according to how it relates to the interval. It will modify the endtime of the received timespan and it will return a new timespan starting from the end of the received one. The interval will attach itself to the timespan that overlaps the interval.

func (*TimeSpan) SplitByMinuteBucket

func (ts *TimeSpan) SplitByMinuteBucket(mb *MinuteBucket) (newTs *TimeSpan)

Splits the given timespan on minute bucket's duration.

type Timing

type Timing struct {
	Id        string
	Years     Years
	Months    Months
	MonthDays MonthDays
	WeekDays  WeekDays
	StartTime string
}

func NewTiming

func NewTiming(timingInfo ...string) (rt *Timing)

type UnitsCounter

type UnitsCounter struct {
	Direction     string
	BalanceId     string
	Units         float64
	MinuteBuckets bucketsorter
}

Amount of a trafic of a certain type

func (*UnitsCounter) String

func (uc *UnitsCounter) String() string

type UserBalance

type UserBalance struct {
	Id             string
	Type           string // prepaid-postpaid
	BalanceMap     map[string]BalanceChain
	MinuteBuckets  []*MinuteBucket
	UnitCounters   []*UnitsCounter
	ActionTriggers ActionTriggerPriotityList
}

Structure containing information about user's credit (minutes, cents, sms...).'

func (*UserBalance) CleanExpiredBalancesAndBuckets

func (ub *UserBalance) CleanExpiredBalancesAndBuckets()

type WeekDays

type WeekDays []time.Weekday

Defines week days series

func (WeekDays) Contains

func (wd WeekDays) Contains(weekDay time.Weekday) (result bool)

Return true if the specified date is inside the series

func (WeekDays) Len

func (wd WeekDays) Len() int

func (WeekDays) Less

func (wd WeekDays) Less(j, i int) bool

func (*WeekDays) Parse

func (wd *WeekDays) Parse(input, sep string)

func (WeekDays) Serialize

func (wd WeekDays) Serialize(sep string) string

Dumps the week days in a serialized string, similar to the one parsed

func (WeekDays) Sort

func (wd WeekDays) Sort()

func (WeekDays) Swap

func (wd WeekDays) Swap(i, j int)

type Years

type Years []int

Defines years days series

func (Years) Contains

func (ys Years) Contains(year int) (result bool)

Return true if the specified date is inside the series

func (Years) Len

func (ys Years) Len() int

func (Years) Less

func (ys Years) Less(j, i int) bool

func (*Years) Parse

func (ys *Years) Parse(input, sep string)

Parse Years elements from string separated by sep.

func (Years) Serialize

func (ys Years) Serialize(sep string) string

func (Years) Sort

func (ys Years) Sort()

func (Years) Swap

func (ys Years) Swap(i, j int)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL