1
#pragma once
2

            
3
#include "envoy/config/core/v3/base.pb.h"
4
#include "envoy/event/dispatcher.h"
5
#include "envoy/filesystem/watcher.h"
6

            
7
namespace Envoy {
8
namespace Config {
9

            
10
// Implement the common functionality of envoy::config::core::v3::WatchedDirectory.
11
class WatchedDirectory {
12
public:
13
  static absl::StatusOr<std::unique_ptr<WatchedDirectory>>
14
  create(const envoy::config::core::v3::WatchedDirectory& config, Event::Dispatcher& dispatcher);
15

            
16
  using Callback = std::function<absl::Status()>;
17

            
18
33
  void setCallback(Callback cb) { cb_ = cb; }
19

            
20
protected:
21
  WatchedDirectory(const envoy::config::core::v3::WatchedDirectory& config,
22
                   Event::Dispatcher& dispatcher, absl::Status& creation_status);
23

            
24
private:
25
  std::unique_ptr<Filesystem::Watcher> watcher_;
26
  Callback cb_;
27
};
28

            
29
using WatchedDirectoryPtr = std::unique_ptr<WatchedDirectory>;
30

            
31
} // namespace Config
32
} // namespace Envoy