mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 16:18:44 +05:00
HTTPPoster with reply timeout and connection caching for CDR replication
This commit is contained in:
@@ -422,7 +422,8 @@ func callUrl(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions) error
|
||||
}
|
||||
cfg := config.CgrConfig()
|
||||
fallbackPath := path.Join(cfg.HttpFailedDir, fmt.Sprintf("act_%s_%s_%s.json", a.ActionType, a.ExtraParameters, utils.GenUUID()))
|
||||
_, _, err = utils.HttpPoster(a.ExtraParameters, cfg.HttpSkipTlsVerify, jsn, utils.CONTENT_JSON, config.CgrConfig().HttpPosterAttempts, fallbackPath, false)
|
||||
_, err = utils.NewHTTPPoster(config.CgrConfig().HttpSkipTlsVerify,
|
||||
config.CgrConfig().ReplyTimeout).Post(a.ExtraParameters, utils.CONTENT_JSON, jsn, config.CgrConfig().HttpPosterAttempts, fallbackPath)
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -441,7 +442,8 @@ func callUrlAsync(ub *Account, sq *StatsQueueTriggered, a *Action, acs Actions)
|
||||
}
|
||||
cfg := config.CgrConfig()
|
||||
fallbackPath := path.Join(cfg.HttpFailedDir, fmt.Sprintf("act_%s_%s_%s.json", a.ActionType, a.ExtraParameters, utils.GenUUID()))
|
||||
go utils.HttpPoster(a.ExtraParameters, cfg.HttpSkipTlsVerify, jsn, utils.CONTENT_JSON, config.CgrConfig().HttpPosterAttempts, fallbackPath, false)
|
||||
go utils.NewHTTPPoster(config.CgrConfig().HttpSkipTlsVerify,
|
||||
config.CgrConfig().ReplyTimeout).Post(a.ExtraParameters, utils.CONTENT_JSON, jsn, config.CgrConfig().HttpPosterAttempts, fallbackPath)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +86,8 @@ func NewCdrServer(cgrCfg *config.CGRConfig, cdrDb CdrStorage, dataDB AccountingS
|
||||
stats = nil
|
||||
}
|
||||
return &CdrServer{cgrCfg: cgrCfg, cdrDb: cdrDb, dataDB: dataDB,
|
||||
rals: rater, pubsub: pubsub, users: users, aliases: aliases, stats: stats, guard: Guardian}, nil
|
||||
rals: rater, pubsub: pubsub, users: users, aliases: aliases, stats: stats, guard: Guardian,
|
||||
httpPoster: utils.NewHTTPPoster(cgrCfg.HttpSkipTlsVerify, cgrCfg.ReplyTimeout)}, nil
|
||||
}
|
||||
|
||||
type CdrServer struct {
|
||||
@@ -100,6 +101,7 @@ type CdrServer struct {
|
||||
stats rpcclient.RpcClientConnection
|
||||
guard *GuardianLock
|
||||
responseCache *cache.ResponseCache
|
||||
httpPoster *utils.HTTPPoster // used for replication
|
||||
}
|
||||
|
||||
func (self *CdrServer) Timezone() string {
|
||||
@@ -477,10 +479,7 @@ func (self *CdrServer) replicateCdr(cdr *CDR) error {
|
||||
fallbackPath := path.Join(
|
||||
self.cgrCfg.HttpFailedDir,
|
||||
rplCfg.FallbackFileName())
|
||||
_, _, err := utils.HttpPoster(
|
||||
rplCfg.Address, self.cgrCfg.HttpSkipTlsVerify, body,
|
||||
content, rplCfg.Attempts, fallbackPath, false) // ToDo: Review caching here after we are sure that the connection leak is gone
|
||||
if err != nil {
|
||||
if _, err := self.httpPoster.Post(rplCfg.Address, content, body, rplCfg.Attempts, fallbackPath); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf(
|
||||
"<CDRReplicator> Replicating CDR: %+v, got error: %s", cdr, err.Error()))
|
||||
if rplCfg.Synchronous {
|
||||
|
||||
Reference in New Issue
Block a user