DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
ProtoBufStream.cpp
Go to the documentation of this file.
1
8
9#include "ProtoBufStream.hpp"
10#include <boost/crc.hpp>
11#include <chrono>
12#include <ers/StreamFactory.hpp>
13#include <iostream>
14#include <string>
15#include <vector>
16
18
19
22namespace erskafka {
24 : m_session("Uknown")
25 , m_application("Uknown")
26{
27
28 nlohmann::json conf;
29 conf["bootstrap"] = param;
30
31 m_publisher = std::make_unique<dunedaq::erskafka::ERSPublisher>(conf);
32
33 if (auto env_p = std::getenv("DUNEDAQ_SESSION"))
34 m_session = env_p;
35
36 if (auto app_p = std::getenv("DUNEDAQ_APPLICATION_NAME"))
37 m_application = app_p;
38}
39
43void
45{
46 try {
47
48 auto schema = to_schema_chain(issue);
49 schema.set_session(m_session);
50 schema.set_application(m_application);
51 m_publisher->publish(std::move(schema));
52
53 } catch (const std::exception& e) {
54 std::cerr << "Producer error : " << e.what() << '\n';
55 }
56}
57} // namespace erskafka
Base class for any user define issue.
Definition Issue.hpp:76
ERS stream implementation.
ProtoBufStream(const std::string &param)
std::unique_ptr< dunedaq::erskafka::ERSPublisher > m_publisher
void write(const ers::Issue &issue) override
#define ERS_REGISTER_OUTPUT_STREAM(class, name, param)
Definition macro.hpp:27