Skip to content

Instantly share code, notes, and snippets.

@choult
Created December 19, 2022 16:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choult/e2b5fef750fc26064e62d2a543b4534f to your computer and use it in GitHub Desktop.
Save choult/e2b5fef750fc26064e62d2a543b4534f to your computer and use it in GitHub Desktop.
This Benthos config demonstrates the consumption of Mastodon HTTP Server-Sent Events
input:
broker:
copies: 1
inputs:
- http_client:
url: "https://mas.to/api/v1/streaming/public"
stream:
enabled: true
reconnect: true
codec: lines
max_buffer: 100000000
processors:
- mapping: |
root = if content().string().has_prefix(":") { deleted() }
batching:
count: 2
pipeline:
processors:
- grok:
expressions:
- '%{HTTPSSE}'
pattern_definitions:
HTTPSSE: "%{NOTSPACE:key}: %{GREEDYDATA:value}"
- archive:
format: json_array
- mapping: |
root.event = this."0".value
root.data = this."1".value.parse_json()
output:
stdout:
codec: lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment