In basic setup copies transactions from ledger into elasticsearch database and performs transformations on this data to make them easier to process.
The architecture is based on concept of "workers". Currently there's 1 type of worker
implemented in Indyscan called RTW
. This stands for Read-Transform-Write
.
One RTW worker runs against 1 subledger of 1 indy network.
RTW worker turned out to be nice generalization which can accomodate various types of workloads. RTW worker can be given transaction source (such as ledger, database), pipeline of transformations to perform on the data read from the source, and some destination where transformed data shall be sent.
Example of RTW workers:
- Worker
RTW1
is copying domain transactions from Sovrin Mainnet intosovmain
elasticsearch index. - Worker
RTW2
reads raw ledger transactions fromsovmain
ES index, transforms data and writes them back tosovmain
ES index. - Worker 3 reads data from one elasticsearch instance and write them into another elasticsearch.
To start up daemon, you need to specify in configuration what kind of workers should be created upon startup. Configuration has 2 parts
Main properties of daemon are specified by environment variables.
Example:
WORKER_CONFIGS=app-configs/sovmain.json,app-configs/sovstaging.json,app-configs/sovbuilder.json
LOG_LEVEL=debug
LOG_ES_URL=http://localhost:9200
SERVER_ENABLED=true
SERVER_PORT=3709
LOG_HTTP_REQUESTS=true
LOG_HTTP_RESPONSES=true
AUTOSTART=true
ENABLE_LOGFILES=true
Details:
-
WORKER_CONFIGS
- comma separated list of paths to worker configurations (more about that later). -
LOG_LEVEL
- Specifies verbosity of output. Accepted values:error
,warn
,info
,debug
,silly
. -
ENABLE_LOGFILES
- IfENABLE_LOGFILES
istrue
, each winston logger also stores logs into files inlogs
directory. -
LOG_ES_URL
- If specified, all logs will be sent to elasticsearch on specified URL. -
SERVER_ENABLED
- Daemon comes with HTTP server to manage workers. If set tofalse
, HTTP server won't be started. -
SERVER_PORT
- IfSERVER_ENABLED
istrue
, the HTTP Server will be running on specified port. -
LOG_HTTP_REQUESTS
- IfSERVER_ENABLED
istrue
, this specifies whether incoming HTTP requests shall be logged. -
LOG_HTTP_RESPONSES
- IfSERVER_ENABLED
istrue
, this specifies whether outgoing HTTP responses shall be logged. -
AUTOSTART
- Specifies whether workers defined byWORKER_CONFIGS
config files shall be automatically started. If set tofalse
, you will have to enable workers either by calling server API or viaindyscan-daemon-ui
(which hooks up to the daemon HTTP API)
The workers to be ran by daemon are specified by worker configuration files. Typically you won't need to write these but rather just slightly adjust ones that are provided to your particular setup.
Here's example of worker configuration file.
{
"env": {
"INDY_NETWORK": "HOST_DOCKER_INTERNAL",
"ES_URL": "http://localhost:9200",
"ES_INDEX": "txs-localdocker"
},
"workersBuildersTemplate": [
{
"builder": "rtwSerialization",
"params": {
"indyNetworkId": "{{{INDY_NETWORK}}}",
"genesisPath": "{{{cfgdir}}}/genesis/{{{INDY_NETWORK}}}.txn",
"esUrl": "{{{ES_URL}}}",
"esIndex": "{{{ES_INDEX}}}",
"workerTiming": "FAST"
}
},
{
"builder": "rtwExpansion",
"params": {
"indyNetworkId": "{{{INDY_NETWORK}}}",
"esUrl": "{{{ES_URL}}}",
"esIndex": "{{{ES_INDEX}}}",
"workerTiming": "FAST"
}
}
]
}
The worker config has 2 parts: env
and workersBuildersTemplate
.
env
section specifies variables and their values to be interpolated intoworkersBuildersTemplate
section.workersBuildersTemplate
- specifies workers. Each builder in the example actually stands up 3 RTW workers - 3 workers per network.- The
rtwSerialization
worker builder create workers which copy data from ledger to elasticsearch. - The
rtwExpansion
worker builder create workers which read raw transactions data from the elasticsearch, transform data into different, easier to consume format, and write back to elasticsearch as a different representation of the transaction.
- The