Commit Graph

1596 Commits

Author SHA1 Message Date
ionutboangiu
b1a5874215 Move config/rsrparser.go to utils package 2025-02-24 13:36:32 +01:00
ionutboangiu
36a7d174ab Remove RSRSep opt from general section
- allows RSRParser to be split gracefully from config (was depending on
  RSRSep, which was retrieved from the global config variable)
- default separator (;) was the only one used except for splitting
  inline attribute values (where ANDSep is used)
2025-02-24 13:36:32 +01:00
ionutboangiu
de87ab04ad Add short comments to all cgr-engine.go functions 2025-01-21 19:59:17 +01:00
ionutboangiu
3f0bb4df43 Move libcgr-engine into cgr-engine.go + flags refactor 2025-01-21 19:59:17 +01:00
ionutboangiu
ba9c2e1e3f Integrate cgrRunPreload inside LoaderService.Start 2025-01-21 19:59:17 +01:00
armirveliaj
7db65ca62c Clean up DispatcherS 2025-01-17 17:29:46 +01:00
ionutboangiu
e23759b4a8 Init services directly in Service slice
except CoreService that needs to be referenced in
case CPU profiling is enabled via flags and needs
to be stopped before CoreService starts managing it
2025-01-16 15:51:52 +01:00
ionutboangiu
3d693aefe5 Remove srvDep map
Now syncing on shutdown based on states
2025-01-16 15:51:52 +01:00
ionutboangiu
6be26def4f Implement CapService 2025-01-16 15:51:52 +01:00
ionutboangiu
04f746c634 Implement LoggerService + refactoring (incomplete) 2025-01-14 19:00:37 +01:00
ionutboangiu
e7152dacf8 Implement ConnManager service
Use it to register internal rpc conns instead of ServManager
DispatcherS now waits for AttributeS to start (only when enabled)
2025-01-14 19:00:37 +01:00
ionutboangiu
089dfc00ae Use SyncedChan to handle shutdown 2025-01-14 19:00:37 +01:00
ionutboangiu
dab152f976 Integrate StateServiceDOWN + registry related refactor
Removed redundant IsRunning service method
Removed registry from constructors
Pass registry to Start/Reload/Shutdown service methods
2025-01-14 19:00:37 +01:00
ionutboangiu
396227d639 Refactor ServiceIndexer implementation
Renamed to ServiceRegistry
Improved comments
2025-01-10 20:18:08 +01:00
ionutboangiu
09b75a1045 Let ServManager manage all services except itself 2025-01-10 20:18:08 +01:00
ionutboangiu
17405af987 Revise service manager logs
Logging is now done as ServiceManager level. Removed any other logs.
2025-01-10 20:18:08 +01:00
ionutboangiu
c8a3ebe5e8 Use channel instead of context to handle shutdown 2025-01-10 20:18:08 +01:00
ionutboangiu
d9359a4005 Implement GuardianService and ConfigService
And use ServiceIndexer to sync with them
2025-01-10 20:18:08 +01:00
DanB
3c57a8ddca Properly name Values instead of Value within DynamicStringSliceOpt 2024-12-19 16:01:31 +01:00
ionutboangiu
da2052e7b3 Implement FilterService
And use ServiceIndexer to sync with it
2024-12-12 11:55:14 +01:00
ionutboangiu
db301f7901 Remove StorDB service param from service constructors
Use ServiceIndexer instead.
Remove CDRs ListenAndServe method.
Pass the storDB connection directly to constructors instead of the
channel.
2024-12-12 11:55:14 +01:00
ionutboangiu
10dfcc5e48 Remove dmS parameter from service constructors
Use ServiceIndexer instead
2024-12-12 11:55:14 +01:00
ionutboangiu
55ecdf45e4 Remove clsChan in favor of using the service indexer 2024-12-12 11:55:14 +01:00
ionutboangiu
98b5b74b23 Remove cacheS parameter from service constructors
ServiceIndexer will be used instead
2024-12-12 11:55:14 +01:00
ionutboangiu
77af4f95b3 Remove anzCh in favor of using the service indexer 2024-12-10 18:53:13 +01:00
ionutboangiu
0783984bfe Remove srvDep from services that don't use it 2024-12-05 20:12:08 +01:00
ionutboangiu
34de7e2c4e Remove unused dependency waitgroups
to declutter cgr-engine.go a bit. Entire map will be removed in the future
2024-12-04 19:28:50 +01:00
ionutboangiu
79e461e7c5 Remove redundant internal channels
only from services that have dedicated files
2024-12-04 19:28:50 +01:00
ionutboangiu
c29f1fdd35 Remove services/cgr-engine.go
Trying to move services init before CGREngine constructor makes it pointless,
as it's only used as a dependency storage for services init.
2024-12-04 09:06:59 +01:00
DanB
2dfa1e7035 Adding initial stopChan to the engine 2024-12-01 20:22:47 +01:00
DanB
6b241ee35b Adding serviceIndexer and StateDependencies 2024-11-28 14:56:03 +01:00
DanB
23e5f0e387 Add generic way to insert services inside services/CGREngine 2024-11-26 14:03:57 +01:00
DanB
76398441da Simplify running of the engine via only one Run command 2024-11-26 12:50:08 +01:00
ionutboangiu
e78722ae4e Init cM,caps,cls,wg inside CGREngine constructor
Also pass the profile to the CGREngine struct the moment profiling started.
2024-11-14 17:48:09 +01:00
ionutboangiu
bb9bfbb19b Rename CommonListenerS constructor
NewServer -> NewCommonListenerS
2024-11-14 17:48:09 +01:00
ionutboangiu
5bf8f1756c Extract cores.Server into new commonlisteners package
Functionality is the same.
Server has been renamed to CommonListenerS.
2024-11-04 21:23:15 +01:00
ionutboangiu
4b427aeaf6 Revise flag names/usage descriptions 2024-11-01 15:59:39 +01:00
ionutboangiu
78ae609f1d Simplify flag parsing by switching to ExitOnError
Will automatically handle 'ErrHelp' by exiting with status 0 when help is
requested and status 2 for other parsing errors.
2024-11-01 15:59:39 +01:00
ionutboangiu
c7dbcaea03 Revise CPU/Memory profiling
CPU profiling changes:

