Parse RunDelay from EventReader with ParseDurationWithNanosecs fixes #1897

This commit is contained in:
TeoV
2020-02-05 16:37:22 +02:00
committed by Dan Christian Bogos
parent b85ebe8214
commit 9376889b10
16 changed files with 65 additions and 63 deletions

View File

@@ -308,7 +308,7 @@ const CGRATES_CFG_JSON = `
"id": "*default", // identifier of the EventReader profile
"type": "*file_csv", // reader type <*file_csv>
"field_separator": ",", // separator used in case of csv files
"run_delay": 0, // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"run_delay": "0", // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited
"source_path": "/var/spool/cgrates/cdrc/in", // read data from this path
"processed_path": "/var/spool/cgrates/cdrc/out", // move processed data here

View File

@@ -1674,7 +1674,7 @@ func TestDfEventReaderCfg(t *testing.T) {
Id: utils.StringPointer(utils.MetaDefault),
Type: utils.StringPointer(utils.MetaFileCSV),
Field_separator: utils.StringPointer(","),
Run_delay: utils.IntPointer(0),
Run_delay: utils.StringPointer("0"),
Concurrent_requests: utils.IntPointer(1024),
Source_path: utils.StringPointer("/var/spool/cgrates/cdrc/in"),
Processed_path: utils.StringPointer("/var/spool/cgrates/cdrc/out"),

View File

@@ -132,7 +132,9 @@ func (er *EventReaderCfg) loadFromJsonCfg(jsnCfg *EventReaderJsonCfg, sep string
er.FieldSep = *jsnCfg.Field_separator
}
if jsnCfg.Run_delay != nil {
er.RunDelay = time.Duration(*jsnCfg.Run_delay)
if er.RunDelay, err = utils.ParseDurationWithNanosecs(*jsnCfg.Run_delay); err != nil {
return
}
}
if jsnCfg.Concurrent_requests != nil {
er.ConcurrentReqs = *jsnCfg.Concurrent_requests

View File

@@ -186,7 +186,7 @@ func TestEventReaderLoadFromJSON(t *testing.T) {
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",
@@ -211,7 +211,7 @@ func TestEventReaderSanitisation(t *testing.T) {
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"source_path": "/tmp/ers/in",
"processed_path": "/tmp/ers/out",

View File

@@ -169,7 +169,7 @@ type EventReaderJsonCfg struct {
Id *string
Type *string
Field_separator *string
Run_delay *int
Run_delay *string
Concurrent_requests *int
Source_path *string
Processed_path *string

View File

@@ -70,7 +70,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",

View File

@@ -80,7 +80,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
@@ -88,7 +88,7 @@
},
{
"id": "file_reader2",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
@@ -113,7 +113,7 @@
},
{
"id": "init_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
@@ -135,7 +135,7 @@
},
{
"id": "terminate_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
@@ -150,7 +150,7 @@
},
{
"id": "create_cdr",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
@@ -174,7 +174,7 @@
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
@@ -201,7 +201,7 @@
},
{
"id": "XmlDryRun",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
@@ -222,7 +222,7 @@
},
{
"id": "FWV1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
@@ -255,7 +255,7 @@
{
"id": "PartialCSV1",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs1/in",
"flags": ["*cdrs"],
@@ -296,7 +296,7 @@
{
"id": "PartialCSV_PostExpiry",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs2/in",
"processed_path": "/tmp/partErs2/out",
@@ -326,7 +326,7 @@
{
"id": "FlatstoreOsips",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*flatstore",
"field_separator": "|",
"source_path": "/tmp/flatstoreErs/in",

View File

@@ -81,7 +81,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
@@ -89,7 +89,7 @@
},
{
"id": "file_reader2",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
@@ -114,7 +114,7 @@
},
{
"id": "init_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
@@ -136,7 +136,7 @@
},
{
"id": "terminate_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
@@ -151,7 +151,7 @@
},
{
"id": "create_cdr",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
@@ -175,7 +175,7 @@
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
@@ -202,7 +202,7 @@
},
{
"id": "XmlDryRun",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
@@ -223,7 +223,7 @@
},
{
"id": "FWV1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
@@ -256,7 +256,7 @@
{
"id": "PartialCSV1",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs1/in",
"flags": ["*cdrs"],
@@ -297,7 +297,7 @@
{
"id": "PartialCSV_PostExpiry",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs2/in",
"processed_path": "/tmp/partErs2/out",
@@ -327,7 +327,7 @@
{
"id": "FlatstoreOsips",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*flatstore",
"field_separator": "|",
"source_path": "/tmp/flatstoreErs/in",

View File

@@ -78,7 +78,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
@@ -86,7 +86,7 @@
},
{
"id": "file_reader2",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
@@ -111,7 +111,7 @@
},
{
"id": "init_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
@@ -133,7 +133,7 @@
},
{
"id": "terminate_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
@@ -148,7 +148,7 @@
},
{
"id": "create_cdr",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
@@ -172,7 +172,7 @@
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
@@ -199,7 +199,7 @@
},
{
"id": "XmlDryRun",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
@@ -220,7 +220,7 @@
},
{
"id": "FWV1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
@@ -253,7 +253,7 @@
{
"id": "PartialCSV1",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs1/in",
"flags": ["*cdrs"],
@@ -294,7 +294,7 @@
{
"id": "PartialCSV_PostExpiry",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs2/in",
"processed_path": "/tmp/partErs2/out",
@@ -324,7 +324,7 @@
{
"id": "FlatstoreOsips",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*flatstore",
"field_separator": "|",
"source_path": "/tmp/flatstoreErs/in",

View File

@@ -75,7 +75,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
@@ -83,7 +83,7 @@
},
{
"id": "file_reader2",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
@@ -108,7 +108,7 @@
},
{
"id": "init_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
@@ -130,7 +130,7 @@
},
{
"id": "terminate_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
@@ -145,7 +145,7 @@
},
{
"id": "create_cdr",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
@@ -169,7 +169,7 @@
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"field_separator": ";",
"source_path": "/tmp/ers_with_filters/in",
@@ -196,7 +196,7 @@
},
{
"id": "XmlDryRun",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_xml",
"source_path": "/tmp/xmlErs/in",
"flags": ["*cdrs","*log"],
@@ -217,7 +217,7 @@
},
{
"id": "FWV1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_fwv",
"source_path": "/tmp/fwvErs/in",
"flags": ["*cdrs"],
@@ -250,7 +250,7 @@
{
"id": "PartialCSV1",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs1/in",
"flags": ["*cdrs"],
@@ -291,7 +291,7 @@
{
"id": "PartialCSV_PostExpiry",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*partial_csv",
"source_path": "/tmp/partErs2/in",
"processed_path": "/tmp/partErs2/out",
@@ -321,7 +321,7 @@
{
"id": "FlatstoreOsips",
"enabled": true,
"run_delay": -1,
"run_delay": "-1",
"type": "*flatstore",
"field_separator": "|",
"source_path": "/tmp/flatstoreErs/in",

View File

@@ -70,7 +70,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*cdrs","*log"],
"source_path": "/tmp/ers/in",
@@ -78,7 +78,7 @@
},
{
"id": "file_reader2",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",

View File

@@ -70,7 +70,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",

View File

@@ -70,7 +70,7 @@
"readers": [
{
"id": "file_reader1",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"source_path": "/tmp/ers/in",
@@ -78,7 +78,7 @@
},
{
"id": "file_reader2",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ";",
"type": "*file_csv",
"source_path": "/tmp/ers2/in",
@@ -103,7 +103,7 @@
},
{
"id": "init_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/init_session/in",
@@ -125,7 +125,7 @@
},
{
"id": "terminate_session",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/terminate_session/in",
@@ -140,7 +140,7 @@
},
{
"id": "create_cdr",
"run_delay": -1,
"run_delay": "-1",
"field_separator": ",",
"type": "*file_csv",
"source_path": "/tmp/cdrs/in",
@@ -164,7 +164,7 @@
},
{
"id": "file_reader_with_filters",
"run_delay": -1,
"run_delay": "-1",
"type": "*file_csv",
"flags": ["*dryrun"],
"field_separator": ";",

View File

@@ -36,7 +36,7 @@ With explanations in the comments:
"readers": [ // list of active readers
{
"id": "file_reader2", // file_reader2 reader
"run_delay": -1, // reading of events it is triggered outside of ERs
"run_delay": "-1", // reading of events it is triggered outside of ERs
"field_separator": ";", // field separator definition
"type": "*file_csv", // type of reader, *file_csv can read .csv files
"flags": [ // influence processing logic within CGRateS workflow

View File

@@ -48,7 +48,7 @@ func TestKafkaER(t *testing.T) {
{
"id": "kafka", // identifier of the EventReader profile
"type": "*kafka_json_map", // reader type <*file_csv>
"run_delay": -1, // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"run_delay": "-1", // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited
"source_path": "localhost:9092", // read data from this path
// "processed_path": "/var/spool/cgrates/cdrc/out", // move processed data here

View File

@@ -77,7 +77,7 @@ func testSQLInitConfig(t *testing.T) {
{
"id": "mysql", // identifier of the EventReader profile
"type": "*sql", // reader type <*file_csv>
"run_delay": 1, // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"run_delay": "1", // sleep interval in seconds between consecutive runs, -1 to use automation via inotify or 0 to disable running all together
"concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited
"source_path": "*mysql://cgrates:CGRateS.org@127.0.0.1:3306?db_name=cgrates2", // read data from this path
"processed_path": "db_name=cgrates2&table_name=cdrs2", // move processed data here