Prevents a situation where when attempting to decode a string into a nil
interface, the decoded value would be the encoded slice of bytes instead
of the string we need.
- Converting directly from a D to an M is deprecated. We are now decoding
directly in a M.
- Used errors.As and errors.Is for proper error comparison and assertion
- Streamlined function parameters and removed redundancies
- Revised sloppy reassignments and added missing error checks
- Shortened and reorganized function structure for improved readability
Remove the custom time decoder used for mongo BSON
datetime values. The custom decoder was only converting these values
into UTC and was not any different from the default time.Time
decoder in the MongoDB driver, which also handles BSON string, int64,
and document values.
- Set (but comment) serverAPI options (currently distinct api and
create.size BSON field are deprecated + possible others that are untested)
- Rename and refactor 'TimeDecodeValue1' to 'decodeTimeValue', add
nil case handling
- Implement 'buildURL' function to connect to mongo (can also be
used for mysql and postgres)
- Update function names, variable names, and comments for clarity
- Replace 'bsonx.Regex' with the Regex primitive for v1.12 compatibility
- Use simple concatenation instead of Sprintf
- Declare 'timeType' locally, replace global 'tTime'
- Use 'RegisterTypeDecoder' to replace deprecated 'RegisterDecoder'
- Simplify several functions without altering functionality
- Remove redundant 'storageType' field in 'mongoStorage',
use 'isDataDB' instead
The purpose of this is to check whether RoundingDecimals was set from the fields configuration.
If it wasn't, we are going to be using the RoundingDecimals dictated by the general subsection.
The FormatCost function in cdr.go now accepts an additional parameter of type *config.RSRParser. This is
then used to extract the value from its path as opposed to always using the value of the Cost field directly.
Improved the unit test for the FormatCost function. Now it has become a table-driven test and it handles
cases when the cost is retrieved from different fields other than from the CDR.
Add bidirectional support for sessions while maintaining changing the
current rpc service registration method. Modified methods in
sessionsbirpc.go file to satisfy the birpc.ClientConnector interface
and removed BiRPC prefix before creating the service that's to be
registered.
Replace all instances of rpcclient.ClientConnector with birpc.ClientConnector.
Pass context, maxReconnectInterval, delayFunc and birpcClient to rpcclient
constructors.
Remove redundant time.Duration conversions (e.g. time.Duration(1*time.Second)
now becomes time.Second.
Add context where needed (context.Background() for tests, context.TODO()
for places where it should be passed from somewhere else).
Implement that functionality of the SessionSv1.Sleep call, in sessions/sessions
instead of apier/v1.
Make changes in utils/server.go (replacing the old rpc2 library with github.com/cgrates/birpc).
Change the way we register birpc methods for sessions in services, using a helper function
defined in engine/libengine.go.
Implement a function that takes as parameters a list of filters
and it checks only whether the inline filters are valid.
Add it inside the functions that load the profiles inside
the TPReader. This prevents the case where it returns error
after indexing had already started when it is already too
late.
Add unit tests for the implemented function.
The (*CDRServer).processEvent function is now called processEvents and can
be passed an array of CGREvents instead of only one. This was done because
when calling the RateCDRs API we want to first refund all CDRs before
starting to debit again.
The rerate parameter is now no longer hardcoded to true for the RateCDRs API.If
required, the "*rerate" flag must be provided by the caller.
Now, the refundEventCost function returns an additional boolean, that signals
whether the refund occured or didn't.
If the reRate parameter is set to true, also set refund to true.
In case CostDetails is not populated, retrieve it from StorDB if possible
and add it to the CGREvent before converting to CDRs. Set CostDetails back
to nil once the refund goes through.
Remove the refund logic from within the store block.
Now that the refund happens before the debit, revise the expected values for
the "testV1CDRsProcessEventWithRefund" subtest within the
apier/v1/cdrs_it_test.go file.
Add an integration test for the following scenario:
-create one account with one balance of 1 free minute and rating for the rest.
-send one CDR of two minutes with ProcessEvent. This should consume 60s out of
the free balance and charge 60s. The SetupTime in the CDR should be 1 hour after
the second CDR.
-send the second CDR with an usage of 2m. This should be charged entirely.
-send a RateCDR API call with OrderBy: "SetupTime". This should rerate the two
CDRs from above and change their order of rating.