24#include <unordered_map>
82 template <
class Span>
using EnableIfByteSpan =
typename std::enable_if<std::is_same<Span, ByteSpan>::value,
int>::type;
173 template <
class Span, EnableIfByteSpan<Span> = 0>
177 return sendSpans(spans, spansCount);
200 template <
class Collection, details::EnableIfByteSpanCollection<Collection> = 0>
205 return send(checked.data, checked.count);
221 return send(spans, N);
232 void sendA(
const void* data,
size_t dataSize);
251 template <
class Span, EnableIfByteSpan<Span> = 0>
252 void sendA(
const Span spans[],
size_t spansCount)
254 sendASpans(spans, spansCount);
268 template <
class Collection, details::EnableIfByteSpanCollection<Collection> = 0>
272 sendA(checked.data, checked.count);
297 void sendB(
const void* data,
size_t dataSize);
316 template <
class Span, EnableIfByteSpan<Span> = 0>
317 void sendB(
const Span spans[],
size_t spansCount)
319 sendBSpans(spans, spansCount);
333 template <
class Collection, details::EnableIfByteSpanCollection<Collection> = 0>
337 sendB(checked.data, checked.count);
381 template <
class Span, EnableIfByteSpan<Span> = 0>
384 sendPrimarySpans(spans, spansCount);
398 template <
class Collection, details::EnableIfByteSpanCollection<Collection> = 0>
446 template <
class Span, EnableIfByteSpan<Span> = 0>
449 sendSecondarySpans(spans, spansCount);
463 template <
class Collection, details::EnableIfByteSpanCollection<Collection> = 0>
501 using FeedClientPtr =
std::unique_ptr<FeedClient>;
502 class AsyncSecondarySender;
505 static
void destruct(FeedClientPtr& client);
507 static
void send(FeedClientPtr& client, const
ByteSpan spans[],
size_t spansCount);
509 void sendASpans(const
ByteSpan spans[],
size_t spansCount);
510 void sendBSpans(const
ByteSpan spans[],
size_t spansCount);
511 void sendPrimarySpans(const
ByteSpan spans[],
size_t spansCount);
512 void sendSecondarySpans(const
ByteSpan spans[],
size_t spansCount);
513 size_t validateDataSize(const
ByteSpan spans[],
size_t spansCount);
515 FeedClientPtr& getFeed(
NetFeedRole::Enum role) noexcept;
516 const FeedClientPtr& getFeed(
NetFeedRole::Enum role) const noexcept;
523 FeedClientPtr feedA_;
524 FeedClientPtr feedB_;
525 std::unique_ptr<AsyncSecondarySender> asyncSecondarySender_;
533 template <
class Span>
534 using EnableIfByteSpan =
typename std::enable_if<std::is_same<Span, ByteSpan>::value,
int>::type;
641 template <
class Span, EnableIfByteSpan<Span> = 0>
645 return sendSpans(target, spans, spansCount);
668 template <
class Collection, details::EnableIfByteSpanCollection<Collection> = 0>
673 return send(target, checked.data, checked.count);
691 return send(target, spans, N);
707 struct NetFeedTypeHash
711 return static_cast<std::size_t
>(value);
717 std::unordered_map<NetFeedType::Enum, MulticastTargetPtr, NetFeedTypeHash> targets_;
#define ONIXS_CMEMDH_LTWT
#define ONIXS_CME_MDH_TESTING_NAMESPACE_END
#define ONIXS_CMEMDH_LTWT_EXPORTED
#define ONIXS_CME_MDH_TESTING_NAMESPACE_BEGIN
#define ONIXS_CMEMDH_EXPORTED
#define ONIXS_CMEMDH_NODISCARD
The collection of parameters defining feed connection.
~MulticastSender()
Releases all configured multicast targets.
Threading::Event send(NetFeedType::Enum target, const Span spans[], size_t spansCount)
Sends multiple byte views as one datagram to the requested network feed type.
MulticastSender(const MulticastSender &)=delete
Threading::Event send(NetFeedType::Enum target, const ByteSpan(&spans)[N])
Sends a fixed-size sequence of byte views as one datagram to a network feed type.
Threading::Event send(NetFeedType::Enum target, Collection &&spans)
Sends a contiguous collection of byte views to a network feed type.
MulticastSender & operator=(const MulticastSender &)=delete
Threading::Event send(NetFeedType::Enum target, const void *data, size_t dataSize)
Sends a datagram to the requested network feed type.
static MulticastTargetPtr constructTarget(NetFeedType::Enum target, const FeedSettings &feedSettings, Messaging::TimeSpan arbitrageDelay=Messaging::TimeSpan{}, ReplayDelayer &delayPolicy=CombinedReplayDelayer::service(), const MulticastTargetOptions &options=MulticastTargetOptions{})
Constructs a multicast target for the requested network feed type.
MulticastSender(const FeedSettings &feedSettings=generateFeedSettings(), Messaging::TimeSpan arbitrageDelay=Messaging::TimeSpan{}, ReplayDelayer &delayPolicy=CombinedReplayDelayer::service(), const MulticastTargetOptions &options=MulticastTargetOptions{})
Initializes multicast targets from the feed settings.
Threading::Event send(NetFeedType::Enum target, ByteSpan span)
Sends a byte view as a datagram to the requested network feed type.
MulticastTargetPtr & getTarget(NetFeedType::Enum target)
Returns the multicast target configured for the requested network feed type.
Threading::Event send(Collection &&spans)
Sends a contiguous collection of byte views as one datagram.
~MulticastTarget()
Leaves joined multicast groups and releases owned multicast clients.
void sendSecondary(const Span spans[], size_t spansCount)
Sends multiple byte views as one datagram to the secondary feed when configured.
void sendB(const void *data, size_t dataSize)
Sends a datagram to feed B when feed B is configured.
void sendB(const ByteSpan(&spans)[N])
Sends a fixed-size sequence of byte views as one datagram to feed B.
static constexpr size_t MaxSpansCount
Maximum number of byte spans accepted by a gather send.
void sendSecondary(const ByteSpan(&spans)[N])
Sends a fixed-size sequence of byte views as one datagram to the secondary feed.
MulticastTarget(NetFeedType::Enum target, const FeedSettings &feedSettings=generateFeedSettings(), Messaging::TimeSpan arbitrageDelay=Messaging::TimeSpan{}, ReplayDelayer &delayPolicy=CombinedReplayDelayer::service(), const MulticastTargetOptions &options=MulticastTargetOptions{})
Initializes the target for one network feed type.
NetFeedRole::Enum secondaryFeed() const noexcept
Returns the feed role used as the secondary feed.
void sendB(Collection &&spans)
Sends a contiguous collection of byte views as one datagram to feed B.
void sendPrimary(const ByteSpan(&spans)[N])
Sends a fixed-size sequence of byte views as one datagram to the primary feed.
void sendA(const void *data, size_t dataSize)
Sends a datagram to feed A when feed A is configured.
Threading::Event send(const ByteSpan(&spans)[N])
Sends a fixed-size sequence of byte views as one datagram to the configured feeds.
void sendPrimary(ByteSpan span)
Sends a byte view as a datagram to the primary feed.
void sendPrimary(const Span spans[], size_t spansCount)
Sends multiple byte views as one datagram to the primary feed.
Threading::Event send(const Span spans[], size_t spansCount)
Sends multiple byte views as one datagram to the configured multicast feeds.
void sendA(ByteSpan span)
Sends a byte view as a datagram to feed A when feed A is configured.
NetFeedRole::Enum primaryFeed() const noexcept
Returns the feed role used as the primary feed.
void sendSecondary(const void *data, size_t dataSize)
Sends a datagram immediately to the secondary feed when it is configured.
bool hasSecondary() const noexcept
Indicates whether the configured layout has a secondary feed.
Threading::Event send(const void *data, size_t dataSize)
Sends a datagram to the primary feed and sends to the secondary feed when it is configured.
void sendA(const Span spans[], size_t spansCount)
Sends multiple byte views as one datagram to feed A when configured.
void sendA(Collection &&spans)
Sends a contiguous collection of byte views as one datagram to feed A.
static constexpr PacketSize DefaultMaxPacketSize
Packet-size value matching the default feed settings.
void sendSecondary(Collection &&spans)
Sends a contiguous collection of byte views as one datagram to the secondary feed.
Threading::Event send(ByteSpan span)
Sends a byte view as a datagram to the configured multicast feeds.
void sendPrimary(const void *data, size_t dataSize)
Sends a datagram to the primary feed.
void sendB(const Span spans[], size_t spansCount)
Sends multiple byte views as one datagram to feed B when configured.
void sendSecondary(ByteSpan span)
Sends a byte view immediately to the secondary feed when it is configured.
void sendPrimary(Collection &&spans)
Sends a contiguous collection of byte views as one datagram to the primary feed.
void sendA(const ByteSpan(&spans)[N])
Sends a fixed-size sequence of byte views as one datagram to feed A.
void sendB(ByteSpan span)
Sends a byte view as a datagram to feed B when feed B is configured.
std::uint64_t UInt64
uInt64.
UInt8 Byte
Alias for Byte.
SpanRange checkedSpans(Collection &spans, std::size_t maxSpansCount, std::size_t minSpansCount=0)
constexpr const char *const MulticastEgressEnvironmentVariable
Environment variable authorizing multicast traffic beyond the local host.
FeedSettings generateFeedSettings(ChannelId channel=999)
Generates feed settings for one testing channel.
constexpr const char *const AllowAnyMulticastDestinationEnvironmentVariable
Environment variable authorizing outgoing multicast destinations outside 239.0.0.0/8.
std::unique_ptr< MulticastTarget > MulticastTargetPtr
std::span< const std::uint8_t > ByteSpan
Provides a non-owning read-only view over contiguous byte storage.
SharedFuture< void > Event
Completion signal for an asynchronous operation that does not produce a value.
Messaging::UInt16 PacketSize
Represents a packet size in bytes.
static ReplayDelayer & service()
Returns the instance reference.
Identifies feed A or feed B within a redundant pair.
Enum
Supported feed roles.
@ A
Feed A in the redundant pair.
Enum
Supported market data feed services.
Configures multicast sockets used by a multicast target.
MulticastTargetOptions()=default
Initializes multicast target options with a TTL of zero.
MulticastTargetOptions & ttl(Messaging::UInt64 value)
Sets the IPv4 multicast time-to-live.
Messaging::Byte ttl() const noexcept
Returns the IPv4 multicast time-to-live.