use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW in project zilla by aklivity.
the class KafkaCacheServerBootstrapFactory method newStream.
@Override
public MessageConsumer newStream(int msgTypeId, DirectBuffer buffer, int index, int length, MessageConsumer sender) {
final BeginFW begin = beginRO.wrap(buffer, index, index + length);
final long routeId = begin.routeId();
final long initialId = begin.streamId();
final long authorization = begin.authorization();
final long affinity = begin.affinity();
assert (initialId & 0x0000_0000_0000_0001L) != 0L;
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 != null;
assert kafkaBeginEx.kind() == KafkaBeginExFW.KIND_BOOTSTRAP;
final KafkaBootstrapBeginExFW kafkaBootstrapBeginEx = kafkaBeginEx.bootstrap();
final String16FW beginTopic = kafkaBootstrapBeginEx.topic();
final String topicName = beginTopic != null ? beginTopic.asString() : null;
MessageConsumer newStream = null;
final KafkaBindingConfig binding = supplyBinding.apply(routeId);
if (binding != null && binding.bootstrap(topicName)) {
final KafkaTopicConfig topic = binding.topic(topicName);
final long resolvedId = routeId;
final long defaultOffset = topic != null && topic.defaultOffset != null ? topic.defaultOffset.value() : OFFSET_HISTORICAL;
newStream = new KafkaBootstrapStream(sender, routeId, initialId, affinity, authorization, topicName, resolvedId, defaultOffset)::onBootstrapInitial;
}
return newStream;
}
Aggregations