当前位置: 首页>>代码示例>>Golang>>正文


Golang AccountingStorage.GetLoadHistory方法代码示例

本文整理汇总了Golang中github.com/cgrates/cgrates/engine.AccountingStorage.GetLoadHistory方法的典型用法代码示例。如果您正苦于以下问题:Golang AccountingStorage.GetLoadHistory方法的具体用法?Golang AccountingStorage.GetLoadHistory怎么用?Golang AccountingStorage.GetLoadHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/cgrates/cgrates/engine.AccountingStorage的用法示例。


在下文中一共展示了AccountingStorage.GetLoadHistory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: startAliasesServer

// ToDo: Make sure we are caching before starting this one
func startAliasesServer(internalAliaseSChan chan rpcclient.RpcClientConnection, accountDb engine.AccountingStorage, server *utils.Server, exitChan chan bool) {
	aliasesServer := engine.NewAliasHandler(accountDb)
	server.RpcRegisterName("AliasesV1", aliasesServer)
	loadHist, err := accountDb.GetLoadHistory(1, true)
	if err != nil || len(loadHist) == 0 {
		utils.Logger.Info(fmt.Sprintf("could not get load history: %v (%v)", loadHist, err))
		internalAliaseSChan <- aliasesServer
		return
	}
	cfi, err := utils.LoadCacheFileInfo(cfg.CacheDumpDir)
	if err != nil || cfi.LoadInfo.AccountingLoadID != loadHist[0].AccountingLoadID {
		if err := accountDb.CacheAccountingPrefixes("RaterStart", utils.ALIASES_PREFIX); err != nil {
			utils.Logger.Crit(fmt.Sprintf("<Aliases> Could not start, error: %s", err.Error()))
			exitChan <- true
			return
		}
	} else {
		if err := engine.CacheLoad(cfg.CacheDumpDir, []string{utils.ALIASES_PREFIX}); err != nil {
			utils.Logger.Crit("could not load cache file: " + err.Error())
			exitChan <- true
			return
		}
	}
	internalAliaseSChan <- aliasesServer
}
开发者ID:iwada,项目名称:cgrates,代码行数:26,代码来源:cgr-engine.go

示例2: startAliasesServer

// ToDo: Make sure we are caching before starting this one
func startAliasesServer(internalAliaseSChan chan rpcclient.RpcClientConnection, accountDb engine.AccountingStorage, server *utils.Server, exitChan chan bool) {
	aliasesServer := engine.NewAliasHandler(accountDb)
	server.RpcRegisterName("AliasesV1", aliasesServer)
	loadHist, err := accountDb.GetLoadHistory(1, true, utils.NonTransactional)
	if err != nil || len(loadHist) == 0 {
		utils.Logger.Info(fmt.Sprintf("could not get load history: %v (%v)", loadHist, err))
		internalAliaseSChan <- aliasesServer
		return
	}

	if err := accountDb.PreloadAccountingCache(); err != nil {
		utils.Logger.Crit(fmt.Sprintf("<Aliases> Could not start, error: %s", err.Error()))
		exitChan <- true
		return
	}

	internalAliaseSChan <- aliasesServer
}
开发者ID:eloycoto,项目名称:cgrates,代码行数:19,代码来源:cgr-engine.go

示例3: startRater

