mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 10:06:24 +05:00
Rename agents API object: SessionSv1 to AgentV1
This commit is contained in:
committed by
Dan Christian Bogos
parent
f9d1c0f0e1
commit
838832c2b2
@@ -64,7 +64,7 @@ func NewAsteriskAgent(cgrCfg *config.CGRConfig, astConnIdx int,
|
||||
connMgr: connMgr,
|
||||
eventsCache: make(map[string]*utils.CGREvent),
|
||||
}
|
||||
srv, err := birpc.NewServiceWithMethodsRename(sma, utils.SessionSv1, true, func(oldFn string) (newFn string) {
|
||||
srv, err := birpc.NewServiceWithMethodsRename(sma, utils.AgentV1, true, func(oldFn string) (newFn string) {
|
||||
return strings.TrimPrefix(oldFn, "V1")
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -57,7 +57,7 @@ func NewDiameterAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS,
|
||||
dpa: make(map[string]chan *diam.Message),
|
||||
peers: make(map[string]diam.Conn),
|
||||
}
|
||||
srv, err := birpc.NewServiceWithMethodsRename(da, utils.SessionSv1, true, func(oldFn string) (newFn string) {
|
||||
srv, err := birpc.NewServiceWithMethodsRename(da, utils.AgentV1, true, func(oldFn string) (newFn string) {
|
||||
return strings.TrimPrefix(oldFn, "V1")
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -42,7 +42,7 @@ func NewFSsessions(fsAgentConfig *config.FsAgentCfg,
|
||||
timezone: timezone,
|
||||
connMgr: connMgr,
|
||||
}
|
||||
srv, err := birpc.NewServiceWithMethodsRename(fsa, utils.SessionSv1, true, func(oldFn string) (newFn string) {
|
||||
srv, err := birpc.NewServiceWithMethodsRename(fsa, utils.AgentV1, true, func(oldFn string) (newFn string) {
|
||||
return strings.TrimPrefix(oldFn, "V1")
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -54,7 +54,7 @@ func NewKamailioAgent(kaCfg *config.KamAgentCfg,
|
||||
conns: make([]*kamevapi.KamEvapi, len(kaCfg.EvapiConns)),
|
||||
activeSessionIDs: make(chan []*sessions.SessionID),
|
||||
}
|
||||
srv, err := birpc.NewServiceWithMethodsRename(ka, utils.SessionSv1, true, func(oldFn string) (newFn string) {
|
||||
srv, err := birpc.NewServiceWithMethodsRename(ka, utils.AgentV1, true, func(oldFn string) (newFn string) {
|
||||
return strings.TrimPrefix(oldFn, "V1")
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -54,8 +54,8 @@ func NewRadiusAgent(cgrCfg *config.CGRConfig, filterS *engine.FilterS,
|
||||
connMgr: connMgr,
|
||||
}
|
||||
|
||||
// Register RadiusAgent methods whose names start with "V1" under the "SessionSv1" object name.
|
||||
srv, err := birpc.NewServiceWithMethodsRename(radAgent, utils.SessionSv1, true, func(oldFn string) (newFn string) {
|
||||
// Register RadiusAgent methods whose names start with "V1" under the "AgentV1" object name.
|
||||
srv, err := birpc.NewServiceWithMethodsRename(radAgent, utils.AgentV1, true, func(oldFn string) (newFn string) {
|
||||
return strings.TrimPrefix(oldFn, "V1")
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
@@ -410,7 +410,7 @@ func (sS *SessionS) forceSTerminate(s *Session, extraUsage time.Duration, tUsage
|
||||
go func() {
|
||||
var rply string
|
||||
if err := clntConn.conn.Call(context.TODO(),
|
||||
utils.SessionSv1DisconnectSession,
|
||||
utils.AgentV1DisconnectSession,
|
||||
utils.AttrDisconnectSession{
|
||||
EventStart: s.EventStart,
|
||||
Reason: ErrForcedDisconnect.Error()},
|
||||
@@ -768,10 +768,10 @@ func (sS *SessionS) disconnectSession(s *Session, rsn string) (err error) {
|
||||
clnt := sS.biJClnt(s.ClientConnID)
|
||||
if clnt == nil {
|
||||
return fmt.Errorf("calling %s requires bidirectional JSON connection, connID: <%s>",
|
||||
utils.SessionSv1DisconnectSession, s.ClientConnID)
|
||||
utils.AgentV1DisconnectSession, s.ClientConnID)
|
||||
}
|
||||
s.EventStart[utils.Usage] = s.totalUsage() // Set the usage to total one debitted
|
||||
servMethod := utils.SessionSv1DisconnectSession
|
||||
servMethod := utils.AgentV1DisconnectSession
|
||||
if clnt.proto == 0 { // compatibility with OpenSIPS 2.3
|
||||
servMethod = "SMGClientV1.DisconnectSession"
|
||||
}
|
||||
@@ -794,10 +794,10 @@ func (sS *SessionS) warnSession(connID string, ev map[string]any) (err error) {
|
||||
clnt := sS.biJClnt(connID)
|
||||
if clnt == nil {
|
||||
return fmt.Errorf("calling %s requires bidirectional JSON connection, connID: <%s>",
|
||||
utils.SessionSv1WarnDisconnect, connID)
|
||||
utils.AgentV1WarnDisconnect, connID)
|
||||
}
|
||||
var rply string
|
||||
if err = clnt.conn.Call(context.TODO(), utils.SessionSv1WarnDisconnect,
|
||||
if err = clnt.conn.Call(context.TODO(), utils.AgentV1WarnDisconnect,
|
||||
ev, &rply); err != nil {
|
||||
if err != utils.ErrNotImplemented {
|
||||
utils.Logger.Warning(fmt.Sprintf("<%s> failed to warn session: <%s>, err: <%s>",
|
||||
@@ -1379,7 +1379,7 @@ func (sS *SessionS) syncSessions() {
|
||||
wg.Add(1)
|
||||
go func(c *biJClient) { // query all connections at once
|
||||
var queriedSessionIDs []*SessionID
|
||||
if err := c.conn.Call(context.TODO(), utils.SessionSv1GetActiveSessionIDs,
|
||||
if err := c.conn.Call(context.TODO(), utils.AgentV1GetActiveSessionIDs,
|
||||
utils.EmptyString, &queriedSessionIDs); err != nil &&
|
||||
err.Error() != utils.ErrNoActiveSession.Error() {
|
||||
utils.Logger.Warning(
|
||||
@@ -4006,7 +4006,7 @@ func (sS *SessionS) sendRar(ctx *context.Context, s *Session, apiOpts map[string
|
||||
clnt := sS.biJClnt(s.ClientConnID)
|
||||
if clnt == nil {
|
||||
return fmt.Errorf("calling %s requires bidirectional JSON connection, connID: <%s>",
|
||||
utils.SessionSv1AlterSessions, s.ClientConnID)
|
||||
utils.AgentV1AlterSessions, s.ClientConnID)
|
||||
}
|
||||
|
||||
// Merge parameter event with the session event. Losing the EventStart OriginID
|
||||
@@ -4027,7 +4027,7 @@ func (sS *SessionS) sendRar(ctx *context.Context, s *Session, apiOpts map[string
|
||||
}
|
||||
|
||||
var rply string
|
||||
if err = clnt.conn.Call(ctx, utils.SessionSv1AlterSessions, args, &rply); err == utils.ErrNotImplemented {
|
||||
if err = clnt.conn.Call(ctx, utils.AgentV1AlterSessions, args, &rply); err == utils.ErrNotImplemented {
|
||||
err = nil
|
||||
}
|
||||
return
|
||||
@@ -4079,7 +4079,7 @@ func (sS *SessionS) BiRPCv1DisconnectPeer(ctx *context.Context,
|
||||
}
|
||||
sS.biJMux.RUnlock()
|
||||
for ID, clnt := range clients {
|
||||
if err = clnt.conn.Call(context.TODO(), utils.SessionSv1DisconnectPeer, args, reply); err != nil && err != utils.ErrNotImplemented {
|
||||
if err = clnt.conn.Call(ctx, utils.AgentV1DisconnectPeer, args, reply); err != nil && err != utils.ErrNotImplemented {
|
||||
utils.Logger.Warning(
|
||||
fmt.Sprintf(
|
||||
"<%s> failed sending DPR for connection with id: <%s>, err: <%s>",
|
||||
|
||||
@@ -1650,7 +1650,6 @@ const (
|
||||
SessionSv1ProcessMessage = "SessionSv1.ProcessMessage"
|
||||
SessionSv1ProcessEvent = "SessionSv1.ProcessEvent"
|
||||
SessionSv1GetCost = "SessionSv1.GetCost"
|
||||
SessionSv1DisconnectSession = "SessionSv1.DisconnectSession"
|
||||
SessionSv1GetActiveSessions = "SessionSv1.GetActiveSessions"
|
||||
SessionSv1GetActiveSessionsCount = "SessionSv1.GetActiveSessionsCount"
|
||||
SessionSv1ForceDisconnect = "SessionSv1.ForceDisconnect"
|
||||
@@ -1658,7 +1657,6 @@ const (
|
||||
SessionSv1GetPassiveSessionsCount = "SessionSv1.GetPassiveSessionsCount"
|
||||
SessionSv1SetPassiveSession = "SessionSv1.SetPassiveSession"
|
||||
SessionSv1Ping = "SessionSv1.Ping"
|
||||
SessionSv1GetActiveSessionIDs = "SessionSv1.GetActiveSessionIDs"
|
||||
SessionSv1RegisterInternalBiJSONConn = "SessionSv1.RegisterInternalBiJSONConn"
|
||||
SessionSv1ReplicateSessions = "SessionSv1.ReplicateSessions"
|
||||
SessionSv1ActivateSessions = "SessionSv1.ActivateSessions"
|
||||
@@ -1666,13 +1664,22 @@ const (
|
||||
SMGenericV1InitiateSession = "SMGenericV1.InitiateSession"
|
||||
SessionSv1AlterSessions = "SessionSv1.AlterSessions"
|
||||
SessionSv1DisconnectPeer = "SessionSv1.DisconnectPeer"
|
||||
SessionSv1WarnDisconnect = "SessionSv1.WarnDisconnect"
|
||||
SessionSv1STIRAuthenticate = "SessionSv1.STIRAuthenticate"
|
||||
SessionSv1STIRIdentity = "SessionSv1.STIRIdentity"
|
||||
SessionSv1Sleep = "SessionSv1.Sleep"
|
||||
SessionSv1CapsError = "SessionSv1.CapsError"
|
||||
)
|
||||
|
||||
// Agent APIs
|
||||
const (
|
||||
AgentV1 = "AgentV1"
|
||||
AgentV1DisconnectSession = "AgentV1.DisconnectSession"
|
||||
AgentV1GetActiveSessionIDs = "AgentV1.GetActiveSessionIDs"
|
||||
AgentV1AlterSessions = "AgentV1.AlterSessions"
|
||||
AgentV1DisconnectPeer = "AgentV1.DisconnectPeer"
|
||||
AgentV1WarnDisconnect = "AgentV1.WarnDisconnect"
|
||||
)
|
||||
|
||||
// Responder APIs
|
||||
const (
|
||||
Responder = "Responder"
|
||||
|
||||
Reference in New Issue
Block a user