1
#pragma once
2

            
3
#include <atomic>
4
#include <functional>
5
#include <memory>
6
#include <string>
7

            
8
#include "envoy/thread/thread.h"
9

            
10
#include "source/common/common/logger.h"
11
#include "source/common/network/address_impl.h"
12

            
13
namespace Envoy {
14

            
15
class UDSServer : public Logger::Loggable<Logger::Id::router> {
16
public:
17
  UDSServer(const std::string& path, std::function<void(const std::string&)> cb);
18
  ~UDSServer();
19

            
20
private:
21
  void close();
22
  void threadRoutine();
23

            
24
  std::function<void(const std::string&)> msg_cb_;
25
  std::shared_ptr<Network::Address::PipeInstance> addr_;
26
  std::atomic<int> fd_;
27
  std::atomic<int> fd2_;
28
  Thread::ThreadPtr thread_;
29
};
30

            
31
} // namespace Envoy