use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.
the class KafkaCacheClientProduceFactory method doBegin.
private void doBegin(MessageConsumer receiver, long routeId, long streamId, long sequence, long acknowledge, int maximum, long traceId, long authorization, long affinity, Consumer<OctetsFW.Builder> extension) {
final BeginFW begin = beginRW.wrap(writeBuffer, 0, writeBuffer.capacity()).routeId(routeId).streamId(streamId).sequence(sequence).acknowledge(acknowledge).maximum(maximum).traceId(traceId).authorization(authorization).affinity(affinity).extension(extension).build();
receiver.accept(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof());
}
use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.
the class KafkaCacheClientProduceFactory method newStream.
private MessageConsumer newStream(MessageConsumer sender, long routeId, long streamId, long sequence, long acknowledge, int maximum, long traceId, long authorization, long affinity, Consumer<OctetsFW.Builder> extension) {
final BeginFW begin = beginRW.wrap(writeBuffer, 0, writeBuffer.capacity()).routeId(routeId).streamId(streamId).sequence(sequence).acknowledge(acknowledge).maximum(maximum).traceId(traceId).authorization(authorization).affinity(affinity).extension(extension).build();
final MessageConsumer receiver = streamFactory.newStream(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof(), sender);
receiver.accept(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof());
return receiver;
}
use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.
the class KafkaCacheMetaFactory method doBegin.
private void doBegin(MessageConsumer receiver, long routeId, long streamId, long sequence, long acknowledge, int maximum, long traceId, long authorization, long affinity, Consumer<OctetsFW.Builder> extension) {
final BeginFW begin = beginRW.wrap(writeBuffer, 0, writeBuffer.capacity()).routeId(routeId).streamId(streamId).sequence(sequence).acknowledge(acknowledge).maximum(maximum).traceId(traceId).authorization(authorization).affinity(affinity).extension(extension).build();
receiver.accept(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof());
}
use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.
the class KafkaClientFetchFactory method newStream.
@Override
public MessageConsumer newStream(int msgTypeId, DirectBuffer buffer, int index, int length, MessageConsumer application) {
final BeginFW begin = beginRO.wrap(buffer, index, index + length);
final long routeId = begin.routeId();
final long initialId = begin.streamId();
final long leaderId = begin.affinity();
final long authorization = begin.authorization();
final OctetsFW extension = begin.extension();
final ExtensionFW beginEx = extensionRO.tryWrap(extension.buffer(), extension.offset(), extension.limit());
final KafkaBeginExFW kafkaBeginEx = beginEx.typeId() == kafkaTypeId ? extension.get(kafkaBeginExRO::wrap) : null;
assert kafkaBeginEx == null || kafkaBeginEx.kind() == KafkaBeginExFW.KIND_FETCH;
final KafkaFetchBeginExFW kafkaFetchBeginEx = kafkaBeginEx != null ? kafkaBeginEx.fetch() : null;
MessageConsumer newStream = null;
if (beginEx != null && kafkaFetchBeginEx != null && kafkaFetchBeginEx.filters().isEmpty()) {
final String16FW beginTopic = kafkaFetchBeginEx.topic();
final String topicName = beginTopic.asString();
final KafkaBindingConfig binding = supplyBinding.apply(routeId);
final KafkaRouteConfig resolved = binding != null ? binding.resolve(authorization, topicName) : null;
if (resolved != null) {
final long resolvedId = resolved.id;
final KafkaOffsetFW partition = kafkaFetchBeginEx.partition();
final int partitionId = partition.partitionId();
final long initialOffset = partition.partitionOffset();
final long latestOffset = partition.latestOffset();
newStream = new KafkaFetchStream(application, routeId, initialId, resolvedId, topicName, partitionId, latestOffset, leaderId, initialOffset)::onApplication;
}
}
return newStream;
}
use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.
the class KafkaClientMetaFactory method newStream.
@Override
public MessageConsumer newStream(int msgTypeId, DirectBuffer buffer, int index, int length, MessageConsumer application) {
final BeginFW begin = beginRO.wrap(buffer, index, index + length);
final long routeId = begin.routeId();
final long initialId = begin.streamId();
final long affinity = begin.affinity();
final long authorization = begin.authorization();
final OctetsFW extension = begin.extension();
final ExtensionFW beginEx = extensionRO.tryWrap(extension.buffer(), extension.offset(), extension.limit());
final KafkaBeginExFW kafkaBeginEx = beginEx != null && beginEx.typeId() == kafkaTypeId ? kafkaBeginExRO.tryWrap(extension.buffer(), extension.offset(), extension.limit()) : null;
assert kafkaBeginEx.kind() == KafkaBeginExFW.KIND_META;
final String16FW beginTopic = kafkaBeginEx.meta().topic();
final String topicName = beginTopic.asString();
MessageConsumer newStream = null;
final KafkaBindingConfig binding = supplyBinding.apply(routeId);
final KafkaRouteConfig resolved = binding != null ? binding.resolve(authorization, topicName) : null;
if (resolved != null && kafkaBeginEx != null) {
final long resolvedId = resolved.id;
newStream = new KafkaMetaStream(application, routeId, initialId, affinity, resolvedId, topicName)::onApplication;
}
return newStream;
}
Aggregations