/go-tsv-watcher

TSV Parser and Watcher

Primary LanguageGoMIT LicenseMIT

go-tsv-watcher Tests

Postgres SQLite Go

TSV Parser and Watcher

Point

The service scans a given directory at a given interval and parses new TSV files, and also saves them to pdf files by device name in a separate directory and database selected by the user.

Database

The service supports the use of three databases. Supported: PostgreSQL, Sqlite, itisadb. I recommend using the itisadb database, as it is more suitable for high loads (developed by me).

CLI arguments

-c=path/to/config.json

Config

// directory to watch
Directory string `json:"directory"`
// directory to write to
DirectoryOut string `json:"directory_out"`

// connection string for storage
DSN string `json:"dsn"`
// storage type (e.g. postgres, sqlite3, itisasb)
Storage string `json:"storage_type"`

// http(s) server mode
HTTP  string `json:"http"`
HTTPS string `json:"https"`

// refresh interval
Refresh string `json:"refresh_interval"`

Config example

{
  "http": ":80",
  "directory": "test_dir",
  "directory_out": "test_out",
  "storage_type": "itisadb",
  "dsn": "127.0.0.1:800",
  "refresh_interval": "1s"
}

Request

You can receive an event via an HTTP(-S) request to your service.

Request example

POST http://IP:PORT/api/v1/event HTTP/1.1
Content-Type: application/json
{
    "unit_guid": "01749246-95f6-57db-b7c3-2ae0e8be6715",
    "page": 1
}

Response example

{
    "ID": "14d013b1-3de3-4dda-8ee6-42474a53e56f",
    "Number": 1,
    "MQTT": "",
    "InventoryID": "G-044322",
    "UnitGUID": "01749246-95f6-57db-b7c3-2ae0e8be6715",
    "MessageID": "cold7_Defrost_status",
    "MessageText": "Разморозка",
    "Context": "",
    "MessageClass": "waiting",
    "Level": 100,
    "Area": "LOCAL",
    "Address": "cold7_status.Defrost_status",
    "Block": false,
    "Type": "",
    "Bit": 0,
    "InvertBit": 0
}

Quick Run

The default 'config.json' file will be used. Make sure you have it.

docker-compose up