Commit Graph

90 Commits

Author SHA1 Message Date
arberkatellari
b8cc20bb7c Add sqlBatchSize to ERS SQL OPTS and adjust delete functionality 2025-01-14 17:04:18 +01:00
arberkatellari
2252765e93 Add 'ees_ids' field to ERs readers config 2024-12-20 17:33:45 +01:00
armirveliaj
a2b86e1a02 Add coverage tests on config 2024-12-17 18:19:59 +01:00
arberkatellari
041b14fa03 Improvements to ERS SQL filters 2024-12-03 18:36:22 +01:00
ionutboangiu
9d3e5e62a6 Implement getter method for EventExporterCfg (by ID)
Removed redundant getter method for default EventExporterCfg.
2024-11-27 16:50:47 +01:00
ionutboangiu
a4925a68db Remove duplicate sep param from ers load method 2024-11-27 16:50:47 +01:00
gezimbll
e48eb5df13 added StartDelay for ers processing 2024-11-15 20:58:10 +01:00
ionutboangiu
962000656b Remove global err used by tests
Removed many leftover error checks for NewDefaultCGRConfig,
which does not return an error anymore.
2024-07-14 14:08:49 +02:00
armirveliaj
f2cb8bc07c Add coverage unit test for config pkg 2024-05-18 16:56:47 +02:00
gezimbll
cff5d22913 fixing unit tests on ersCfg 2024-03-13 18:26:01 +01:00
ionutboangiu
0c91933065 Revise ERs event exporting
Add ees_success_ids and ees_failed_ids fields in reader config. The
former will be used to set EeIDs when the event processing returns
no error, while the latter will be used otherwise.

Add config sanity checks for the added options.

Remove Processed opts and everything related to them since they should
not be used anymore.

Fixed test compilation errors caused by the change.
2023-11-29 16:21:51 +01:00
ionutboangiu
c282d40201 Implement reconnect logic for AMQP EventReader
Implemented functionality that handles reconnecting to the amqp server
and reinitializing the amqp channel in case of errors and timeouts. This
is handled by a goroutine created in the client constructor (it also
handles the initial connect/init).

Reconnects and reinits will use a fibonacci backoff strategy, and the
attempt amount and max waiting interval can be adjusted by the
'reconnects' and 'max_reconnect_interval' config options.

Messages that fail processing are now dropped instead of being requeued,
preventing infinite processing loops. However, this means that the
messages are lost. Handling failed messages will need to be addressed
separately.

'concurrent_requests' will now set the prefetch count. Setting the
prefetch count using the Qos function was able to replace our old
approach that was using channels. Default value is 1024 which,
according to the rabbitmq docs, 'runs into the law of diminishing
returns'. The recommended value is between 100-300. Source:
https://www.rabbitmq.com/confirms.html#channel-qos-prefetch-throughput

Fix test compilation errors and failing tests caused by these changes.

References #4160
2023-11-08 18:31:07 +01:00
ionutboangiu
6c41ebe0de Add sanity check to prevent xml reader panic
HierarchyPath parser now returns nil when
the path is empty (instead of a string slice with one
EmptyString element).

If the prefix is set to true, when calling the AsString
method on a nil HierarchyPath, only the separator will
be returned. This avoids a nil expr error coming from
the xmlquery library.

Use the Query and QueryAll functions from the xmlquery
package to be able to handle the errors ourselves and
avoid panics.

Remove config default value for xml_root_path. The field
will remain commented in config_defaults for reference.

Add tests for HierarchyPath.AsString function.

Add comments for XmlProvider and xml_root_path opt.
2023-10-16 13:18:12 +03:00
ionutboangiu
a80fe9b96e Remove redundant prefixes/suffixes from rOpts field names 2023-09-28 20:48:07 +02:00
ionutboangiu
bac73aa2c6 Migrate to new jetstream API
Updated ees/ers implementation to use the jetstream package which
separates the jetstream context from Core NATS.

Removed the jsOpts fields from the NatsEE struct. We are now using the
jetStreamMaxWait option directly through a timeout context.

Added streamName option for NATS reader since it is now required to be
specified when creating a consumer (it is not inferred based on subject
anymore).

Updated nats ers integration test.

Removed deprecated birpc unit test.

Updated tests to also use the new jetstream package.

Updated tests to start the nats-server using their official driver
instead of using the std go exec package. time.Sleeps are now not
required anymore to wait for the server.

In test configurations for nats readers, made sure that natsStreamName
option is populated. It is now required for consumers to know where to
subscribe.

Fixed potential panic that happened when jetstreamMaxWait option would
not be set.
2023-09-28 20:48:07 +02:00
ionutboangiu
b1d68b6cfe Upgrade NATS driver version and implementation
Upgraded NATS server version in ansible role.

upgraded go.mod nats version due to an issue caused by version mismatch
between driver and server (uncertain).

Increased amount of sleep in tests after starting a NATS server with
jetstream enabled from 50ms to 100ms.

## *NatsER.Serve

- Replaced ChanQueueSubscribe with QueueSubscribe for Core NATS consumer
to handle the message processing directly.

- Since QueueSubscribe is now used regardless of jetstream status, the
message handler has been assigned to a separate variable that can be
reused.

-  The message handler is now dealing with the message processing
directly, therefore the select case listening for the channel which is
feeding NATS messages can be removed together with the channel itself
and the select. Currently, the goroutine within Serve only has to block
until the rdrExit chan is closed.

- Moved the resource check inside the handler right before starting the
message processing goroutine.