cgr-engine.go:
- use filepath.Join instead of path.Join
- handle *CoreService.StopCPUProfiling error inside deferred function
- same with the error from *os.File.Close()

cores/core.go:
- StartCPUProfile now returns an *os.File (as opposed to an io.WriteCloser),
  because os.File.Stat is used beforehand to check if a handler of the file is
  already active and confirm the status of profiling.  Asserting the type would
  have worked as well.
- handle pprof.StartCPUProfile error and ensure file is closed before returning
- log file close error as a warning if it occurs
- return missing mandatory error with correct path field name ('DirPath')
- no need to check if fileCPU is nil for profiling status
  - pprof.StartCPUProfiling will return an error if profiling is already started
  - os.File.Close() will return ErrClosed if profiling is already stopped
- differentiate between calling StopCPUProfiling when profiling hasn't started
and when it was already stopped by returning appropriate errors

Memory profiling changes:

- merge StopChanMemProf with StopMemoryProfiling
- remove fileMEM and stopMemProf from struct and constructors
- add separate mutex for memory profiling, ensure thread safety
- handle all significant errors
- log error if StopMemoryProfiling fails during CoreS Shutdown
- ignore errors if profiling inactive in Shutdown and deferred Stop
- move validations inside V1 functions
- return error if StartMemoryProfiling already started
- return error if StopMemoryProfiling already stopped or never started
- close profiling loop on error, not the cgr-engine
- StopMemoryProfiling closes channel and profiling loop writes final profile
- rename Path to DirPath for mandatory field error
- rename memprof_nrfiles flag to memprof_maxfiles
- increase default memprof_interval
- consider MaxFiles <= 0 as unlimited
- move memory profiling logic after starting services
- use CoreService Start/StopMemoryProfiling in main
- remove final memory profile block (created by deferred Stop)
- convert MemProfiling to method on CoreService and rename to profileMemory
- use Ticker for recurrent actions instead of Timer
- compute mem_final.prof full path in StartMemoryProfiling
- suffix profile files with current time instead of numbers
- update dispatcher methods after changes
- move MemoryPrf from utils to cores, rename to MemoryProfilingParams
- add logs for starting/stopping profiling
- added the possibility to disable timestamps in the memory profile file names
  and use increments of 1 instead.

Other changes:

- improved integration tests for flags (now table tests)
- improved profiling integration tests
2024-11-01 15:59:39 +01:00
ionutboangiu
e0c05ecfa7 Add redis pipeline window and limit cfg opts
Set redisPoolPipelineWindow to control duration before pipeline
flush (0 disables implicit pipelining) and redisPoolPipelineLimit
for max commands per pipeline (0 means no limit, only time window
applies).
2024-10-29 18:54:51 +01:00
ionutboangiu
3e98e37db3 Revise NewRPCClient helper function 2024-10-23 21:11:25 +02:00
ionutboangiu
0063ef3822 Add support for mongodb+srv conn format
Option can be found in db opts under the name 'mongoConnScheme'.
2024-09-05 20:46:40 +02:00
ionutboangiu
169b5500d3 Revise err handling for CSV storage constructor
NewFileCSVStorage() now returns an error besides the storage struct itself, which is
logged and returned instead of calling log.Fatal() which was causing the engine to
crash.

Fixed compilation errors by creating the CSVStorage separately and passing it as an
argument to the TpReader constructor.

Fixes #3962
2024-09-05 20:46:40 +02:00
ionutboangiu
1b24a504dc add flaky build constraint to unstable tests 2024-08-21 20:59:10 +02:00
ionutboangiu
0f70af84e9 centralize test flags for shared use across tests 2024-08-15 18:17:33 +02:00
ionutboangiu
0dfb3b860d Centralize RPCClient constructor 2024-08-15 18:17:33 +02:00
armirveliaj
6dc612a32a Add print_config flags to cgr-loader and cgr-migrator 2024-07-03 10:39:59 +02:00
gezimbll
3ff0e6e5a1 revising integration tests 2024-06-07 17:18:23 +02:00
arberkatellari
de5db4a938 Add caching_delay to config and loaders 2024-03-06 16:16:08 +01:00
ionutboangiu
113e2a2bdf Replace interface{} with any 2023-05-31 10:22:28 +02:00