diff --git a/config/config_defaults.go b/config/config_defaults.go index 7404a7207..841e9fe7f 100755 --- a/config/config_defaults.go +++ b/config/config_defaults.go @@ -304,7 +304,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, 0 to use automation via inotify + "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 diff --git a/data/conf/samples/ers/cgrates.json b/data/conf/samples/ers/cgrates.json new file mode 100644 index 000000000..ae3b70fc9 --- /dev/null +++ b/data/conf/samples/ers/cgrates.json @@ -0,0 +1,55 @@ +{ +// CGRateS Configuration file +// +// Used for SessionSv1 integration tests + + +"general": { + "log_level": 7, +}, + + +"listen": { + "rpc_json": ":2012", + "rpc_gob": ":2013", + "http": ":2080", +}, + + +"stor_db": { + "db_password": "CGRateS.org", +}, + + +"rals": { + "enabled": true, +}, + + +"cdrs": { + "enabled": true, + "chargers_conns": [], + "rals_conns": [], +}, + + +"sessions": { + "enabled": true, + "cdrs_conns": [ + {"address": "*internal"} + ], +}, + + +"ers": { + "enabled": true, + "readers": [ + { + "id": "file_reader1", + "run_delay": -1, + }, + ], +}, + + +} diff --git a/ers/ers.go b/ers/ers.go index effbb0891..e98790f67 100644 --- a/ers/ers.go +++ b/ers/ers.go @@ -71,8 +71,8 @@ func (erS *ERService) ListenAndServe(cfgRldChan chan struct{}, } } erS.rdrs[rdrCfg.SourcePath] = append(erS.rdrs[rdrCfg.SourcePath], rdr) - } + //fmt.Printf("ERSService: %s\n", utils.ToIJSON(erS.rdrs)) go erS.handleReloads(cfgRldChan, exitChan) e := <-exitChan exitChan <- e // put back for the others listening for shutdown request diff --git a/ers/reader.go b/ers/reader.go index 8e3e6ceff..02d66904b 100644 --- a/ers/reader.go +++ b/ers/reader.go @@ -19,6 +19,8 @@ along with this program. If not, see package ers import ( + "fmt" + "github.com/cgrates/cgrates/config" "github.com/cgrates/cgrates/utils" ) @@ -34,5 +36,11 @@ type EventReader interface { // NewEventReader instantiates the event reader based on configuration at index func NewEventReader(rdrCfg *config.EventReaderCfg) (er EventReader, err error) { + switch rdrCfg.Type { + default: + err = fmt.Errorf("unsupported reader type: <%s>", rdrCfg.Type) + case utils.MetaFileCSV: + + } return }