Streams Via REST API
By using the Wombat streams
mode REST API you can dynamically control which streams are active at runtime. The full
spec for the Wombat streams mode REST API can be found here.
Note that stream configs created and updated using this API do not benefit from environment variable interpolation (function interpolation will still work).
Walkthrough
Start by running Wombat in streams mode:
On a separate terminal we can add our first stream foo
by POST
ing a JSON or YAML config to the /streams/foo
endpoint:
Now we can check the full set of streams loaded by GET
ing the /streams
endpoint:
And we can send data to our new stream via its namespaced URL:
Good, now let’s add another stream bar
the same way:
And check the set again:
It’s also possible to get the configuration of a loaded stream by GET
ing the path /streams/{id}
:
Next, we might want to update stream foo
by PUT
ing a new config to the path /streams/foo
:
We have removed the memory buffer with this change, let’s check that the config has actually been updated:
Good, we are done with stream bar
now, so let’s delete it by DELETE
ing the /streams/bar
endpoint:
And let’s GET
the /streams
endpoint to see the new set:
Great. Another useful feature is POST
ing to /streams
, this allows us to set the entire set of streams with a single request.
The payload is a map of stream ids to configurations and this will become the exclusive set of active streams. If there are existing streams that are not on the list they will be removed.
Let’s check our new set of streams:
Done.