Search in sources :

Example 1 with KafkaBootstrapBeginExFW

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;
}
Also used : ExtensionFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.ExtensionFW) MessageConsumer(io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer) KafkaBootstrapBeginExFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW) KafkaTopicConfig(io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaTopicConfig) OctetsFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.OctetsFW) String16FW(io.aklivity.zilla.runtime.binding.kafka.internal.types.String16FW) BeginFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW) KafkaBindingConfig(io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaBindingConfig) KafkaBeginExFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaBeginExFW)

Aggregations

KafkaBindingConfig (io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaBindingConfig)1 KafkaTopicConfig (io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaTopicConfig)1 OctetsFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.OctetsFW)1 String16FW (io.aklivity.zilla.runtime.binding.kafka.internal.types.String16FW)1 BeginFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW)1 ExtensionFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.ExtensionFW)1 KafkaBeginExFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaBeginExFW)1 KafkaBootstrapBeginExFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaBootstrapBeginExFW)1 MessageConsumer (io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer)1