## ers.getProcessedOptions

- Renamed function from getProcessOptions to getProcessedOptions.

- Initially, the EventExporterOpts struct was always initialized to be
non-nil which meant exporting processed messages by the reader was
always enabled by force. Function has been updated to initialize it
only once when the first Processed option that was set is found.

- Created init function for all types of opts structs to avoid
repetition.

## *NatsEE.parseOpts

- Renamed function from parseOpt to parseOpts.

- Updated function to return early in case of nil opts struct to reduce
nesting.

- The nested jetstream status and maxwait conditions nil verification
have been merged into one condition.

- Handled the error coming from GetNatsOpts function.

- NATS Subject assignment has been removed. It was redundant, since it
had already been set from before this function was called.

## *NatsEE.Connect

- Updated function to return early in case of non-nil nats.Conn value
to reduce nesting.

## *NatsEE.ExportEvent

- Use defer to release resources and RUnlock.

## *NatsEE.Close

- Use defer to Unlock.

- Update function to return early in case of nil nats.Conn value to
reduce nesting.

## ees.GetNatsOpts

- Chose switch over if else when parsing client certificate and keys
opts.

- Updated function to return the errors directly instead of assigning
them to a separate variable right before returning.

## ers.GetNatsOpts

- Passed the NATSROpts struct directly to the function.

- Chose switch over if else when parsing client certificate and keys
opts.

- Updated function to return the errors directly instead of assigning
them to a separate variable right before returning.

Removed tab from commented natsJetStreamMaxWaitProcessed option
value in config_defaults.go under ers section.

Removed redundant NATS prefix from config.NATSROpts type field names.

Added function in ers/lib_test.go to create a config file in /tmp
based on a config string.

Added integration test for ERs NATS.
2023-09-26 21:29:52 +02:00
NikolasPetriti
69d0fa7705 Add coverage tests for config 2023-09-12 18:10:02 +02:00
NikolasPetriti
9697975766 Add coverage tests for config 2023-09-11 12:23:42 +02:00
gezimbll
01d3c5d0fa Separating opts in ERS && fixing tests 2023-06-27 11:08:34 +02:00
ionutboangiu
6c16ff320f Replace interface{} with any 2023-05-31 10:23:12 +02:00
gezimbll
c2a5259f75 improving coverage tests 2022-11-04 10:09:21 +01:00
gezimbll
8848bb6898 improving coverage tests at engine 2022-11-04 10:09:21 +01:00
gezimbll
48b571a199 improving coverage tests at config&engine 2022-10-26 17:07:22 +02:00
gezimbll
0737c55898 coverage tests at config 2022-10-25 17:03:17 +02:00
gezimbll
c2aed810e3 improving tests at config folder 2022-10-25 09:34:07 +02:00
gezimbll
0d72169516 coverage tests at configs 2022-10-25 09:34:07 +02:00
ionutboangiu
38447e9229 Make ers opts as struct and fix compilation errors 2021-11-29 20:57:39 +01:00
ionutboangiu
9e6fb6bccb Remove partial_cache_action and partial_path from erscfg 2021-07-08 09:55:08 +02:00
Trial97
09985ce8f9 Added nats ees 2021-06-25 18:13:34 +02:00
Trial97
73de017591 Updated flatstore tests 2021-05-17 18:00:31 +02:00
Trial97
6408a8c4cd Updated config test 2021-05-17 18:00:31 +02:00
Trial97
051028078d Updated s3 and sqs ers configs 2021-05-17 18:00:31 +02:00
Trial97
5105d3aa85 Updated ers config 2021-05-17 18:00:31 +02:00
Trial97
0a7446bdad Added Config in agent request as dataprovider 2021-02-09 15:16:20 +01:00
andronache
36da1a6309 Consts in utils 2021-01-11 10:57:44 +01:00
andronache
1470267727 Modified consts in utils 2021-01-07 18:15:35 +01:00
TeoV
5775d09c7b Add infrastructure for AccountS in DataManager 2020-12-21 10:19:59 +01:00
porosnicuadrian
711d7d5a1a Removed error from NewDefaultCGRConfig signature's function 2020-12-02 14:00:35 +01:00
Trial97
c539800acd Added more Clone functions for config sections 2020-11-27 08:41:56 +01:00
Trial97
2b19127d05 Added more Clone functions for config sections 2020-11-27 08:41:56 +01:00
Trial97
568df81745 Added cores package and tests for caps 2020-11-05 17:07:50 +01:00
porosnicuadrian
bbd303e2c0 Covered tests for config directory 2020-11-05 14:46:08 +01:00
Trial97
5da4cf6d1c Updated account action plans integration tests for cache 2020-10-31 20:52:09 +01:00
Trial97
b2db71f303 Added APIs to reload config from string 2020-10-29 17:55:26 +01:00
porosnicuadrian
26fc655f2c Fixed the error description and added testsm in config 2020-10-29 16:57:01 +01:00
Trial97
1e6b5848e3 Updated AsMapInterface constants 2020-10-20 11:09:16 +02:00
Trial97
b06661af42 Added option to not read *env variables in RJReader 2020-10-15 12:41:04 +02:00
porosnicuadrian
17916acbc5 Covered erscfg to 100% 2020-10-07 12:02:51 +02:00
Trial97
4e80f5e703 Added more tests for empty fields in ees 2020-10-07 12:00:46 +02:00
porosnicuadrian
cc406e4392 Covered almost to 100% on erscfg 2020-10-05 19:03:26 +02:00