Skip to content

Instantly share code, notes, and snippets.

@smetj
Last active March 14, 2017 22:06
Show Gist options
  • Save smetj/befe8d64a2d993bd2939e00e23c126f2 to your computer and use it in GitHub Desktop.
Save smetj/befe8d64a2d993bd2939e00e23c126f2 to your computer and use it in GitHub Desktop.
Wishbone functions
---
functions:
json_decode:
function: wishbone.function.decode.json
uppercase:
function: wishbone.function.process.uppercase
arguments:
source: "@data.value"
destination: "@data.value"
modules:
input:
module: wishbone.module.input.httpserver
output:
module: wishbone.module.output.stdout
functions:
inbox:
- json_decode
- uppercase
routingtable:
- input.outbox -> output.inbox
...
@smetj
Copy link
Author

smetj commented Mar 14, 2017

Done using the development branch of Wishbone https://github.com/smetj/wishbone/tree/develop
Submitting a JSON to the wishbone server looks like:

$ echo -e '{"value":"hello how are you?"}\n'|curl -XPUT -d @- http://localhost:19283
ok

Server output:

$ wishbone debug --config functions_demo.yaml 

Instance started in foreground with pid 12664
2017-03-14T23:02:10 wishbone[12664]: debug input: Connected queue input.logs to _logs.input
2017-03-14T23:02:10 wishbone[12664]: debug input: Module instance '_metrics' has no queue 'input' so auto created.
2017-03-14T23:02:10 wishbone[12664]: debug input: Connected queue input.metrics to _metrics.input
2017-03-14T23:02:10 wishbone[12664]: debug input: Module instance 'input' has no queue 'outbox' so auto created.
2017-03-14T23:02:10 wishbone[12664]: debug input: Connected queue input.outbox to output.inbox
2017-03-14T23:02:10 wishbone[12664]: debug input: preHook() found, executing
2017-03-14T23:02:10 wishbone[12664]: debug input: Started with max queue size of 100 events and metrics interval of 1 seconds.
2017-03-14T23:02:10 wishbone[12664]: debug output: Connected queue output.logs to _logs.output
2017-03-14T23:02:10 wishbone[12664]: debug output: Module instance '_metrics' has no queue 'output' so auto created.
2017-03-14T23:02:10 wishbone[12664]: debug output: Connected queue output.metrics to _metrics.output
2017-03-14T23:02:10 wishbone[12664]: debug output: preHook() found, executing
2017-03-14T23:02:10 wishbone[12664]: debug output: Started with max queue size of 100 events and metrics interval of 1 seconds.
2017-03-14T23:02:10 wishbone[12664]: debug output: Function 'consume' has been registered to consume queue 'inbox'
2017-03-14T23:02:10 wishbone[12664]: informational input: Serving on 0.0.0.0:19283 with a connection poolsize of 1000.
{'value': 'HELLO HOW ARE YOU?'}
2017-03-14T23:02:27 wishbone[12664]: informational input: 127.0.0.1 - - [2017-03-14 23:02:27] "PUT / HTTP/1.1" 200 103 0.000493

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment