Ejemplo n.º 1
0
// Does not block for posts, no error reports
func callUrlAsync(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) error {
	var o interface{}
	if ub != nil {
		o = ub
	}
	if sq != nil {
		o = sq
	}
	jsn, err := json.Marshal(o)
	if err != nil {
		return err
	}
	cfg := config.CgrConfig()
	fallbackPath := path.Join(cfg.HttpFailedDir, fmt.Sprintf("act_%s_%s_%s.json", a.ActionType, a.ExtraParameters, utils.GenUUID()))
	go utils.NewHTTPPoster(config.CgrConfig().HttpSkipTlsVerify,
		config.CgrConfig().ReplyTimeout).Post(a.ExtraParameters, utils.CONTENT_JSON, jsn, config.CgrConfig().HttpPosterAttempts, fallbackPath)
	return nil
}
Ejemplo n.º 2
0
func NewCdrServer(cgrCfg *config.CGRConfig, cdrDb CdrStorage, dataDB AccountingStorage, rater, pubsub, users, aliases, stats rpcclient.RpcClientConnection) (*CdrServer, error) {
	if rater == nil || reflect.ValueOf(rater).IsNil() { // Work around so we store actual nil instead of nil interface value, faster to check here than in CdrServer code
		rater = nil
	}
	if pubsub == nil || reflect.ValueOf(pubsub).IsNil() {
		pubsub = nil
	}
	if users == nil || reflect.ValueOf(users).IsNil() {
		users = nil
	}
	if aliases == nil || reflect.ValueOf(aliases).IsNil() {
		aliases = nil
	}
	if stats == nil || reflect.ValueOf(stats).IsNil() {
		stats = nil
	}
	return &CdrServer{cgrCfg: cgrCfg, cdrDb: cdrDb, dataDB: dataDB,
		rals: rater, pubsub: pubsub, users: users, aliases: aliases, stats: stats, guard: Guardian,
		httpPoster: utils.NewHTTPPoster(cgrCfg.HttpSkipTlsVerify, cgrCfg.ReplyTimeout)}, nil
}