aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Common/StatusFile.h
blob: 5115e54428fdbec4fd4fea051c8a8119a89b10df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#pragma once

#include <string>
#include <functional>
#include <boost/noncopyable.hpp>


namespace DB
{

class WriteBuffer;


/** Provides that no more than one server works with one data directory.
  */
class StatusFile : private boost::noncopyable
{
public:
    using FillFunction = std::function<void(WriteBuffer&)>;

    StatusFile(std::string path_, FillFunction fill_);
    ~StatusFile();

    /// You can use one of these functions to fill the file or provide your own.
    static FillFunction write_pid;
    static FillFunction write_full_info;

private:
    const std::string path;
    FillFunction fill;
    int fd = -1;
};


}