Search in sources :

Example 11 with BeginFW

use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.

the class KafkaClientFetchFactory 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;
}
Also used : MessageConsumer(io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer) BeginFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW)

Example 12 with BeginFW

use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.

the class KafkaClientMetaFactory 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());
}
Also used : BeginFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW)

Example 13 with BeginFW

use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.

the class KafkaClientMetaFactory 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;
}
Also used : MessageConsumer(io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer) BeginFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW)

Example 14 with BeginFW

use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.

the class KafkaClientProduceFactory 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.typeId() == kafkaTypeId ? extension.get(kafkaBeginExRO::wrap) : null;
    assert kafkaBeginEx == null || kafkaBeginEx.kind() == KafkaBeginExFW.KIND_PRODUCE;
    final KafkaProduceBeginExFW kafkaProduceBeginEx = kafkaBeginEx != null ? kafkaBeginEx.produce() : null;
    MessageConsumer newStream = null;
    if (kafkaProduceBeginEx != null) {
        final String16FW beginTopic = kafkaProduceBeginEx.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 && kafkaBeginEx != null) {
            final long resolvedId = resolved.id;
            final int partitionId = kafkaProduceBeginEx.partition().partitionId();
            newStream = new KafkaProduceStream(application, routeId, initialId, affinity, resolvedId, topicName, partitionId)::onApplication;
        }
    }
    return newStream;
}
Also used : ExtensionFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.ExtensionFW) KafkaProduceBeginExFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaProduceBeginExFW) MessageConsumer(io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer) OctetsFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.OctetsFW) 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) KafkaRouteConfig(io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaRouteConfig) String16FW(io.aklivity.zilla.runtime.binding.kafka.internal.types.String16FW)

Example 15 with BeginFW

use of io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW in project zilla by aklivity.

the class KafkaClientProduceFactory 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;
}
Also used : MessageConsumer(io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer) BeginFW(io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW)

Aggregations

BeginFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.BeginFW)44 MessageConsumer (io.aklivity.zilla.runtime.engine.binding.function.MessageConsumer)31 OctetsFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.OctetsFW)17 ExtensionFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.ExtensionFW)17 KafkaBeginExFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaBeginExFW)17 KafkaBindingConfig (io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaBindingConfig)14 String16FW (io.aklivity.zilla.runtime.binding.kafka.internal.types.String16FW)14 KafkaRouteConfig (io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaRouteConfig)11 KafkaCache (io.aklivity.zilla.runtime.binding.kafka.internal.cache.KafkaCache)6 KafkaCacheTopic (io.aklivity.zilla.runtime.binding.kafka.internal.cache.KafkaCacheTopic)6 KafkaOffsetFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.KafkaOffsetFW)5 KafkaCachePartition (io.aklivity.zilla.runtime.binding.kafka.internal.cache.KafkaCachePartition)4 KafkaDeltaType (io.aklivity.zilla.runtime.binding.kafka.internal.types.KafkaDeltaType)4 BindingHandler (io.aklivity.zilla.runtime.engine.binding.BindingHandler)4 ArrayList (java.util.ArrayList)4 KafkaOffsetType (io.aklivity.zilla.runtime.binding.kafka.internal.types.KafkaOffsetType)3 KafkaDescribeBeginExFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaDescribeBeginExFW)3 KafkaFetchBeginExFW (io.aklivity.zilla.runtime.binding.kafka.internal.types.stream.KafkaFetchBeginExFW)3 KafkaTopicConfig (io.aklivity.zilla.runtime.binding.kafka.internal.config.KafkaTopicConfig)2 KafkaCapabilities (io.aklivity.zilla.runtime.binding.kafka.internal.types.KafkaCapabilities)2