From 99a50502f7985197fa42604ad3b895323a2006f1 Mon Sep 17 00:00:00 2001 From: andronache Date: Mon, 10 May 2021 12:34:03 +0300 Subject: [PATCH] Finished renaming opts for Event Exporter --- config/config_defaults.go | 24 +++++++++---------- data/conf/cgrates/cgrates.json | 12 +++++----- .../samples/cdrsexport_internal/cgrates.json | 8 +++---- .../samples/cdrsexport_mongo/cgrates.json | 8 +++---- .../samples/cdrsexport_mysql/cgrates.json | 8 +++---- .../cdrsreplicationmaster.json | 8 +++---- .../cdrsreplicationmaster.json | 8 +++---- data/conf/samples/ees/cgrates.json | 4 ++-- engine/poster_test.go | 12 +++++----- ers/amqp_it_test.go | 6 ++--- ers/kafka_test.go | 12 +++++----- ers/sql.go | 1 - ers/sql_it_test.go | 8 +++---- ers/sql_test.go | 16 ++++++------- utils/consts.go | 10 ++++---- 15 files changed, 72 insertions(+), 73 deletions(-) diff --git a/config/config_defaults.go b/config/config_defaults.go index c9a2654f8..3630d298d 100644 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -377,16 +377,16 @@ const CGRATES_CFG_JSON = ` // AMQP // "consumerTag": "cgrates", // the ID of the consumer - // "exchange": "", - // "exchangeType": "", - // "routingKey": "", + // "sqlExchange": "", + // "sqlExchangeType": "", + // "amqpRoutingKey": "", // "exchangeProcessed": "", // "exchangeTypeProcessed": "", // "routingKeyProcessed": "", // Kafka - // "topic": "cgrates", // the topic from were the events are read + // "kafkaTopic": "cgrates", // the topic from were the events are read // "groupID": "cgrates", // the group that reads the events // "maxWait": "1ms", // the maximum amount of time to wait for new data to come @@ -394,11 +394,11 @@ const CGRATES_CFG_JSON = ` // SQL - // "dbName": "cgrates", // the name of the database from were the events are read + // "sqlDBName": "cgrates", // the name of the database from were the events are read // "sqlTableName": "cdrs", // the name of the table from were the events are read // "sslmode": "disable", // the postgresSSLMode for postgres db - // "dbNameProcessed": "", // the name of the database were the events are sent after they are processed + // "sqlDBNameProcessed": "", // the name of the database were the events are sent after they are processed: "", // the name of the database were the events are sent after they are processed // "sqlTableNameProcessed": "", // the name of the table were the events are sent after they are processed // "sslmodeProcessed": "", // the postgresSSLMode for postgres db @@ -479,19 +479,19 @@ const CGRATES_CFG_JSON = ` // "sqlMaxConnLifetime": 0, // SQLMaxConnLifetime - // "sqlTableName":"cdrs", // the name of the table from where the events are exported - // "dbName": "cgrates", // the name of the database from where the events are exported + // "sqlTableName":"cdrs", // the name of the table from where the events are exported + // "sqlDBName": "cgrates", // the name of the database from where the events are exported // "sslmode": "disable", // the postgresSSLMode for postgres // Kafka - // "topic": "cgrates", // the topic from where the events are exported + // "kafkaTopic": "cgrates", // the topic from where the events are exported // AMQP - // "routingKey": "", // RoutingKey - // "exchange": "", // Exchange - // "exchangeType": "", // ExchangeType + // "amqpRoutingKey": "", // RoutingKey + // "sqlExchange": "", // Exchange + // "sqlExchangeType": "", // ExchangeType // SQS and S3 diff --git a/data/conf/cgrates/cgrates.json b/data/conf/cgrates/cgrates.json index 0e364306f..dbd845cd2 100755 --- a/data/conf/cgrates/cgrates.json +++ b/data/conf/cgrates/cgrates.json @@ -356,16 +356,16 @@ // // AMQP // // "consumerTag": "cgrates", // the ID of the consumer -// // "exchange": "", -// // "exchangeType": "", -// // "routingKey": "", +// // "sqlExchange": "", +// // "sqlExchangeType": "", +// // "amqpRoutingKey": "", // // "exchangeProcessed": "", // // "exchangeTypeProcessed": "", // // "routingKeyProcessed": "", // // Kafka -// // "topic": "cgrates", // the topic from were the events are read +// // "kafkaTopic": "cgrates", // the topic from were the events are read // // "groupID": "cgrates", // the group that reads the events // // "maxWait": "1ms", // the maximum amount of time to wait for new data to come @@ -373,11 +373,11 @@ // // SQL -// // "dbName": "cgrates", // the name of the database from were the events are read +// // "sqlDBName": "cgrates", // the name of the database from were the events are read // // "sqlTableName": "cdrs", // the name of the table from were the events are read // // "sslmode": "disable", // the ssl mode for postgres db -// // "dbNameProcessed": "", // the name of the database were the events are sent after they are processed +// // "sqlDBNameProcessed": "", // the name of the database were the events are sent after they are processed // // "sqlTableNameProcessed": "", // the name of the table were the events are sent after they are processed // // "sslmodeProcessed": "", // the ssl mode for postgres db diff --git a/data/conf/samples/cdrsexport_internal/cgrates.json b/data/conf/samples/cdrsexport_internal/cgrates.json index 1c33a1c3d..fa10a2e00 100644 --- a/data/conf/samples/cdrsexport_internal/cgrates.json +++ b/data/conf/samples/cdrsexport_internal/cgrates.json @@ -65,9 +65,9 @@ "export_path": "amqp://guest:guest@localhost:5672/", "opts": { "queueID": "cgrates_cdrs", - "exchange": "exchangename", - "exchangeType": "fanout", - "routingKey": "cgr_cdrs", + "sqlExchange": "exchangename", + "sqlExchangeType": "fanout", + "amqpRoutingKey": "cgr_cdrs", }, "tenant": "cgrates.org", "attempts": 20, @@ -111,7 +111,7 @@ "type": "*kafka_json_map", "export_path": "127.0.0.1:9092", "opts":{ - "topic": "cgrates_cdrs", + "kafkaTopic": "cgrates_cdrs", }, "tenant": "cgrates.org", "attempts": 10, diff --git a/data/conf/samples/cdrsexport_mongo/cgrates.json b/data/conf/samples/cdrsexport_mongo/cgrates.json index 14a65aec4..a858058ee 100644 --- a/data/conf/samples/cdrsexport_mongo/cgrates.json +++ b/data/conf/samples/cdrsexport_mongo/cgrates.json @@ -70,9 +70,9 @@ "export_path": "amqp://guest:guest@localhost:5672/", "opts": { "queueID": "cgrates_cdrs", - "exchange": "exchangename", - "exchangeType": "fanout", - "routingKey": "cgr_cdrs", + "sqlExchange": "exchangename", + "sqlExchangeType": "fanout", + "amqpRoutingKey": "cgr_cdrs", }, "tenant": "cgrates.org", "attempts": 20, @@ -116,7 +116,7 @@ "type": "*kafka_json_map", "export_path": "127.0.0.1:9092", "opts":{ - "topic": "cgrates_cdrs", + "kafkaTopic": "cgrates_cdrs", }, "tenant": "cgrates.org", "attempts": 10, diff --git a/data/conf/samples/cdrsexport_mysql/cgrates.json b/data/conf/samples/cdrsexport_mysql/cgrates.json index d1c881792..675b990c0 100644 --- a/data/conf/samples/cdrsexport_mysql/cgrates.json +++ b/data/conf/samples/cdrsexport_mysql/cgrates.json @@ -67,9 +67,9 @@ "export_path": "amqp://guest:guest@localhost:5672/", "opts": { "queueID": "cgrates_cdrs", - "exchange": "exchangename", - "exchangeType": "fanout", - "routingKey": "cgr_cdrs", + "sqlExchange": "exchangename", + "sqlExchangeType": "fanout", + "amqpRoutingKey": "cgr_cdrs", }, "tenant": "cgrates.org", "attempts": 20, @@ -112,7 +112,7 @@ "type": "*kafka_json_map", "export_path": "127.0.0.1:9092", "opts": { - "topic": "cgrates_cdrs", + "kafkaTopic": "cgrates_cdrs", }, "tenant": "cgrates.org", "attempts": 10, diff --git a/data/conf/samples/cdrsonexpmaster_mongo/cdrsreplicationmaster.json b/data/conf/samples/cdrsonexpmaster_mongo/cdrsreplicationmaster.json index 969238a1f..6f8d424bc 100644 --- a/data/conf/samples/cdrsonexpmaster_mongo/cdrsreplicationmaster.json +++ b/data/conf/samples/cdrsonexpmaster_mongo/cdrsreplicationmaster.json @@ -79,9 +79,9 @@ "export_path": "amqp://guest:guest@localhost:5672/", "opts": { "queueID": "cgrates_cdrs", - "exchange": "exchangename", - "exchangeType": "fanout", - "routingKey": "cgr_cdrs", + "sqlExchange": "exchangename", + "sqlExchangeType": "fanout", + "amqpRoutingKey": "cgr_cdrs", }, "tenant": "cgrates.org", "attempts": 3, @@ -118,7 +118,7 @@ "type": "*kafka_json_map", "export_path": "localhost:9092", "opts": { - "topic": "cgrates_cdrs", + "kafkaTopic": "cgrates_cdrs", }, "tenant": "cgrates.org", "synchronous": true, diff --git a/data/conf/samples/cdrsonexpmaster_mysql/cdrsreplicationmaster.json b/data/conf/samples/cdrsonexpmaster_mysql/cdrsreplicationmaster.json index 2ded3f3ba..2dbfeb95a 100644 --- a/data/conf/samples/cdrsonexpmaster_mysql/cdrsreplicationmaster.json +++ b/data/conf/samples/cdrsonexpmaster_mysql/cdrsreplicationmaster.json @@ -77,9 +77,9 @@ "export_path": "amqp://guest:guest@localhost:5672/", "opts": { "queueID": "cgrates_cdrs", - "exchange": "exchangename", - "exchangeType": "fanout", - "routingKey": "cgr_cdrs", + "sqlExchange": "exchangename", + "sqlExchangeType": "fanout", + "amqpRoutingKey": "cgr_cdrs", }, "tenant": "cgrates.org", "attempts": 3, @@ -116,7 +116,7 @@ "type": "*kafka_json_map", "export_path": "localhost:9092", "opts": { - "topic": "cgrates_cdrs", + "kafkaTopic": "cgrates_cdrs", }, "tenant": "cgrates.org", "synchronous": true, diff --git a/data/conf/samples/ees/cgrates.json b/data/conf/samples/ees/cgrates.json index c199983fc..3cf065465 100644 --- a/data/conf/samples/ees/cgrates.json +++ b/data/conf/samples/ees/cgrates.json @@ -394,7 +394,7 @@ "export_path": "mysql://cgrates:CGRateS.org@127.0.0.1:3306", "attempts": 1, "opts": { - "dbName": "exportedDatabase", // if dbName is not present "cgrates" will be used as default + "sqlDBName": "exportedDatabase", // if dbName is not present "cgrates" will be used as default "sqlTableName": "expTable", // tableName is mandatory in opts for sql exporter "sslmode": "disable", "sqlMaxIdleConns": "10", @@ -415,7 +415,7 @@ "export_path": "mysql://cgrates:CGRateS.org@127.0.0.1:3306", "attempts": 1, "opts": { - "dbName": "exportedDatabase", + "sqlDBName": "exportedDatabase", "sqlTableName": "expTable", "sslmode": "disable", "sqlMaxIdleConns": "10", diff --git a/engine/poster_test.go b/engine/poster_test.go index 4d9c69b69..fc89aa3ee 100644 --- a/engine/poster_test.go +++ b/engine/poster_test.go @@ -37,10 +37,10 @@ func TestAMQPPosterParseURL(t *testing.T) { routingKey: "CGRCDR", } opts := map[string]interface{}{ - "queueID": "q1", - "exchange": "E1", - "routingKey": "CGRCDR", - "exchangeType": "fanout", + "queueID": "q1", + "sqlExchange": "E1", + "amqpRoutingKey": "CGRCDR", + "sqlExchangeType": "fanout", } amqp.parseOpts(opts) if !reflect.DeepEqual(expected, amqp) { @@ -55,7 +55,7 @@ func TestKafkaParseURL(t *testing.T) { topic: "cdr_billing", attempts: 10, } - if kfk := NewKafkaPoster(u, 10, map[string]interface{}{"topic": "cdr_billing"}); !reflect.DeepEqual(exp, kfk) { + if kfk := NewKafkaPoster(u, 10, map[string]interface{}{"kafkaTopic": "cdr_billing"}); !reflect.DeepEqual(exp, kfk) { t.Errorf("Expected: %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(kfk)) } u = "localhost:9092" @@ -64,7 +64,7 @@ func TestKafkaParseURL(t *testing.T) { topic: "cdr_billing", attempts: 10, } - if kfk := NewKafkaPoster(u, 10, map[string]interface{}{"topic": "cdr_billing"}); !reflect.DeepEqual(exp, kfk) { + if kfk := NewKafkaPoster(u, 10, map[string]interface{}{"kafkaTopic": "cdr_billing"}); !reflect.DeepEqual(exp, kfk) { t.Errorf("Expected: %s ,received: %s", utils.ToJSON(exp), utils.ToJSON(kfk)) } } diff --git a/ers/amqp_it_test.go b/ers/amqp_it_test.go index 4d7fbfeda..17e8a6448 100644 --- a/ers/amqp_it_test.go +++ b/ers/amqp_it_test.go @@ -46,9 +46,9 @@ func TestAMQPER(t *testing.T) { "opts": { "queueID": "cdrs3", "consumerTag": "test-key", - "exchange": "test-exchange", - "exchangeType": "direct", - "routingKey": "test-key", + "sqlExchange": "test-exchange", + "sqlExchangeType": "direct", + "amqpRoutingKey": "test-key", }, "processed_path": "", // move processed data here "tenant": "cgrates.org", // tenant used by import diff --git a/ers/kafka_test.go b/ers/kafka_test.go index 3b862dc42..25f44bebc 100644 --- a/ers/kafka_test.go +++ b/ers/kafka_test.go @@ -38,9 +38,9 @@ func TestKafkasetOpts(t *testing.T) { maxWait: time.Second, } if err := k.setOpts(map[string]interface{}{ - "topic": "cdrs", - "groupID": "new", - "maxWait": "1s", + "kafkaTopic": "cdrs", + "groupID": "new", + "maxWait": "1s", }); err != nil { t.Fatal(err) } else if expKafka.dialURL != k.dialURL { @@ -81,9 +81,9 @@ func TestKafkasetOpts(t *testing.T) { maxWait: time.Second, } if err := k.setOpts(map[string]interface{}{ - "topic": "cdrs", - "groupID": "new", - "maxWait": "1s", + "kafkaTopic": "cdrs", + "groupID": "new", + "maxWait": "1s", }); err != nil { t.Fatal(err) } else if expKafka.dialURL != k.dialURL { diff --git a/ers/sql.go b/ers/sql.go index de6b6b059..9b82fae2f 100644 --- a/ers/sql.go +++ b/ers/sql.go @@ -328,7 +328,6 @@ func (rdr *SQLEventReader) setURL(inURL, outURL string, opts map[string]interfac rdr.expTableName = utils.CDRsTBL if vals, has := processedOpt[utils.SQLTableName]; has { rdr.expTableName = utils.IfaceAsString(vals) - } switch rdr.expConnType { diff --git a/ers/sql_it_test.go b/ers/sql_it_test.go index a9d4fc143..6733a73ff 100644 --- a/ers/sql_it_test.go +++ b/ers/sql_it_test.go @@ -98,8 +98,8 @@ func testSQLInitConfig(t *testing.T) { "concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited "source_path": "*mysql://cgrates:CGRateS.org@127.0.0.1:3306", // read data from this path "opts": { - "dbName":"cgrates2", - "dbNameProcessed":"cgrates2", + "sqlDBName":"cgrates2", + "sqlDBNameProcessed":"cgrates2", "sqlTableNameProcessed":"cdrs2", }, "processed_path": "", // move processed data here @@ -375,8 +375,8 @@ func testSQLInitConfig2(t *testing.T) { "concurrent_requests": 1024, // maximum simultaneous requests/files to process, 0 for unlimited "source_path": "*mysql://cgrates:CGRateS.org@127.0.0.1:3306", // read data from this path "opts": { - "dbName":"cgrates2", - "dbNameProcessed":"cgrates2", + "sqlDBName":"cgrates2", + "sqlDBNameProcessed":"cgrates2", "sqlTableNameProcessed":"cdrs2", }, "processed_path": "", // move processed data here diff --git a/ers/sql_test.go b/ers/sql_test.go index ee1705094..b0ce78725 100644 --- a/ers/sql_test.go +++ b/ers/sql_test.go @@ -41,11 +41,11 @@ func TestSQLSetURL(t *testing.T) { inURL := "*mysql://cgrates:CGRateS.org@127.0.0.1:3306" outURL := "*mysql://cgrates:CGRateS.org@127.0.0.1:3306" if err := sql.setURL(inURL, outURL, map[string]interface{}{ - "dbName": "cgrates2", - utils.SQLTableName: "cdrs2", - "sslmode": "enabled", + "sqlDBName": "cgrates2", + "sqlTableName": "cdrs2", + "sslmode": "enabled", - "dbNameProcessed": "cgrates3", + "sqlDBNameProcessed": "cgrates3", "sqlTableNameProcessed": "cdrs3", "sslmodeProcessed": "enabled", }); err != nil { @@ -76,11 +76,11 @@ func TestSQLSetURL(t *testing.T) { inURL = "*postgres://cgrates:CGRateS.org@127.0.0.1:3306" outURL = "*postgres://cgrates:CGRateS.org@127.0.0.1:3306" if err := sql.setURL(inURL, outURL, map[string]interface{}{ - "dbName": "cgrates2", + "sqlDBName": "cgrates2", "sqlTableName": "cdrs2", "sslmode": "enabled", - "dbNameProcessed": "cgrates3", + "sqlDBNameProcessed": "cgrates3", "sqlTableNameProcessed": "cdrs3", "sslmodeProcessed": "enabled", }); err != nil { @@ -111,11 +111,11 @@ func TestSQLSetURL(t *testing.T) { inURL = "*postgres://cgrates:CGRateS.org@127.0.0.1:3306" outURL = "" if err := sql.setURL(inURL, outURL, map[string]interface{}{ - "dbName": "cgrates2", + "sqlDBName": "cgrates2", "sqlTableName": "cdrs2", "sslmode": "enabled", - "dbNameProcessed": "cgrates2", + "sqlDBNameProcessed": "cgrates2", "sqlTableNameProcessed": "cdrs2", "sslmodeProcessed": "enabled", }); err != nil { diff --git a/utils/consts.go b/utils/consts.go index 8791cfa93..a1d8edcea 100644 --- a/utils/consts.go +++ b/utils/consts.go @@ -2536,7 +2536,7 @@ const ( AWSSecret = "awsSecret" AWSToken = "awsToken" AWSFolderPath = "s3FolderPath" - KafkaTopic = "topic" + KafkaTopic = "kafkaTopic" KafkaGroupID = "groupID" KafkaMaxWait = "maxWait" @@ -2544,9 +2544,9 @@ const ( DefaultQueueID = "cgrates_cdrs" QueueID = "queueID" DefaultExchangeType = "direct" - Exchange = "exchange" - ExchangeType = "exchangeType" - RoutingKey = "routingKey" + Exchange = "sqlExchange" + ExchangeType = "sqlExchangeType" + RoutingKey = "amqpRoutingKey" // for ers: AMQPDefaultConsumerTag = "cgrates" @@ -2558,7 +2558,7 @@ const ( KafkaDefaultGroupID = "cgrates" KafkaDefaultMaxWait = time.Millisecond - SQLDBName = "dbName" + SQLDBName = "sqlDBName" SQLTableName = "sqlTableName" SQLDefaultSSLMode = "disable" SQLDefaultDBName = "cgrates"