Package io.camunda.zeebe.logstreams.log
Interface LogStreamWriter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault booleancanWriteEvents(int eventCount, int batchSize) Returns true if the given eventCount with the given batchLength could potentially be written, false otherwise.default Either<LogStreamWriter.WriteFailure, Long> tryWrite(LogAppendEntry appendEntry) Attempts to write the event to the underlying stream.default Either<LogStreamWriter.WriteFailure, Long> tryWrite(LogAppendEntry appendEntry, long sourcePosition) default Either<LogStreamWriter.WriteFailure, Long> tryWrite(List<LogAppendEntry> appendEntries) Attempts to write the events to the underlying stream.tryWrite(List<LogAppendEntry> appendEntries, long sourcePosition) Attempts to write the events to the underlying stream.
-
Method Details
-
canWriteEvents
default boolean canWriteEvents(int eventCount, int batchSize) Returns true if the given eventCount with the given batchLength could potentially be written, false otherwise.- Parameters:
eventCount- the potential event count we want to checkbatchSize- the potential batch Size (in bytes) we want to check- Returns:
- true if the event count with corresponding size could be written, false otherwise
-
tryWrite
Attempts to write the event to the underlying stream.- Parameters:
appendEntry- the entry to write- Returns:
- the event position, a negative value if fails to write the event, or 0 if the value is empty
-
tryWrite
default Either<LogStreamWriter.WriteFailure,Long> tryWrite(LogAppendEntry appendEntry, long sourcePosition) -
tryWrite
Attempts to write the events to the underlying stream. This method is atomic, either all events are written, or none are.- Parameters:
appendEntries- a set of entries to append; these will be appended in the order- Returns:
- the last (i.e. highest) event position, a negative value if fails to write the events, or 0 if the batch is empty
-
tryWrite
Either<LogStreamWriter.WriteFailure,Long> tryWrite(List<LogAppendEntry> appendEntries, long sourcePosition) Attempts to write the events to the underlying stream. This method is atomic, either all events are written, or none are.- Parameters:
appendEntries- a list of entries to append; append order is maintainedsourcePosition- a back-pointer to the record whose processing created these entries- Returns:
- the last (i.e. highest) event position, a negative value if fails to write the events, or 0 if the batch is empty
-