osquery-1/osquery/ev2/tests/utils.h
Filipe Manco 438a6e1464 Basic ev2 framework (#5401)
Summary:
Pull Request resolved: https://github.com/facebook/osquery/pull/5401

Extremely rough implementation of the basic componenets to get things going.

Blueprint issue #5158 .

Reviewed By: akindyakov

Differential Revision: D13779295

fbshipit-source-id: c7373794e8152ffea8a7c5d97f0c937bf97a2a0a
2019-01-29 09:30:20 -08:00

57 lines
1.3 KiB
C++

/**
* Copyright (c) 2018-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed as defined on the LICENSE file found in the
* root directory of this source tree.
*/
#pragma once
#include <chrono>
#include <osquery/ev2/publisher.h>
#include <osquery/ev2/subscription.h>
namespace osquery {
namespace ev2 {
class TestEvent {
public:
using Id = uint64_t;
using Time = std::chrono::system_clock::time_point;
explicit TestEvent(Id id, Time time);
virtual ~TestEvent() = default;
bool operator==(const TestEvent& rhs) const;
bool operator!=(const TestEvent& rhs) const;
const Id id;
const Time time;
};
class NullPublisher : public ev2::Publisher {
public:
explicit NullPublisher(const std::string& name);
~NullPublisher() = default;
ExpectedSuccess<Publisher::Error> subscribe(
std::shared_ptr<Subscription> subscription) override;
};
class NullSubscription : public ev2::Subscription {
public:
explicit NullSubscription(const std::string& subscriber);
~NullSubscription() = default;
std::size_t avail() const override;
std::size_t wait(std::size_t batch = 1,
std::chrono::milliseconds timeout =
std::chrono::milliseconds::zero()) override;
void abort() override;
};
} // namespace ev2
} // namespace osquery