API reference
Every public type in 1.4.2, grouped by module. Types not listed here are
package-private implementation details and are not part of the compatibility surface.
The full Javadoc is browsable at https://krabka-io.github.io/krabka-streams-java/.
Javadoc is also published alongside each artifact (-javadoc.jar) and is generated with
Xdoclint:all plus -Werror, so every public type and member carries a complete
comment. Every public type and package summary includes a runnable-style usage
example.
krabka-streams
Package io.krabka.streams.
KrabkaStreamsConfig
public final class. A utility class that cannot be instantiated.
| Member | Signature |
|---|---|
GROUP_ |
public static final String = "group. |
STREAMS_ |
public static final String = "streams" |
with |
public static Properties with |
withDefaults copies settings into a new Properties and applies krabka defaults
with putIfAbsent. Throws NullPointerException for a null argument.
Everything else in this module is the Apache Kafka Streams 4.3.1 API, re-exported as an
api dependency.
krabka-streams-schema-serde
Package io.krabka.streams.schema.
KrabkaSchemaRegistryClient
public final class. An asynchronous Confluent Schema Registry REST client.
| Member | Signature |
|---|---|
| constructor | Krabka |
| constructor | Krabka |
| constructor | Krabka |
| constructor | injected client plus int max |
register |
Completable |
lookup |
Completable |
latest |
Completable |
latest |
Completable |
schema |
Completable |
| management | subjects, versions, compatibility, deletion, and reference resolution methods |
Nested records:
public record SchemaReference(String name, String subject, int version) {}
public record RegisteredSchema(..., List<SchemaReference> references) {}
public record FetchedSchema(String schema, String messageType, List<SchemaReference> references) {}
Failures complete the future exceptionally with SchemaRegistryException.
SchemaCache
public final class. A thread-safe store of resolved schema IDs and writer schemas.
| Member | Signature |
|---|---|
| constructor | Schema, which uses AUTO_ and Topic |
| constructor | Schema |
subject |
String subject(String topic, Role role) |
intern |
void intern(String subject, Schema, idempotent by subject |
prewarm |
Completable |
prewarm |
Completable |
id |
Optional |
writer |
String writer, which throws Schema on a miss |
writer |
String writer, null when unknown |
writer |
Map<String, String> writer |
seed |
void seed |
seed |
void seed |
seed |
void seed |
AvroSerde<T>
public final class ... implements Serde<T>
| Member | Signature |
|---|---|
for |
static <T extends Specific |
for |
static <T extends Specific |
generic |
static Avro |
reflect |
static <T> Avro |
register |
void register |
serializer / deserializer |
from Serde<T> |
Registers the Avro canonical parsing form. Deserialization performs writer/reader schema resolution.
ProtobufSerde<T extends Message>
public final class ... implements Serde<T>
| Member | Signature |
|---|---|
for |
static <T extends Message> Protobuf |
for |
static <T extends Message> Protobuf |
register |
void register |
Uses the Protobuf message-index framing and verifies the writer’s messageType.
JsonSchemaSerde<T>
public final class ... implements Serde<T>
| Member | Signature |
|---|---|
for |
static <T> Json |
for |
static <T> Json |
for |
static <T> Json |
register |
void register |
validate applies in both directions. $schema selects Draft 4, 6, 7, 2019-09, or
2020-12; an extended factory accepts an explicit dialect, strategy, and mapper.
ConfluentWireFormat
public final class. Framing helpers.
| Member | Signature |
|---|---|
MAGIC |
public static final byte = 0 |
encode |
static byte[] encode(int schema |
decode |
static Frame decode(byte[] bytes) |
encode |
static byte[] encode |
decode |
static Protobuf |
public record Frame(int schemaId, byte[] body) {}
public record ProtobufFrame(int schemaId, List<Integer> messageIndexes, byte[] body) {}
Both records copy body on construction and on access.
LocalSchemaCompatibility
Network-free pairwise checks for BACKWARD, FORWARD, and FULL modes. avro and
json accept schema text; protobuf accepts two FileDescriptor values. Every check
returns Result(boolean compatible, List<String> incompatibilities).
Enums and interfaces
| Type | Values / members |
|---|---|
Role |
KEY, VALUE |
Schema |
AVRO (no wire name), PROTOBUF, JSON |
Register |
AUTO_, LOOKUP_, USE_ |
Subject |
@Functional |
Topic |
implements Subject, producing topic + "-key" or topic + "-value" |
Exceptions
| Type | Extends | Members |
|---|---|---|
Schema |
Runtime |
Schema, (String, Throwable), (int status; int status, which returns -1 for transport or parsing errors |
Schema |
org. |
Schema; int schema |
krabka-streams-columnar
Package io.krabka.streams.columnar.
ColumnarTopology
public final class. The topology builder.
| Member | Signature |
|---|---|
| constructor | Columnar |
add |
Columnar |
add |
Columnar |
add |
Columnar |
add |
Columnar |
add |
Columnar |
add |
Columnar |
add |
Columnar |
source |
List<String> source |
validate |
void validate(), which throws Columnar |
build |
Built |
BuiltColumnarTopology
public final class. Validated, stateful, reusable, and synchronized.
| Member | Signature |
|---|---|
run |
List<Produced |
run |
List<Produced |
run |
evaluates one co-partitioned input map |
| state lifecycle | snapshot, restore, release, and close |
ColumnarNode
public final class. An opaque parent handle with no public members.
ColumnarRunner
public final class. A utility class.
public static long runPartitionOnce(
ColumnarTopology topology,
Consumer<byte[], byte[]> consumer,
Producer<byte[], byte[]> producer,
String topic,
int partition,
long offset,
Duration pollTimeout)
Commits and returns the next offset. group(...) creates a subscribed reusable runner;
group runners provide ordinary and transactional runOnce methods. The full overload
accepts ColumnarErrorPolicy, ColumnarStateStore, and ColumnarMetrics.
sendAsync returns a CompletableFuture<Void> for broker acknowledgements.
Runner support types:
ColumnarErrorPolicy:fail(),skip(), ordeadLetter(topic).ColumnarMetrics: lock-free counters exposed through an immutableSnapshot.ColumnarStateStore:load(int partition, long epoch)andsave(int partition, long epoch, Map<String, byte[]> snapshot);LIVE_EPOCHis the rebalance state andnone()is ephemeral.FileColumnarStateStore: atomically replaced snapshot files under a caller-owned path, in the container the three krabka streams libraries share.
The seven-argument group overload also accepts a BarrierAlignment. A runner built
with one exposes pendingCut(), restoreToEpoch(long), and restoreToLatestCut().
Codecs
| Type | Signature |
|---|---|
Batch |
interface: decode/encode methods, with default topic-aware overloads |
Blob |
final class implements Batch: Blob, Blob |
Gzip |
final class implements Batch: bounded GZIP decorator for another codec |
Row |
final class implements Batch: Row |
Arrow |
final class implements Serde<Vector: Arrow |
BlobCodec constants: DEFAULT_MAX_RECORD_BYTES (900 * 1024), KEY_COLUMN
(__key), TIMESTAMP_COLUMN (__timestamp), PARTITION_COLUMN (__partition),
OFFSET_COLUMN (__offset), HEADERS_COLUMN (__headers), plus
payloadColumn(String) for escaped collisions.
Row bridges
| Type | Signature |
|---|---|
Row |
interface: Vector, List<T> batch |
Json |
constructors accept Class<T>, optional Object or Arrow Schema; from derives fields |
ArrowValues
public final class of static helpers for RowBridge and ColumnarProcessor
implementations, exposing the same type-coercing conversions the built-in operators
use:
static VectorSchemaRoot createRoot(List<Field> fields, int rows, BufferAllocator allocator)
static void set(FieldVector vector, int row, Object value)
static Object get(FieldVector vector, int row)
static void finish(VectorSchemaRoot root)
Operators
| Type | Signature |
|---|---|
Columnar |
@Functional |
Stateful |
processor plus snapshot() and restore(byte[]) |
Columnar |
final class: void forward(Vector |
Row |
@Functional |
Row |
@Functional |
Derived |
record Derived |
Aggregation |
record Aggregation(String input |
Aggregate |
enum: COUNT, SUM, MIN, MAX |
BuiltinOp is a public final class implements ColumnarProcessor:
static BuiltinOp filter(BufferAllocator allocator, RowPredicate predicate)
static BuiltinOp select(BufferAllocator allocator, String... columns)
static BuiltinOp withColumns(BufferAllocator allocator, DerivedColumn... columns)
static BuiltinOp groupBy(
BufferAllocator allocator, Collection<String> keys, Aggregation... aggregations)
static BuiltinOp windowedGroupBy(
BufferAllocator allocator,
Collection<String> keys,
Duration size,
Aggregation... aggregations)
static BuiltinOp windowedGroupBy(
BufferAllocator allocator,
Collection<String> keys,
Duration size,
Duration retention,
Aggregation... aggregations)
void process(ColumnarContext context, VectorSchemaRoot batch)
Records and exceptions
public record RecordHeader(String key, byte[] value) {}
public record ConsumedRecord(..., List<RecordHeader> headers) {}
public record ProduceRecord(..., List<RecordHeader> headers) {}
public record ProducedToTopic(String topic, ProduceRecord record) {}
public record ColumnarJoin(
String leftKey, String rightKey, Duration window, String leftPrefix, String rightPrefix) {}
public final class ColumnarException extends RuntimeException {
public ColumnarException(String message);
public ColumnarException(String message, Throwable cause);
}
ConsumedRecord and ProduceRecord copy their byte arrays on construction and on
access. value must not be null; key may be.
Barrier alignment
Package io.krabka.streams.columnar.barrier. See
Barrier alignment for usage.
| Type | Signature |
|---|---|
Barrier |
record Barrier |
Barrier |
enum: COMPLETE, PARTIAL; code() and from |
Barrier |
final class: static Optional<Barrier; TOPIC is _ |
Barrier |
final class: Barrier, optional Duration; latest and complete |
Barrier |
record Barrier; on(String, Barrier and with |
Barrier |
interface: void on; none() |
BarrierCut members: complete(), offset(TopicPartition) returning OptionalLong,
recordsBefore(TopicPartition, List<ConsumedRecord>), and
reached(TopicPartition, long position). The offsets and the missing partitions are
copied on construction, so a decoded cut is immutable.
krabka-streams-columnar-schema
Package io.krabka.streams.columnar.schema. See
Columnar processing for usage. The module depends on both
krabka-streams-columnar and krabka-streams-schema-serde, plus
protobuf-java-util as an implementation dependency for the canonical Protobuf
JSON fallback.
AvroBatchCodec
public final class implements BatchCodec
| Member | Signature |
|---|---|
generic |
static Avro |
for |
static <T extends Specific |
register |
void register |
arrow |
Schema arrow (Arrow), the payload columns without metadata columns |
| decode/encode | the four Batch methods |
ProtobufBatchCodec
public final class implements BatchCodec
| Member | Signature |
|---|---|
of |
static <T extends Message> Protobuf |
register |
void register |
arrow |
Schema arrow (Arrow), the payload columns without metadata columns |
| decode/encode | the four Batch methods |
Row bridges and schema converters
| Type | Signature |
|---|---|
Avro |
implements Row: generic(Schema), for, arrow |
Protobuf |
implements Row: of(T default, arrow |
Avro |
static Schema to, static Field to |
Protobuf |
static Schema to, static Field to |
The bridges derive their Arrow schema once, at construction, from the reader schema
or message descriptor; mid-stream writer evolution never changes the columns.
Conversion choices that the Arrow type alone cannot reverse are tagged with
krabka.avro.*, krabka.proto.*, or krabka.json field metadata.
krabka-streams-coordination
Package io.krabka.streams.coordination. See Coordination for usage.
The module depends on krabka-streams for the pinned Kafka client version and uses the
producer, consumer, and admin clients only.
Role, MemberId
public final class, each Comparable and each built by one factory.
| Member | Signature |
|---|---|
MAX_ |
public static final int = 249 bytes, on both types |
of |
static Role of(String name), static Member |
| accessor | String name() on Role, String id() on Member |
bytes |
byte[] bytes() on Role, the UTF-8 name the partition rule hashes |
Both factories throw CoordinationException for an empty name and for a name past the
byte bound. A Role becomes a Kafka transactional.id.
FencingToken
public final class implements Comparable<FencingToken>
| Member | Signature |
|---|---|
NO_ |
public static final Fencing, the role no member has ever taken |
of |
static Fencing |
parse |
static Fencing, the id:epoch form |
producer |
long producer |
producer |
short producer |
minted |
boolean minted() |
compare |
lexicographic: producer id first, then producer epoch |
supersedes |
boolean supersedes(Fencing |
of rejects a negative value in either position.
Record types and codec
| Type | Signature |
|---|---|
Record |
enum: REGISTRATION (0), LEASE (1); code(), from |
Coordination |
sealed interface permits Registration, Lease: kind(), member() |
Registration |
record(Member |
Lease |
record(Member |
Coordination |
record(Record |
Coordination |
record(long offset, Coordination |
Coordination |
TOPIC, encode, encode, decode, decode, is |
Role |
DEFAULT_ = 16; static int partition |
CoordinationKey.registration(Role, MemberId) and CoordinationKey.lease(Role) build a
key that keeps the member rule of the frozen layout. decodeValue returns an empty
Optional for a tombstone.
Lease policy and clock
| Type | Signature |
|---|---|
Lease |
defaults(), of(Duration, Duration, Duration), duration(), renew, challenge, renews |
Lease |
challenge, grant(Member, timing(Lease) |
Lease |
lease(), expires, live, remaining, renew, renew |
Lease |
challenge |
Clock |
long now; static Clock system() |
Manual |
Manual, set(long), advance(Duration) |
The defaults are a 30-second lease, a 10-second renew interval, and a 5-second challenge
stagger. of rejects an extent that is not positive and a renew interval that is not
shorter than the duration.
Succession
| Type | Signature |
|---|---|
Roster |
record(Member |
Role |
empty(), from |
Role |
roster(), lease(), holder(), entry(Member, rank |
Role |
Role, role(), apply(Coordination, build() |
Decision |
record(Decision. |
Decision. |
NOT_, HOLD, CHALLENGE, WAIT |
Succession |
static Decision evaluate(Role |
The rules perform no input and no output. rankOf returns an OptionalInt, and the
rank is the index in the roster after the removal of the current holder.
Transport and client
| Type | Signature |
|---|---|
Coordination |
acquire, read, register, write, clear, describe, close |
Kafka |
(Admin, Producer, Function<Role, Producer>, Consumer) and an overload that takes a poll timeout |
Coordination |
(Coordination and (Coordination |
Coordination |
config(), read, describe(Role), try, acquire(. |
Leadership |
role(), member(), token(), lease(), timing(), held(), renew, renew(), resign() |
Leadership |
record(Role role, Fencing; holder(), lease(), held(), current() |
Coordination |
public class extends Runtime |
Fenced |
public final class extends Coordination; role() |
Leadership is AutoCloseable and resigns on close. FencedException is the only
signal that a leadership ended.
krabka-streams-test-utils
Package io.krabka.streams.test. See Testing for usage.
ColumnarTestDriver
public final class
| Member | Signature |
|---|---|
| constructor | Columnar |
pipe |
overloads accept record bytes and optional List<Record |
pipe |
void pipe |
fail |
injects one Runtime before the next batch evaluation |
is |
boolean is |
output |
int output |
read |
Produce, which throws No |
drain |
List<Produce |
SchemaRegistryStub
public final class ... implements AutoCloseable
| Member | Signature |
|---|---|
| constructor | Schema, which binds 127. on an ephemeral port |
uri |
URI uri() |
request |
int request |
close |
void close() |
This module also re-exports Apache Kafka’s kafka-streams-test-utils, including
TopologyTestDriver.
Compatibility
Nothing is deprecated yet. The public surface above is what future releases will be
judged against; package-private types
(AbstractSchemaSerde, ArrowBatchSupport, BridgeMetadata, ProtobufSchemaPrinter)
may change at any time.
Transitive api dependencies are part of the surface too: Kafka Streams 4.3.1, Avro
1.12.1, Protobuf 4.33.5, Jackson 2.22.0, and Arrow 19.0.0.