use of io.aklivity.zilla.runtime.engine.binding.BindingHandler in project zilla by aklivity.
the class KafkaCacheClientFactory 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 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;
MessageConsumer newStream = null;
if (kafkaBeginEx != null) {
final BindingHandler factory = factories.get(kafkaBeginEx.kind());
if (factory != null) {
newStream = factory.newStream(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof(), sender);
}
}
return newStream;
}
use of io.aklivity.zilla.runtime.engine.binding.BindingHandler in project zilla by aklivity.
the class KafkaCacheServerFactory 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 OctetsFW extension = begin.extension();
final ExtensionFW beginEx = extension.get(extensionRO::tryWrap);
assert beginEx != null;
final int typeId = beginEx.typeId();
assert beginEx != null && typeId == kafkaTypeId;
MessageConsumer newStream = null;
final KafkaBeginExFW kafkaBeginEx = extension.get(kafkaBeginExRO::tryWrap);
if (kafkaBeginEx != null) {
final BindingHandler streamFactory = factories.get(kafkaBeginEx.kind());
if (streamFactory != null) {
newStream = streamFactory.newStream(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof(), sender);
}
}
return newStream;
}
use of io.aklivity.zilla.runtime.engine.binding.BindingHandler in project zilla by aklivity.
the class TestBindingFactory method newStream.
private MessageConsumer newStream(MessageConsumer source, long routeId, long streamId, long sequence, long acknowledge, int maximum, long traceId) {
MutableDirectBuffer writeBuffer = context.writeBuffer();
BindingHandler streamFactory = context.streamFactory();
BeginFW begin = beginRW.wrap(writeBuffer, 0, writeBuffer.capacity()).routeId(routeId).streamId(streamId).sequence(sequence).acknowledge(acknowledge).maximum(maximum).traceId(traceId).affinity(0L).build();
MessageConsumer stream = streamFactory.newStream(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof(), source);
stream.accept(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof());
return stream;
}
use of io.aklivity.zilla.runtime.engine.binding.BindingHandler in project zilla by aklivity.
the class KafkaClientFactory 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 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;
MessageConsumer newStream = null;
if (kafkaBeginEx != null) {
final BindingHandler factory = factories.get(kafkaBeginEx.kind());
if (factory != null) {
newStream = factory.newStream(begin.typeId(), begin.buffer(), begin.offset(), begin.sizeof(), application);
}
}
return newStream;
}
use of io.aklivity.zilla.runtime.engine.binding.BindingHandler in project zilla by aklivity.
the class DispatchAgent method handleBeginInitial.
private MessageConsumer handleBeginInitial(int msgTypeId, DirectBuffer buffer, int index, int length) {
final BeginFW begin = beginRO.wrap(buffer, index, index + length);
final long routeId = begin.routeId();
final long initialId = begin.streamId();
MessageConsumer newStream = null;
BindingRegistry binding = configuration.resolveBinding(routeId);
final BindingHandler streamFactory = binding != null ? binding.streamFactory() : null;
if (streamFactory != null) {
final MessageConsumer replyTo = supplyReplyTo(initialId);
newStream = streamFactory.newStream(msgTypeId, buffer, index, length, replyTo);
if (newStream != null) {
final long replyId = supplyReplyId(initialId);
streams[streamIndex(initialId)].put(instanceId(initialId), newStream);
throttles[throttleIndex(replyId)].put(instanceId(replyId), newStream);
supplyLoadEntry.apply(routeId).initialOpened(1L);
}
}
return newStream;
}
Aggregations