|
| 1 | +/* |
| 2 | + * Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with |
| 5 | + * the License. A copy of the License is located at |
| 6 | + * |
| 7 | + * http://aws.amazon.com/apache2.0 |
| 8 | + * |
| 9 | + * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR |
| 10 | + * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions |
| 11 | + * and limitations under the License. |
| 12 | + */ |
| 13 | +package com.amazonaws.services.lambda.runtime.events; |
| 14 | + |
| 15 | +import lombok.AllArgsConstructor; |
| 16 | +import lombok.Builder; |
| 17 | +import lombok.Data; |
| 18 | +import lombok.NoArgsConstructor; |
| 19 | +import java.util.List; |
| 20 | +import java.util.Map; |
| 21 | + |
| 22 | +@Data |
| 23 | +@NoArgsConstructor |
| 24 | +@AllArgsConstructor |
| 25 | +@Builder(setterPrefix = "with") |
| 26 | +/** Represents a Kafka Event. **/ |
| 27 | +public class KafkaEvent { |
| 28 | + private Map<String, List<KafkaEventRecord>> records; |
| 29 | + private String eventSource; |
| 30 | + private String eventSourceArn; |
| 31 | + |
| 32 | + @Data |
| 33 | + @NoArgsConstructor |
| 34 | + @AllArgsConstructor |
| 35 | + @Builder(setterPrefix = "with") |
| 36 | + public static class KafkaEventRecord { |
| 37 | + private String topic; |
| 38 | + private int partition; |
| 39 | + private long offset; |
| 40 | + private long timestamp; |
| 41 | + private String timestampType; |
| 42 | + private String key; |
| 43 | + private String value; |
| 44 | + } |
| 45 | + |
| 46 | + @Data |
| 47 | + @NoArgsConstructor |
| 48 | + @AllArgsConstructor |
| 49 | + @Builder(setterPrefix = "with") |
| 50 | + public static class TopicPartition { |
| 51 | + private String topic; |
| 52 | + private int partition; |
| 53 | + |
| 54 | + @Override |
| 55 | + public String toString() { |
| 56 | + //Kafka also uses '-' for toString() |
| 57 | + return topic + "-" + partition; |
| 58 | + } |
| 59 | + } |
| 60 | +} |
0 commit comments