Created
April 16, 2015 10:45
-
-
Save natbusa/416823a99663cd8112ea to your computer and use it in GitHub Desktop.
actor httpclient syntax/semantics ideas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from httpMethods import * | |
# Create the graph (profiling tags) | |
# get (as a http client) every 10 seconds json and emit it on | |
post('/api/actors', | |
{ | |
"type":"httpclient", | |
"trigger": null, # can also be omitted altogether | |
"collect":null, # can also be omitted altogether | |
"params": { | |
"url" : "http://finance.google.com/finance/info?client=ig&q=NASDAQ%3aMSFT", | |
"method" : "GET", # this should be a default | |
"timeout": 2, | |
"auth": { | |
"method": "apikey", # should support a number of auth schemes | |
"apikey": "IUFTSI&^YGUS" | |
} | |
}, | |
"timer": { | |
"duration": 10, | |
"mode": "continue" | |
} | |
}) | |
# it only supports json, invalid json is discarded | |
# example of possible emitted json | |
""" | |
// [ | |
{ | |
"id": "358464" | |
,"t" : "MSFT" | |
,"e" : "NASDAQ" | |
,"l" : "42.26" | |
,"l_max" : "43.26" | |
,"l_cur" : "42.26" | |
,"s": "1" | |
""" | |
# provided that the previous actor id is 1 | |
post('/api/actors', { | |
"type":"threshold", | |
"trigger": 1, | |
"collect": { | |
"key": "trigger[0].l", | |
"threshold": 100 # but could also be "trigger[0].l_max * 1.15" | |
}, | |
"params": null | |
} | |
# use params when its fixed at *creation* time | |
# use collect when you need more flexibility | |
# suppose the previous id is 2 | |
post('/api/actors', | |
{ | |
"type":"httpclient", | |
"trigger": 2, | |
"collect":{ | |
"min": "trigger[0].l_min", | |
"curr": "trigger[0].l" | |
} | |
"params": { | |
"url" : "http://dashku.com", | |
"method" : "POST", # this should be a default | |
"timeout": 2, | |
"auth": { | |
"method": "apikey", # should support a number of auth schemes | |
"apikey": "IUFTSI&^YGUS" | |
}, | |
"template": '{"data":{ "min":$min, "current":$curr}}' | |
}, | |
"timer": { | |
"duration": 10, | |
"mode": "continue" | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment