// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/eventlog/impl/EventLog.java
// @ToString
// @Getter
// @Setter
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder(toBuilder = true)
// public class EventLog {
// 
//     private Integer id;
//     private String eventType;
//     private String eventBodyData;
//     private String flowId;
//     private Instant created;
//     private Instant lastModified;
//     private String lockedBy;
//     private Instant lockedUntil;
// 
// }


import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.zalando.nakadiproducer.eventlog.impl.EventLog;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
package org.zalando.nakadiproducer.transmission.impl;



@Slf4j
public class EventBatcher {

    private static final long NAKADI_BATCH_SIZE_LIMIT_IN_BYTES = 50000000;
    private final ObjectMapper objectMapper;
    private final Consumer<List<BatchItem>> publisher;

    private List<BatchItem> batch;
    private long aggregatedBatchSize;

    public EventBatcher(ObjectMapper objectMapper, Consumer<List<BatchItem>> publisher) {
        this.objectMapper = objectMapper;
        this.publisher = publisher;

        this.batch = new ArrayList<>();
        this.aggregatedBatchSize = 0;
    }

    /**
     * Pushes one event to be published. It will be either published right now, or with some other events,
     * latest when calling {@link #finish()}.
     * @param eventLogEntry The event log entry for this event.
     * @param nakadiEvent The Nakadi form of the event.
     */
// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/eventlog/impl/EventLog.java
// @ToString
// @Getter
// @Setter
// @NoArgsConstructor
// @AllArgsConstructor
// @Builder(toBuilder = true)
// public class EventLog {
// 
//     private Integer id;
//     private String eventType;
//     private String eventBodyData;
//     private String flowId;
//     private Instant created;
//     private Instant lastModified;
//     private String lockedBy;
//     private Instant lockedUntil;
// 
// }


// Path: nakadi-producer/src/main/java/org/zalando/nakadiproducer/transmission/impl/EventBatcher.java
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.zalando.nakadiproducer.eventlog.impl.EventLog;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

package org.zalando.nakadiproducer.transmission.impl;



@Slf4j
public class EventBatcher {

    private static final long NAKADI_BATCH_SIZE_LIMIT_IN_BYTES = 50000000;
    private final ObjectMapper objectMapper;
    private final Consumer<List<BatchItem>> publisher;

    private List<BatchItem> batch;
    private long aggregatedBatchSize;

    public EventBatcher(ObjectMapper objectMapper, Consumer<List<BatchItem>> publisher) {
        this.objectMapper = objectMapper;
        this.publisher = publisher;

        this.batch = new ArrayList<>();
        this.aggregatedBatchSize = 0;
    }

    /**
     * Pushes one event to be published. It will be either published right now, or with some other events,
     * latest when calling {@link #finish()}.
     * @param eventLogEntry The event log entry for this event.
     * @param nakadiEvent The Nakadi form of the event.
     */
    public void pushEvent(EventLog eventLogEntry, NakadiEvent nakadiEvent) {