Skip to content

Instantly share code, notes, and snippets.

@Sachin-Kottarathodi
Created March 18, 2021 20:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sachin-Kottarathodi/f9dac7a3342a3643e792e2143a6adf7d to your computer and use it in GitHub Desktop.
Save Sachin-Kottarathodi/f9dac7a3342a3643e792e2143a6adf7d to your computer and use it in GitHub Desktop.
from gearsclient import GearsRemoteBuilder as GearsBuilder
from redistimeseries.client import Client
def stream_handler(item):
data = item['value']
member = json.dumps(
{'device_id': data['device_id'],
'transaction_id': data['transaction_id'],
'ts': data['ts'],
})
redis.Redis().zadd(data.get('device_id'), {member: data['ts']})
Client().incrby(data['fraud_type'], 1)
GearsBuilder(reader='StreamReader', r=redis_conn, requirements=["redis", "redistimeseries"]).foreach(stream_handler).register('data_stream')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment