diff --git a/agents/astagent.go b/agents/astagent.go index 5027f5e54..374859b9d 100644 --- a/agents/astagent.go +++ b/agents/astagent.go @@ -411,7 +411,7 @@ func (sma *AsteriskAgent) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, // BiRPCv1CapsError is used to return error when the caps limit is hit func (sma *AsteriskAgent) BiRPCv1CapsError(clnt rpcclient.ClientConnector, args interface{}, reply *string) (err error) { - return utils.ErrMaxConcurentRPCExceeded + return utils.ErrMaxConcurrentRPCExceeded } // Handlers is used to implement the rpcclient.BiRPCConector interface diff --git a/agents/diamagent.go b/agents/diamagent.go index fc815c74a..0c2401e89 100644 --- a/agents/diamagent.go +++ b/agents/diamagent.go @@ -604,7 +604,7 @@ func (da *DiameterAgent) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, a // BiRPCv1CapsError is used to return error when the caps limit is hit func (da *DiameterAgent) BiRPCv1CapsError(clnt rpcclient.ClientConnector, args interface{}, reply *string) (err error) { - return utils.ErrMaxConcurentRPCExceeded + return utils.ErrMaxConcurrentRPCExceeded } // Handlers is used to implement the rpcclient.BiRPCConector interface diff --git a/agents/fsagent.go b/agents/fsagent.go index ed23a6588..2395dfc58 100644 --- a/agents/fsagent.go +++ b/agents/fsagent.go @@ -516,7 +516,7 @@ func (fsa *FSsessions) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, arg // BiRPCv1CapsError is used to return error when the caps limit is hit func (fsa *FSsessions) BiRPCv1CapsError(clnt rpcclient.ClientConnector, args interface{}, reply *string) (err error) { - return utils.ErrMaxConcurentRPCExceeded + return utils.ErrMaxConcurrentRPCExceeded } // Handlers is used to implement the rpcclient.BiRPCConector interface diff --git a/agents/kamagent.go b/agents/kamagent.go index 5eb62d2f4..cfede5a25 100644 --- a/agents/kamagent.go +++ b/agents/kamagent.go @@ -484,7 +484,7 @@ func (ka *KamailioAgent) BiRPCv1WarnDisconnect(clnt rpcclient.ClientConnector, a // BiRPCv1CapsError is used to return error when the caps limit is hit func (ka *KamailioAgent) BiRPCv1CapsError(clnt rpcclient.ClientConnector, args interface{}, reply *string) (err error) { - return utils.ErrMaxConcurentRPCExceeded + return utils.ErrMaxConcurrentRPCExceeded } // Handlers is used to implement the rpcclient.BiRPCConector interface diff --git a/apier/v1/caps_it_test.go b/apier/v1/caps_it_test.go index 70f644bcd..1edc9c418 100644 --- a/apier/v1/caps_it_test.go +++ b/apier/v1/caps_it_test.go @@ -180,7 +180,7 @@ func testCapsOnHTTPBusy(t *testing.T) { return } resp.Body.Close() - if strings.Contains(string(contents), utils.ErrMaxConcurentRPCExceeded.Error()) { + if strings.Contains(string(contents), utils.ErrMaxConcurrentRPCExceeded.Error()) { lock.Lock() fldAPIs++ lock.Unlock() @@ -244,9 +244,9 @@ func testCapsOnBiJSONBusy(t *testing.T) { for waiting { select { case err := <-errChan: - if err.Error() != utils.ErrMaxConcurentRPCExceeded.Error() { + if err.Error() != utils.ErrMaxConcurrentRPCExceeded.Error() { t.Errorf("expected: <%+v>, \nreceived: <%+v>", - utils.ErrMaxConcurentRPCExceeded, err) + utils.ErrMaxConcurrentRPCExceeded, err) } case <-waitCh: waiting = false diff --git a/apier/v1/smgbirpc.go b/apier/v1/smgbirpc.go index fb92a4bc8..808a9b2e9 100644 --- a/apier/v1/smgbirpc.go +++ b/apier/v1/smgbirpc.go @@ -68,5 +68,5 @@ func (smgv1 *SMGenericV1) BiRPCV1ProcessCDR(clnt *rpc2.Client, // BiRPCv1CapsError is used to return error when the caps limit is hit func (smgv1 *SMGenericV1) BiRPCV1CapsError(clnt *rpc2.Client, args interface{}, reply *string) (err error) { - return utils.ErrMaxConcurentRPCExceeded + return utils.ErrMaxConcurrentRPCExceeded } diff --git a/cores/caps.go b/cores/caps.go index 3be9eb162..1b473a678 100644 --- a/cores/caps.go +++ b/cores/caps.go @@ -101,8 +101,8 @@ func (c *capsServerCodec) ReadRequestBody(x interface{}) error { return c.sc.ReadRequestBody(x) } func (c *capsServerCodec) WriteResponse(r *rpc.Response, x interface{}) error { - if r.Error == utils.ErrMaxConcurentRPCExceededNoCaps.Error() { - r.Error = utils.ErrMaxConcurentRPCExceeded.Error() + if r.Error == utils.ErrMaxConcurrentRPCExceededNoCaps.Error() { + r.Error = utils.ErrMaxConcurrentRPCExceeded.Error() } else { defer c.caps.Deallocate() } @@ -164,7 +164,8 @@ type capsBiRPCCodec struct { // ReadHeader must read a message and populate either the request // or the response by inspecting the incoming message. func (c *capsBiRPCCodec) ReadHeader(req *rpc2.Request, resp *rpc2.Response) (err error) { - if err = c.sc.ReadHeader(req, resp); err != nil || req.Method == utils.EmptyString { + if err = c.sc.ReadHeader(req, resp); err != nil || + req.Method == utils.EmptyString { // caps will not process replies return } if err = c.caps.Allocate(); err != nil { @@ -191,8 +192,8 @@ func (c *capsBiRPCCodec) WriteRequest(req *rpc2.Request, x interface{}) error { // WriteResponse must be safe for concurrent use by multiple goroutines. func (c *capsBiRPCCodec) WriteResponse(r *rpc2.Response, x interface{}) error { - if r.Error == utils.ErrMaxConcurentRPCExceededNoCaps.Error() { - r.Error = utils.ErrMaxConcurentRPCExceeded.Error() + if r.Error == utils.ErrMaxConcurrentRPCExceededNoCaps.Error() { + r.Error = utils.ErrMaxConcurrentRPCExceeded.Error() } else { defer c.caps.Deallocate() } diff --git a/cores/caps_test.go b/cores/caps_test.go index 935dc51e0..38d906707 100644 --- a/cores/caps_test.go +++ b/cores/caps_test.go @@ -80,8 +80,8 @@ func TestNewCapsServerCodec(t *testing.T) { t.Fatal(err) } - if err = codec.ReadRequestBody("args"); err != utils.ErrMaxConcurentRPCExceededNoCaps { - t.Errorf("Expected error: %v ,received: %v ", utils.ErrMaxConcurentRPCExceededNoCaps, err) + if err = codec.ReadRequestBody("args"); err != utils.ErrMaxConcurrentRPCExceededNoCaps { + t.Errorf("Expected error: %v ,received: %v ", utils.ErrMaxConcurrentRPCExceededNoCaps, err) } if err = codec.WriteResponse(&rpc.Response{ @@ -93,7 +93,7 @@ func TestNewCapsServerCodec(t *testing.T) { } if err = codec.WriteResponse(&rpc.Response{ - Error: utils.ErrMaxConcurentRPCExceededNoCaps.Error(), + Error: utils.ErrMaxConcurrentRPCExceededNoCaps.Error(), Seq: 0, ServiceMethod: utils.CoreSv1Ping, }, "reply"); err != nil { @@ -184,8 +184,8 @@ func TestNewCapsBiRPCCodec(t *testing.T) { t.Fatal(err) } - if err = codec.ReadRequestBody("args"); err != utils.ErrMaxConcurentRPCExceededNoCaps { - t.Errorf("Expected error: %v ,received: %v ", utils.ErrMaxConcurentRPCExceededNoCaps, err) + if err = codec.ReadRequestBody("args"); err != utils.ErrMaxConcurrentRPCExceededNoCaps { + t.Errorf("Expected error: %v ,received: %v ", utils.ErrMaxConcurrentRPCExceededNoCaps, err) } if err = codec.WriteResponse(&rpc2.Response{ @@ -207,7 +207,7 @@ func TestNewCapsBiRPCCodec(t *testing.T) { } if err = codec.WriteResponse(&rpc2.Response{ - Error: utils.ErrMaxConcurentRPCExceededNoCaps.Error(), + Error: utils.ErrMaxConcurrentRPCExceededNoCaps.Error(), Seq: 0, }, "reply"); err != nil { t.Fatal(err) diff --git a/engine/caps.go b/engine/caps.go index 6cdeccc8a..f372f0f74 100644 --- a/engine/caps.go +++ b/engine/caps.go @@ -55,7 +55,7 @@ func (cR *Caps) Allocate() (err error) { switch cR.strategy { case utils.MetaBusy: if len(cR.aReqs) == cap(cR.aReqs) { - return utils.ErrMaxConcurentRPCExceededNoCaps + return utils.ErrMaxConcurrentRPCExceededNoCaps } fallthrough case utils.MetaQueue: diff --git a/engine/caps_test.go b/engine/caps_test.go index a37cd10eb..bc511135e 100644 --- a/engine/caps_test.go +++ b/engine/caps_test.go @@ -47,8 +47,8 @@ func TestNewCaps(t *testing.T) { if al := cs.Allocated(); al != 0 { t.Errorf("Expected: %v ,received: %v", 0, al) } - if err := cs.Allocate(); err != utils.ErrMaxConcurentRPCExceededNoCaps { - t.Errorf("Expected: %v ,received: %v", utils.ErrMaxConcurentRPCExceededNoCaps, err) + if err := cs.Allocate(); err != utils.ErrMaxConcurrentRPCExceededNoCaps { + t.Errorf("Expected: %v ,received: %v", utils.ErrMaxConcurrentRPCExceededNoCaps, err) } cs = NewCaps(1, utils.MetaBusy) if err := cs.Allocate(); err != nil { diff --git a/sessions/sessions.go b/sessions/sessions.go index 87f70ae9e..51d2db300 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -4136,7 +4136,7 @@ func (sS *SessionS) BiRPCv1STIRIdentity(clnt rpcclient.ClientConnector, // BiRPCv1STIRIdentity the API for STIR header creation func (sS *SessionS) BiRPCv1CapsError(clnt rpcclient.ClientConnector, args interface{}, identity *string) (err error) { - return utils.ErrMaxConcurentRPCExceeded + return utils.ErrMaxConcurrentRPCExceeded } // Handlers bidirectional methods following diff --git a/utils/errors.go b/utils/errors.go index 8a535d2b6..6c2506665 100644 --- a/utils/errors.go +++ b/utils/errors.go @@ -25,59 +25,59 @@ import ( ) var ( - ErrNoMoreData = errors.New("NO_MORE_DATA") - ErrNotImplemented = errors.New("NOT_IMPLEMENTED") - ErrNotFound = errors.New("NOT_FOUND") - ErrDSPHostNotFound = errors.New("DSP_HOST_NOT_FOUND") - ErrDSPProfileNotFound = errors.New("DSP_PROFILE_NOT_FOUND") - ErrTimedOut = errors.New("TIMED_OUT") - ErrServerError = errors.New("SERVER_ERROR") - ErrMaxRecursionDepth = errors.New("MAX_RECURSION_DEPTH") - ErrMandatoryIeMissing = errors.New("MANDATORY_IE_MISSING") - ErrExists = errors.New("EXISTS") - ErrBrokenReference = errors.New("BROKEN_REFERENCE") - ErrParserError = errors.New("PARSER_ERROR") - ErrInvalidPath = errors.New("INVALID_PATH") - ErrInvalidKey = errors.New("INVALID_KEY") - ErrUnauthorizedDestination = errors.New("UNAUTHORIZED_DESTINATION") - ErrRatingPlanNotFound = errors.New("RATING_PLAN_NOT_FOUND") - ErrAccountNotFound = errors.New("ACCOUNT_NOT_FOUND") - ErrAccountDisabled = errors.New("ACCOUNT_DISABLED") - ErrInsufficientCredit = errors.New("INSUFFICIENT_CREDIT") - ErrNotConvertible = errors.New("NOT_CONVERTIBLE") - ErrResourceUnavailable = errors.New("RESOURCE_UNAVAILABLE") - ErrResourceUnauthorized = errors.New("RESOURCE_UNAUTHORIZED") - ErrNoActiveSession = errors.New("NO_ACTIVE_SESSION") - ErrPartiallyExecuted = errors.New("PARTIALLY_EXECUTED") - ErrMaxUsageExceeded = errors.New("MAX_USAGE_EXCEEDED") - ErrMaxCostExceeded = errors.New("MAX_COST_EXCEEDED") - ErrFilterNotPassingNoCaps = errors.New("filter not passing") - ErrNotConvertibleNoCaps = errors.New("not convertible") - ErrMandatoryIeMissingNoCaps = errors.New("mandatory information missing") - ErrUnauthorizedApi = errors.New("UNAUTHORIZED_API") - ErrUnknownApiKey = errors.New("UNKNOWN_API_KEY") - ErrReqUnsynchronized = errors.New("REQ_UNSYNCHRONIZED") - ErrUnsupporteServiceMethod = errors.New("UNSUPPORTED_SERVICE_METHOD") - ErrDisconnected = errors.New("DISCONNECTED") - ErrReplyTimeout = errors.New("REPLY_TIMEOUT") - ErrSessionNotFound = errors.New("SESSION_NOT_FOUND") - ErrJsonIncompleteComment = errors.New("JSON_INCOMPLETE_COMMENT") - ErrNotEnoughParameters = errors.New("NotEnoughParameters") - ErrNotConnected = errors.New("NOT_CONNECTED") - RalsErrorPrfx = "RALS_ERROR" - DispatcherErrorPrefix = "DISPATCHER_ERROR" - RateSErrPrfx = "RATES_ERROR" - ErrUnsupportedFormat = errors.New("UNSUPPORTED_FORMAT") - ErrNoDatabaseConn = errors.New("NO_DATABASE_CONNECTION") - ErrMaxIncrementsExceeded = errors.New("MAX_INCREMENTS_EXCEEDED") - ErrIndexOutOfBounds = errors.New("INDEX_OUT_OF_BOUNDS") - ErrWrongPath = errors.New("WRONG_PATH") - ErrServiceAlreadyRunning = fmt.Errorf("service already running") - ErrMaxConcurentRPCExceededNoCaps = errors.New("max concurent rpc exceeded") // on internal we return this error for concureq - ErrMaxConcurentRPCExceeded = errors.New("MAX_CONCURENT_RPC_EXCEEDED") // but the codec will rewrite it with this one to be sure that we corectly dealocate the request - ErrMaxIterationsReached = errors.New("maximum iterations reached") - ErrNegative = errors.New("NEGATIVE") - ErrCastFailed = errors.New("CAST_FAILED") + ErrNoMoreData = errors.New("NO_MORE_DATA") + ErrNotImplemented = errors.New("NOT_IMPLEMENTED") + ErrNotFound = errors.New("NOT_FOUND") + ErrDSPHostNotFound = errors.New("DSP_HOST_NOT_FOUND") + ErrDSPProfileNotFound = errors.New("DSP_PROFILE_NOT_FOUND") + ErrTimedOut = errors.New("TIMED_OUT") + ErrServerError = errors.New("SERVER_ERROR") + ErrMaxRecursionDepth = errors.New("MAX_RECURSION_DEPTH") + ErrMandatoryIeMissing = errors.New("MANDATORY_IE_MISSING") + ErrExists = errors.New("EXISTS") + ErrBrokenReference = errors.New("BROKEN_REFERENCE") + ErrParserError = errors.New("PARSER_ERROR") + ErrInvalidPath = errors.New("INVALID_PATH") + ErrInvalidKey = errors.New("INVALID_KEY") + ErrUnauthorizedDestination = errors.New("UNAUTHORIZED_DESTINATION") + ErrRatingPlanNotFound = errors.New("RATING_PLAN_NOT_FOUND") + ErrAccountNotFound = errors.New("ACCOUNT_NOT_FOUND") + ErrAccountDisabled = errors.New("ACCOUNT_DISABLED") + ErrInsufficientCredit = errors.New("INSUFFICIENT_CREDIT") + ErrNotConvertible = errors.New("NOT_CONVERTIBLE") + ErrResourceUnavailable = errors.New("RESOURCE_UNAVAILABLE") + ErrResourceUnauthorized = errors.New("RESOURCE_UNAUTHORIZED") + ErrNoActiveSession = errors.New("NO_ACTIVE_SESSION") + ErrPartiallyExecuted = errors.New("PARTIALLY_EXECUTED") + ErrMaxUsageExceeded = errors.New("MAX_USAGE_EXCEEDED") + ErrMaxCostExceeded = errors.New("MAX_COST_EXCEEDED") + ErrFilterNotPassingNoCaps = errors.New("filter not passing") + ErrNotConvertibleNoCaps = errors.New("not convertible") + ErrMandatoryIeMissingNoCaps = errors.New("mandatory information missing") + ErrUnauthorizedApi = errors.New("UNAUTHORIZED_API") + ErrUnknownApiKey = errors.New("UNKNOWN_API_KEY") + ErrReqUnsynchronized = errors.New("REQ_UNSYNCHRONIZED") + ErrUnsupporteServiceMethod = errors.New("UNSUPPORTED_SERVICE_METHOD") + ErrDisconnected = errors.New("DISCONNECTED") + ErrReplyTimeout = errors.New("REPLY_TIMEOUT") + ErrSessionNotFound = errors.New("SESSION_NOT_FOUND") + ErrJsonIncompleteComment = errors.New("JSON_INCOMPLETE_COMMENT") + ErrNotEnoughParameters = errors.New("NotEnoughParameters") + ErrNotConnected = errors.New("NOT_CONNECTED") + RalsErrorPrfx = "RALS_ERROR" + DispatcherErrorPrefix = "DISPATCHER_ERROR" + RateSErrPrfx = "RATES_ERROR" + ErrUnsupportedFormat = errors.New("UNSUPPORTED_FORMAT") + ErrNoDatabaseConn = errors.New("NO_DATABASE_CONNECTION") + ErrMaxIncrementsExceeded = errors.New("MAX_INCREMENTS_EXCEEDED") + ErrIndexOutOfBounds = errors.New("INDEX_OUT_OF_BOUNDS") + ErrWrongPath = errors.New("WRONG_PATH") + ErrServiceAlreadyRunning = fmt.Errorf("service already running") + ErrMaxConcurrentRPCExceededNoCaps = errors.New("max concurrent rpc exceeded") // on internal we return this error for concureq + ErrMaxConcurrentRPCExceeded = errors.New("MAX_CONCURRENT_RPC_EXCEEDED") // but the codec will rewrite it with this one to be sure that we corectly dealocate the request + ErrMaxIterationsReached = errors.New("maximum iterations reached") + ErrNegative = errors.New("NEGATIVE") + ErrCastFailed = errors.New("CAST_FAILED") ErrMap = map[string]error{ ErrNoMoreData.Error(): ErrNoMoreData,