rchain-community / rchain-dbr

RChain Distributed Budgeting and Rewards Bounty Web Site
https://rewards.rchain.coop/
10 stars 6 forks source link

subscription via webhook, RChain #6

Open dckc opened 6 years ago

dckc commented 6 years ago

@jimscarver wrote Jun 1:

BugetBot was great for monitoring the reward system but now that we are off google sheets we need something similar to log events from the new reward system. -- https://github.com/rchain/bounties/issues/157#issuecomment-393866577

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 ?

jimscarver commented 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

dckc commented 6 years ago

Another option: an h-entry feed

http://microformats.org/wiki/h-entry

Jeff-NJ commented 6 years ago

Hi! This is jeffscarver. Just getting my feet wet (first post). Be gentle, I am trying to learn. :)

dckc commented 6 years ago

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' }

https://github.com/dckc/rchain-dbr/tree/s2r/s2r f669bdf

dckc commented 6 years ago
. .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))])
tschoffelen commented 6 years ago

Very nice work!

cc @AhsanFazal