Open dckc opened 6 years ago
I am hoping we can develop a graphql interface to the bounty database. In that vein we might want to consider using a qraphql subscription
Another option: an h-entry feed
Hi! This is jeffscarver. Just getting my feet wet (first post). Be gentle, I am trying to learn. :)
Now that I've tackled pushing data to RChain from node.js, let's connect mysql binlog events to RChain. I just made a new node app; so far it can subscribe to new votes:
. .env; node server.js
Waiting for database events...
...
{ type: 'INSERT',
schema: 'xataface',
table: 'budget_vote',
affectedRows: [ { after: [Object], before: undefined } ],
affectedColumns:
[ 'pay_period',
'issue_num',
'voter',
'amount',
'vote_time',
'weight' ],
timestamp: 1533407169000,
nextPosition: 2463,
binlogName: 'mysql-bin.000001' }
. .env; node server.js
Waiting for database events from... { user: 'rchain_binlog', host: '127.0.0.1', port: 3506 }
@@event: { type: 'UPDATE',
schema: 'xataface',
table: 'budget_vote',
affectedRows: [ { after: [Object], before: [Object] } ],
affectedColumns: [ 'amount', 'vote_time' ],
timestamp: 1533415174000,
nextPosition: 91516,
binlogName: 'mysql-bin.000001' }
@@rho: @[`https://rewards.rchain.coop`, "budget_vote"]!("UPDATE", [@"after"!(@"amount"!(425) | @"issue_num"!(199) | @"pay_period"!("2018-07-01T05:00:00.000Z") | @"vote_time"!("2018-08-04T20:39:34.000Z") | @"voter"!("dckc") | @"weight"!(Nil)) | @"before"!(@"amount"!(420) | @"issue_num"!(199) | @"pay_period"!("2018-07-01T05:00:00.000Z") | @"vote_time"!("2018-08-04T20:19:36.000Z") | @"voter"!("dckc") | @"weight"!(Nil))])
Very nice work!
cc @AhsanFazal
@jimscarver wrote Jun 1:
I was thinking of a webhook.
But the Right Thing To Do is to feed the data into RChain via the node gRPC interface.
mysql supports subscription via its "binlog"; I've done this in a js app, finquick, using mysql-events.
The non-PHP parts of this app are mostly python, so we could use https://github.com/noplay/python-mysql-replication . Using RChain's gRPC stuff via scala is a little more straightforward than doing it with pyhon, so maybe https://github.com/shyiko/mysql-binlog-connector-java ?