Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds metadata to KinesisFirehose response record to support dynamic partitioning #1346

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,16 @@ public class FirehoseRecord
#endif
public string Base64EncodedData { get; set; }

/// <summary>
/// The response record metadata.
/// </summary>
[DataMember(Name = "metadata")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("metadata")]
#endif
public FirehoseResponseRecordMetadata Metadata { get; set; }


/// <summary>
/// Base64 encodes the data and sets the Base64EncodedData property.
/// </summary>
Expand All @@ -101,5 +111,22 @@ public void EncodeData(string data)
this.Base64EncodedData = Convert.ToBase64String(Encoding.UTF8.GetBytes(data));
}
}

/// <summary>
/// The response record metadata after processing KinesisFirehoseEvent.Records
/// </summary>
[DataContract]
public class FirehoseResponseRecordMetadata
{
/// <summary>
/// Key Value pairs used for Dynamic Partitioning
/// https://docs.aws.amazon.com/firehose/latest/dev/dynamic-partitioning.html
/// </summary>
[DataMember(Name = "partitionKeys")]
#if NETCOREAPP_3_1
[System.Text.Json.Serialization.JsonPropertyName("partitionKeys")]
#endif
public Dictionary<string, string> PartitionKeys { get; set; }
}
}
}
3 changes: 2 additions & 1 deletion Libraries/test/EventsTests.Shared/EventTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,8 @@ public void KinesisFirehoseResponseTest(Type serializerType)
Assert.Equal("49572672223665514422805246926656954630972486059535892482", kinesisResponse.Records[0].RecordId);
Assert.Equal(KinesisFirehoseResponse.TRANSFORMED_STATE_OK, kinesisResponse.Records[0].Result);
Assert.Equal("SEVMTE8gV09STEQ=", kinesisResponse.Records[0].Base64EncodedData);

Assert.Equal("iamValue1", kinesisResponse.Records[0].Metadata.PartitionKeys["iamKey1"]);
Assert.Equal("iamValue2", kinesisResponse.Records[0].Metadata.PartitionKeys["iamKey2"]);


MemoryStream ms = new MemoryStream();
Expand Down
10 changes: 8 additions & 2 deletions Libraries/test/EventsTests.Shared/kinesis-firehose-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
{
"recordId": "49572672223665514422805246926656954630972486059535892482",
"result": "Ok",
"data": "SEVMTE8gV09STEQ="
"data": "SEVMTE8gV09STEQ=",
"metadata": {
"partitionKeys": {
"iamKey1": "iamValue1",
"iamKey2": "iamValue2"
}
}
}
]
}
}