Update kamevapi to new version

This commit is contained in:
arberkatellari
2024-03-07 14:56:31 +02:00
committed by Dan Christian Bogos
parent 28e53cecc9
commit f7cbec3b41
4 changed files with 11 additions and 10 deletions

View File

@@ -21,7 +21,6 @@ package agents
import (
"errors"
"fmt"
"log"
"regexp"
"strings"
"time"
@@ -29,11 +28,11 @@ import (
"github.com/cgrates/birpc"
"github.com/cgrates/birpc/context"
"github.com/cgrates/cgrates/engine"
"github.com/cgrates/kamevapi"
"github.com/cgrates/cgrates/config"
"github.com/cgrates/cgrates/sessions"
"github.com/cgrates/cgrates/utils"
"github.com/cgrates/kamevapi"
)
var (
@@ -84,12 +83,10 @@ func (self *KamailioAgent) Connect() (err error) {
}
errChan := make(chan error)
for connIdx, connCfg := range self.cfg.EvapiConns {
logger := log.New(utils.Logger, "kamevapi:", 2)
if self.conns[connIdx], err = kamevapi.NewKamEvapi(connCfg.Address, connIdx, connCfg.Reconnects, connCfg.MaxReconnectInterval,
utils.FibDuration, eventHandlers, logger); err != nil {
utils.FibDuration, eventHandlers, utils.Logger); err != nil {
return
}
utils.Logger.Info(fmt.Sprintf("<%s> successfully connected to Kamailio at: <%s>", utils.KamailioAgent, connCfg.Address))
go func(conn *kamevapi.KamEvapi) { // Start reading in own goroutine, return on error
if err := conn.ReadEvents(); err != nil {
errChan <- err

2
go.mod
View File

@@ -21,7 +21,7 @@ require (
github.com/cgrates/baningo v0.0.0-20210413080722-004ffd5e429f
github.com/cgrates/birpc v1.3.1-0.20211117095917-5b0ff29f3084
github.com/cgrates/fsock v0.0.0-20231222174700-7257ce894e23
github.com/cgrates/kamevapi v0.0.0-20220525160402-5b8036487a6c
github.com/cgrates/kamevapi v0.0.0-20240307160311-26273f03eedf
github.com/cgrates/ltcache v0.0.0-20210405185848-da943e80c1ab
github.com/cgrates/radigo v0.0.0-20240123163129-491c899df727
github.com/cgrates/rpcclient v0.0.0-20230605090759-8bb5188b73e5

4
go.sum
View File

@@ -53,8 +53,8 @@ github.com/cgrates/birpc v1.3.1-0.20211117095917-5b0ff29f3084 h1:YIEepjEOjeHaFre
github.com/cgrates/birpc v1.3.1-0.20211117095917-5b0ff29f3084/go.mod h1:z/PmNnDPqSQALedKJv5T8+eXIq6XHa9J0St1YsvAVns=
github.com/cgrates/fsock v0.0.0-20231222174700-7257ce894e23 h1:AElRJimochzP6ghx3/sVtV0oPyqiAMwd3ovo4s5YnqM=
github.com/cgrates/fsock v0.0.0-20231222174700-7257ce894e23/go.mod h1:5A9wag324AzIlaDd7tpPDAg26ouUO1orarAq7Vxr4As=
github.com/cgrates/kamevapi v0.0.0-20220525160402-5b8036487a6c h1:ILTMiCcBw80hSe1L0LE3u2U7sFQB/vcFc2JZpvTD4/E=
github.com/cgrates/kamevapi v0.0.0-20220525160402-5b8036487a6c/go.mod h1:R1iZadqJTrjkwWxhK8gVPcYhcWoE4d0A6HZ+y6ZHzys=
github.com/cgrates/kamevapi v0.0.0-20240307160311-26273f03eedf h1:GbMJzvtwdX1OCEmsqSts/cRCIcIMvo8AYtC2dQExWlg=
github.com/cgrates/kamevapi v0.0.0-20240307160311-26273f03eedf/go.mod h1:oEq/JbubkOD2pXHvDy4r7519NkxriONisrnVpkCaNJw=
github.com/cgrates/ltcache v0.0.0-20210405185848-da943e80c1ab h1:dKdAUwrij6vYwewe1WV1+pDSagqGI5JLqjTZZyN2ANo=
github.com/cgrates/ltcache v0.0.0-20210405185848-da943e80c1ab/go.mod h1:9oSG/6gUoab/vKm/eQ3QcX6KeTR0wRw88N33iCnC/k4=
github.com/cgrates/radigo v0.0.0-20240123163129-491c899df727 h1:rhYHlbfEPDNreekd1ZtUYi/NbFm5cEl8twQZ3c/0nYU=

View File

@@ -74,7 +74,9 @@ func (kam *KamailioAgent) Start() error {
go func(k *agents.KamailioAgent) {
if connErr := k.Connect(); connErr != nil &&
!strings.Contains(connErr.Error(), "use of closed network connection") { // if closed by us do not log
utils.Logger.Err(fmt.Sprintf("<%s> error: %s", utils.KamailioAgent, connErr))
if !strings.Contains(connErr.Error(), "KamEvapi") {
utils.Logger.Err(fmt.Sprintf("<%s> error: %s", utils.KamailioAgent, connErr))
}
kam.shdChan.CloseOnce()
}
}(kam.kam)
@@ -98,7 +100,9 @@ func (kam *KamailioAgent) reload(k *agents.KamailioAgent) (err error) {
if strings.Contains(err.Error(), "use of closed network connection") { // if closed by us do not log
return
}
utils.Logger.Err(fmt.Sprintf("<%s> error: %s", utils.KamailioAgent, err))
if !strings.Contains(err.Error(), "KamEvapi") {
utils.Logger.Err(fmt.Sprintf("<%s> error: %s", utils.KamailioAgent, err))
}
kam.shdChan.CloseOnce()
}
return