Line data Source code
1 :
2 : /* This application creates a ERSPublisher and dumps regular messages via the system
3 :
4 : */
5 :
6 : #include <chrono>
7 : #include <thread>
8 : #include <sstream>
9 : #include <memory>
10 :
11 : #include <ers/OutputStream.hpp>
12 : #include <ers/StreamManager.hpp>
13 :
14 : using namespace std;
15 :
16 0 : ERS_DECLARE_ISSUE( erskafka,
17 : TestIssue,
18 : "this is issue with ID: " << id,
19 : ((int)id)
20 : )
21 :
22 :
23 0 : int main( int argc, char * argv[] ) {
24 :
25 0 : std::string conf = "protobufstream(monkafka.cern.ch:30092)";
26 :
27 0 : setenv("DUNEDAQ_PARTITION", "TestPartition",0);
28 0 : setenv("DUNEDAQ_APPLICATION_NAME", "ERSStreamTest",0);
29 :
30 0 : auto stream = ers::StreamFactory::instance().create_out_stream( conf );
31 :
32 : int n = 20 ;
33 0 : for ( int i = 0 ; i < n ; ++i ) {
34 0 : erskafka::TestIssue issue(ERS_HERE, i);
35 0 : stream -> write( issue );
36 0 : this_thread::sleep_for(std::chrono::milliseconds(500+((i%2)*1000)));
37 0 : }
38 :
39 0 : erskafka::TestIssue first( ERS_HERE, 100);
40 0 : erskafka::TestIssue second( ERS_HERE, 200, first);
41 0 : erskafka::TestIssue third( ERS_HERE, 300, second);
42 :
43 0 : stream -> write( std::move(third) );
44 0 : this_thread::sleep_for(std::chrono::milliseconds(500));
45 :
46 0 : return 0 ;
47 0 : }
|