The HTTP ingest endpoint allows the streaming of discrete requests using the HTTP protocol.
All HTTP headers specified in the request are converted into metadata and supplied as part of the request to all ingestors.
Path | Description |
---|---|
ingest | Does not associate the request to any specific ingestor. Events will be broadcast to all registered ingestors. |
ingest/[name] | Associates the request to a specific ingestor. Events are published to that ingestor only. |
curl -X POST http://localhost:8080/ingest \
-H "hydra-kafka-topic:test.TopicName" \
-H "hydra-schema:TestSchema" \
-H "hydra-validation-strategy:relaxed" \
-d '{"name": "001c000001nlucqiaf", "handle": "152cba6e"}'
{"requestId":"FX3GTeML","status":{"code":200,"message":"OK"},"ingestors":{"kafka_ingestor":{"code":200,"message":"OK"}}}%
Hydra supports web sockets for event streaming with semantics that are very similar to the HTTP endpoint, with a few differences:
These can be specified at connection time via HTTP headers beginning with "hydra-***"
or after the socket has
connected by issuing SET
commands.
Once the metadata for the request has been set, clients can send payloads directly to the socket, without having to re-set these for every request.
Add this entry to your config:
hydra.ingest.websocket.enabled = true
The socket endpoint will be available at ws://[host]/ws-ingest
Path | Description |
---|---|
ws-ingest | Does not associate the request to any specific ingestor. Events will be broadcast to all registered ingestors. |
ws-ingest/[name] | Associates the socket to a specific ingestor. Events are published to that ingestor only. |
Web socket commands start with the
-c
switch.
Used to set request metadata.
Syntax:
To set request metadata:
-c SET hydra-kafka-topic = test.Topic
To list the current request metadata:
-c SET
Used to get a list of all available commands.
Sending any payload that does not begin with the command switch will initiate the ingestion protocol.
Ingestion payloads can include an optional request id, by prefixing the payload with a -i
switch. For instance:
-i 122 {"name":"test","value":"test"}
/connect ws://localhost:8080/ws-ingest/kafka_ingestor
-c set hydra-kafka-topic = test-topic
sent: -c set hydra-kafka-topic = test-topic
response: {"status":200,"message":"OK[HYDRA-KAFKA_TOPIC=test-topic]"}
-c set hydra-ack = explicit
sent: -c set hydra-ack = explicit
response: {"status":200,"message":"OK[HYDRA-ACK=explicit]"}
{"name":"test","value":"test"}
sent: {"name":"test","value":"test"}
response: {"requestId":"GrnuqJBX","status":{"code":200,"message":"OK"},"ingestors":{"kafka_ingestor":{"code":200,"message":"OK"}}}
Scala
Python