diff --git a/sessions/libsessions.go b/sessions/libsessions.go index c0814be43..41c68005f 100644 --- a/sessions/libsessions.go +++ b/sessions/libsessions.go @@ -87,6 +87,7 @@ func getSessionTTL(ev *engine.MapEvent, cfgSessionTTL time.Duration, return } +// GetSetCGRID will populate the CGRID key if not present and return it func GetSetCGRID(ev engine.MapEvent) (cgrID string) { cgrID = ev.GetStringIgnoreErrors(utils.CGRID) if cgrID == "" { diff --git a/sessions/session.go b/sessions/session.go index 77b4e903d..7bb921c68 100644 --- a/sessions/session.go +++ b/sessions/session.go @@ -26,11 +26,13 @@ import ( "github.com/cgrates/cgrates/utils" ) +// SessionID is given by an agent as the answer to GetActiveSessionIDs API type SessionID struct { OriginHost string OriginID string } +// CGRID returns the CGRID formated using the SessionID func (s *SessionID) CGRID() string { return utils.Sha1(s.OriginID, s.OriginHost) } @@ -63,6 +65,7 @@ type ExternalSession struct { NextAutoDebit time.Time } +// Session is the main structure to describe a call type Session struct { sync.RWMutex @@ -107,6 +110,7 @@ func (s *Session) Clone() (cln *Session) { return } +// AsExternalSessions returns the session as a list of ExternalSession using all SRuns func (s *Session) AsExternalSessions(tmz, nodeID string) (aSs []*ExternalSession) { aSs = make([]*ExternalSession, len(s.SRuns)) for i, sr := range s.SRuns { @@ -143,6 +147,8 @@ func (s *Session) AsExternalSessions(tmz, nodeID string) (aSs []*ExternalSession } return } + +// AsExternalSession returns the session as an ExternalSession using the SRuns given func (s *Session) AsExternalSession(sr *SRun, tmz, nodeID string) (aS *ExternalSession) { aS = &ExternalSession{ CGRID: s.CGRID, diff --git a/sessions/sessions.go b/sessions/sessions.go index 121b4a688..40a48030a 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1677,6 +1677,7 @@ func (sS *SessionS) BiRPCv1SetPassiveSession(clnt rpcclient.RpcClientConnection, return } +// ArgsReplicateSessions used to specify wich Session to replicate over the given connections type ArgsReplicateSessions struct { CGRID string Passive bool @@ -1755,6 +1756,7 @@ type V1AuthorizeArgs struct { *utils.ArgDispatcher } +// ParseFlags will populate the V1AuthorizeArgs flags func (args *V1AuthorizeArgs) ParseFlags(flags string) { dispatcherFlag := false for _, subsystem := range strings.Split(flags, utils.FIELDS_SEP) { @@ -2035,6 +2037,7 @@ type V1InitSessionArgs struct { *utils.ArgDispatcher } +// ParseFlags will populate the V1InitSessionArgs flags func (args *V1InitSessionArgs) ParseFlags(flags string) { dispatcherFlag := false for _, subsystem := range strings.Split(flags, utils.FIELDS_SEP) { @@ -2071,11 +2074,11 @@ type V1InitSessionReply struct { } // SetMaxUsageNeeded used by agent that use the reply as NavigableMapper -func (v1AuthReply *V1InitSessionReply) SetMaxUsageNeeded(getMaxUsage bool) { - if v1AuthReply == nil { +func (v1Rply *V1InitSessionReply) SetMaxUsageNeeded(getMaxUsage bool) { + if v1Rply == nil { return } - v1AuthReply.getMaxUsage = getMaxUsage + v1Rply.getMaxUsage = getMaxUsage } // AsNavigableMap is part of engine.NavigableMapper interface @@ -2231,6 +2234,7 @@ func (sS *SessionS) BiRPCv1InitiateSession(clnt rpcclient.RpcClientConnection, return } +// V1InitReplyWithDigest is the formated reply type V1InitReplyWithDigest struct { AttributesDigest *string ResourceAllocation *string @@ -2239,6 +2243,7 @@ type V1InitReplyWithDigest struct { StatQueues *string } +// BiRPCv1InitiateSessionWithDigest returns the formated result of InitiateSession func (sS *SessionS) BiRPCv1InitiateSessionWithDigest(clnt rpcclient.RpcClientConnection, args *V1InitSessionArgs, initReply *V1InitReplyWithDigest) (err error) { var initSessionRply V1InitSessionReply @@ -2407,6 +2412,7 @@ func (sS *SessionS) BiRPCv1UpdateSession(clnt rpcclient.RpcClientConnection, return } +// NewV1TerminateSessionArgs creates a new V1TerminateSessionArgs using the given arguments func NewV1TerminateSessionArgs(acnts, resrc, thrds bool, thresholdIDs []string, stats bool, statIDs []string, cgrEv *utils.CGREvent, @@ -2428,6 +2434,7 @@ func NewV1TerminateSessionArgs(acnts, resrc, return } +// V1TerminateSessionArgs is used as argumen for TerminateSession type V1TerminateSessionArgs struct { TerminateSession bool ReleaseResources bool @@ -2439,6 +2446,7 @@ type V1TerminateSessionArgs struct { *utils.ArgDispatcher } +// ParseFlags will populate the V1TerminateSessionArgs flags func (args *V1TerminateSessionArgs) ParseFlags(flags string) { dispatcherFlag := false for _, subsystem := range strings.Split(flags, utils.FIELDS_SEP) { @@ -2726,6 +2734,7 @@ type V1ProcessMessageArgs struct { *utils.ArgDispatcher } +// ParseFlags will populate the V1ProcessMessageArgs flags func (args *V1ProcessMessageArgs) ParseFlags(flags string) { dispatcherFlag := false for _, subsystem := range strings.Split(flags, utils.FIELDS_SEP) { @@ -3279,6 +3288,7 @@ func (sS *SessionS) BiRPCv1ForceDisconnect(clnt rpcclient.RpcClientConnection, return nil } +// BiRPCv1RegisterInternalBiJSONConn will register the client for a bidirectional comunication func (sS *SessionS) BiRPCv1RegisterInternalBiJSONConn(clnt rpcclient.RpcClientConnection, ign string, reply *string) error { sS.RegisterIntBiJConn(clnt)