26 class itch5_stats_handler {
28 explicit itch5_stats_handler(config
const& cfg)
29 : stats_(cfg.stats()) {
34 time_point now()
const {
35 return std::chrono::steady_clock::now();
38 template <
typename message_type>
40 time_point recv_ts,
long msgcnt, std::size_t msgoffset,
41 message_type
const& msg) {
42 JB_LOG(trace) << msgcnt <<
":" << msgoffset <<
" " << msg;
43 auto pl = now() - recv_ts;
44 stats_.sample(msg.header.timestamp.ts, pl);
49 char msgtype = *
static_cast<char const*
>(msg.
buf());
50 JB_LOG(error) <<
"Unknown message type '" << msgtype <<
"'(" << int(msgtype)
51 <<
") in msgcnt=" << msg.
count()
52 <<
", msgoffset=" << msg.
offset();
61 int main(
int argc,
char* argv[])
try {
63 cfg.load_overrides(argc, argv, std::string(
"itch5stats.yaml"),
"JB_ROOT");
66 boost::iostreams::filtering_istream in;
69 itch5_stats_handler handler(cfg);
74 std::cerr << u.what() << std::endl;
76 }
catch (std::exception
const& ex) {
77 std::cerr <<
"Standard exception raised: " << ex.what() << std::endl;
80 std::cerr <<
"Unknown exception raised" << std::endl;
87 desc(
"input-file").help(
"An input file with ITCH-5.0 messages."),
89 , stats(desc(
"stats",
"offline-feed-statistics"),
this) {
92 void config::validate()
const {
93 if (input_file() ==
"") {
95 "Missing input-file setting." 96 " You must specify an input file.",
clock_type::time_point time_point
A convenience alias for clock_type::time_point.
Base class for all configuration objects.
virtual void validate() const
Validate the settings.
Keep statistics about a feed and its offline processor.
int main(int argc, char *argv[])
void process_iostream(std::istream &in, message_handler &handler)
Process an iostream of ITCH-5.0 messages.
void init(config const &cfg)
Initialize the logging functions using the configuration provided.
#define config_object_constructors(NAME)
Helper class to easily define configuration attributes.
A simple class to communicate the result of parsing the options.
void open_input_file(boost::iostreams::filtering_istream &in, std::string const &filename)
Open a file for reading.
std::uint32_t count() const
std::uint64_t offset() const