feat: Support AWS Kinesis destination #316
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This implements the RFC from #305. A few note-worthy things to call out here:
1. Add
config.metadata_in_payload
bool config as suggested in the issue.2.
config.endpoint
UIThis should probably be hidden. However, it would make local dev testing difficult, especially when using the UI to test locally. With SQS, we can derive the endpoint from the
queue_url
field and detect whether it's production AWS or local LocalStack. We can't do the same with AWS Kinesis.Options:
3. Partition key template payload
This PR implements the partition templating with JMESPath as discussed in the RFC.
One thing to note is that I ended up going with the message payload as the input for the template. What I mean is that when producing a Kinesis record, we need 3 info:
stream_name
,partition_key
, anddata
(bytes version of a Go map); whatever the data content is, that map is the payload for the partition key template.For example, with an event like so:
If
metadataInPayload: true
, the resulting payload would be:So, you can do something like
metadata.mymeta
ormetadata.topic
as the partition key tempalte.If
metadataInPayload: false
, the resulting payload would beIn that case, you can do
mydata
for the template. Or an empty string, in which case we'll use the event ID as the partition key. One note is that you will NOT be able to use topic as the partition key in this case, unless topic is part of the data itself.Reasoning
The reason I went with this approach was around the end-user perspective. They won't know what an event is, and the only thing they know is the payload they'll receive. Therefore, I think this makes a bit more sense than the incoming event payload from the producer/operator side.
However, this still requires the user to know beforehand what the expected data shape is. It's a bit more complicated than webhook, for example, where you can just provide a URL and observe the incoming requests. Maybe it's a necessary consideration, given the technology.
4. Delivery details
This is how the UI looks right now.
NOTE: The "message" UI is incorrect now. Currently, the message UI is fake, deriving from the event. For Kinesis, it doesn't account for the fact that the user can opt-out of metadata, and therefore the message can be different. We probably need to add a task to persist message data & display properly.
Dev notes:
go run ./cmd/destinations/awskinesis
. Make sure you runmake up/deps
beforehand. There're new changes to the Docker Compose, so if you had it running previously, also make sure to restart the containers.TODO:
Next step:
PutRecords
to send events in batch