Project
Loading...
Searching...
No Matches
o2SimpleSink.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
15
16#include <chrono>
17#include <thread>
18#include <vector>
19#include <fairmq/Device.h>
20
21using namespace o2::framework;
22
23void customize(std::vector<ConfigParamSpec>& workflowOptions)
24{
25 workflowOptions.emplace_back(
26 ConfigParamSpec{"dataspec", VariantType::String, "", {"DataSpec for the outputs"}});
27 workflowOptions.emplace_back(
28 ConfigParamSpec{"name", VariantType::String, "test-sink", {"Name of the source"}});
29}
31
32AlgorithmSpec simplePipe(std::string const& what, int minDelay)
33{
34 return AlgorithmSpec{adaptStateful([what, minDelay]() {
35 srand(getpid());
36 return adaptStateless([what, minDelay](DataAllocator& outputs, RawDeviceService& device) {
37 LOG(info) << "Callback invoked";
38 outputs.make<int>(OutputRef{what}, 1);
39 device.device()->WaitFor(std::chrono::seconds(minDelay));
40 });
41 })};
42}
43
44// This is how you can define your processing in a declarative way
46{
47 // Get the dataspec option and creates OutputSpecs from it
48 auto dataspec = ctx.options().get<std::string>("dataspec");
49 std::vector<InputSpec> inputs = select(dataspec.c_str());
50
51 return WorkflowSpec{
52 {
53 .name = ctx.options().get<std::string>("name"),
54 .inputs = inputs,
55 .algorithm = AlgorithmSpec{adaptStateless(
56 [](InputRecord& inputs) {
57 LOG(info) << "Received " << inputs.size() << " messages";
58 })},
59 }};
60}
ConfigParamRegistry & options() const
decltype(auto) make(const Output &spec, Args... args)
The input API of the Data Processing Layer This class holds the inputs which are valid for processing...
virtual fair::mq::Device * device()=0
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
AlgorithmSpec::ProcessCallback adaptStateless(LAMBDA l)
std::vector< InputSpec > select(char const *matcher="")
AlgorithmSpec::InitCallback adaptStateful(LAMBDA l)
WorkflowSpec defineDataProcessing(ConfigContext const &ctx)
This function hooks up the the workflow specifications into the DPL driver.
AlgorithmSpec simplePipe(std::string const &what, int minDelay)
void customize(std::vector< ConfigParamSpec > &workflowOptions)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"