forked from envoyproxy/envoy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
drain_manager_impl.h
42 lines (33 loc) · 1.2 KB
/
drain_manager_impl.h
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
36
37
38
39
40
41
42
#pragma once
#include <chrono>
#include <functional>
#include "envoy/server/drain_manager.h"
#include "envoy/server/instance.h"
#include "common/common/logger.h"
namespace Envoy {
namespace Server {
/**
* Implementation of drain manager that does the following by default:
* 1) Terminates the parent process after 15 minutes.
* 2) Drains the parent process over a period of 10 minutes where drain close becomes more
* likely each second that passes.
*/
class DrainManagerImpl : Logger::Loggable<Logger::Id::main>, public DrainManager {
public:
DrainManagerImpl(Instance& server, envoy::api::v2::Listener::DrainType drain_type);
// Server::DrainManager
bool drainClose() const override;
void startDrainSequence(std::function<void()> completion) override;
void startParentShutdownSequence() override;
private:
bool draining() const { return drain_tick_timer_ != nullptr; }
void drainSequenceTick();
Instance& server_;
const envoy::api::v2::Listener::DrainType drain_type_;
Event::TimerPtr drain_tick_timer_;
std::atomic<uint32_t> drain_time_completed_{};
Event::TimerPtr parent_shutdown_timer_;
std::function<void()> drain_sequence_completion_;
};
} // namespace Server
} // namespace Envoy