Copyright Matus Chochlik. Distributed under the Boost Software License, Version 1.0. See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
#include <array>
#include <thread>
auto main(main_ctx& ctx) -> int {
std::array<span_size_t, 256> byte_counts{};
auto log_byte_hist = [&ctx, &byte_counts](
const msgbus::message_context& mc,
msgbus::stored_message& msg) {
for(auto b : msg.content()) {
}
ctx.log()
.info("received blob message ${message}")
.arg_func([&byte_counts, max_count](logger_backend& backend) {
for(std::size_t i = 0; i < 256; ++i) {
backend.add_float(
float(0),
float(byte_counts[i]),
float(max_count));
}
});
return true;
};
return true;
};
msgbus::router_address
address{ctx};
msgbus::connection_setup conn_setup(ctx);
msgbus::endpoint bus{
conn_setup.setup_connectors(bus,
address);
timeout idle_too_long{std::chrono::minutes{1}};
while(!idle_too_long) {
if(
bus.update() ||
bus.process_everything({construct_from, log_byte_hist})) {
idle_too_long.reset();
} else {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
bus.finish();
return 0;
}
}
blob_manipulator::filter_function blob_filter_function
Alias for blob message type filter callable reference.
Definition: endpoint.hpp:47
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
#define EAGINE_ID(NAME)
Macro for constructing instances of eagine::identifier.
Definition: identifier.hpp:353
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto cover(T *addr, S size) noexcept -> span_if_mutable< T >
Creates a span starting at the specified pointer and specified length.
Definition: span.hpp:465
basic_address< false > address
Type alias for non-const memory address values.
Definition: address.hpp:203
static constexpr auto std_size(T v) noexcept
Converts argument to std size type.
Definition: types.hpp:52
static constexpr auto maximum(T a, T b) noexcept
Returns the maximum value of a and b.
Definition: functions.hpp:61
@ message
Message protocol.
static auto zero(basic_span< T, P, S > spn) -> std::enable_if_t< std::is_integral_v< T >||std::is_floating_point_v< T >, basic_span< T, P, S >>
Fills a span with zero value of type T.
Definition: span_algo.hpp:548
auto byte_to_identifier(byte b) noexcept -> identifier
Creates an identifier representing a byte value as a hex string.
@ message_id
The message type id has been verified.