// Starts rater and reports on chan
func startRater(internalRaterChan chan rpcclient.RpcClientConnection, cacheDoneChan chan struct{}, internalBalancerChan chan *balancer2go.Balancer, internalSchedulerChan chan *scheduler.Scheduler,
	internalCdrStatSChan chan rpcclient.RpcClientConnection, internalHistorySChan chan rpcclient.RpcClientConnection,
	internalPubSubSChan chan rpcclient.RpcClientConnection, internalUserSChan chan rpcclient.RpcClientConnection, internalAliaseSChan chan rpcclient.RpcClientConnection,
	server *utils.Server,
	ratingDb engine.RatingStorage, accountDb engine.AccountingStorage, loadDb engine.LoadStorage, cdrDb engine.CdrStorage, logDb engine.LogStorage,
	stopHandled *bool, exitChan chan bool) {
	var waitTasks []chan struct{}

	//Cache load
	cacheTaskChan := make(chan struct{})
	waitTasks = append(waitTasks, cacheTaskChan)
	go func() {
		defer close(cacheTaskChan)

		loadHist, err := accountDb.GetLoadHistory(1, true)
		if err != nil || len(loadHist) == 0 {
			utils.Logger.Info(fmt.Sprintf("could not get load history: %v (%v)", loadHist, err))
			cacheDoneChan <- struct{}{}
			return
		}
		cfi, err := utils.LoadCacheFileInfo(cfg.CacheDumpDir)
		if err != nil || cfi.LoadInfo.RatingLoadID != loadHist[0].RatingLoadID {
			if err := ratingDb.CacheRatingAll("StartRater"); err != nil {
				utils.Logger.Crit(fmt.Sprintf("Cache rating error: %s", err.Error()))
				exitChan <- true
				return
			}
		} else {
			if err := engine.CacheLoad(cfg.CacheDumpDir, []string{utils.DESTINATION_PREFIX, utils.RATING_PLAN_PREFIX, utils.RATING_PROFILE_PREFIX, utils.LCR_PREFIX, utils.DERIVEDCHARGERS_PREFIX, utils.ACTION_PREFIX, utils.ACTION_PLAN_PREFIX, utils.SHARED_GROUP_PREFIX}); err != nil {
				utils.Logger.Crit("could not load cache file: " + err.Error())
				exitChan <- true
				return
			}
		}
		cacheDoneChan <- struct{}{}
	}()

	// Retrieve scheduler for it's API methods
	var sched *scheduler.Scheduler // Need the scheduler in APIer
	if cfg.SchedulerEnabled {
		schedTaskChan := make(chan struct{})
		waitTasks = append(waitTasks, schedTaskChan)
		go func() {
			defer close(schedTaskChan)
			select {
			case sched = <-internalSchedulerChan:
				internalSchedulerChan <- sched
			case <-time.After(cfg.InternalTtl):
				utils.Logger.Crit("<Rater>: Internal scheduler connection timeout.")
				exitChan <- true
				return
			}

		}()
	}
	var bal *balancer2go.Balancer
	if cfg.RALsBalancer != "" { // Connection to balancer
		balTaskChan := make(chan struct{})
		waitTasks = append(waitTasks, balTaskChan)
		go func() {
			defer close(balTaskChan)
			if cfg.RALsBalancer == utils.MetaInternal {
				select {
				case bal = <-internalBalancerChan:
					internalBalancerChan <- bal // Put it back if someone else is interested about
				case <-time.After(cfg.InternalTtl):
					utils.Logger.Crit("<Rater>: Internal balancer connection timeout.")
					exitChan <- true
					return
				}
			} else {
				go registerToBalancer(exitChan)
				go stopRaterSignalHandler(internalCdrStatSChan, exitChan)
				*stopHandled = true
			}
		}()
	}
	var cdrStats *rpcclient.RpcClientPool
	if len(cfg.RALsCDRStatSConns) != 0 { // Connections to CDRStats
		cdrstatTaskChan := make(chan struct{})
		waitTasks = append(waitTasks, cdrstatTaskChan)
		go func() {
			defer close(cdrstatTaskChan)
			cdrStats, err = engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
				cfg.RALsCDRStatSConns, internalCdrStatSChan, cfg.InternalTtl)
			if err != nil {
				utils.Logger.Crit(fmt.Sprintf("<RALs> Could not connect to CDRStatS, error: %s", err.Error()))
				exitChan <- true
				return
			}
		}()
	}
	if len(cfg.RALsHistorySConns) != 0 { // Connection to HistoryS,
		histTaskChan := make(chan struct{})
		waitTasks = append(waitTasks, histTaskChan)
		go func() {
			defer close(histTaskChan)
			if historySConns, err := engine.NewRPCPool(rpcclient.POOL_FIRST, cfg.ConnectAttempts, cfg.Reconnects, cfg.ConnectTimeout, cfg.ReplyTimeout,
				cfg.RALsHistorySConns, internalHistorySChan, cfg.InternalTtl); err != nil {
//.........这里部分代码省略.........
开发者ID:iwada,项目名称:cgrates,代码行数:101,代码来源:rater.go


注:本文中的github.com/cgrates/cgrates/engine.AccountingStorage.GetLoadHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。