Line data Source code
1 : #pragma once 2 : 3 : #include <ostream> 4 : 5 : #include "envoy/common/pure.h" 6 : #include "envoy/server/fatal_action_config.h" 7 : #include "envoy/thread/thread.h" 8 : 9 : namespace Envoy { 10 : namespace FatalAction { 11 : 12 : using FatalActionPtrList = std::list<Server::Configuration::FatalActionPtr>; 13 : 14 : // Status when trying to run the Fatal Actions. 15 : enum class Status { 16 : Success, 17 : 18 : // We either haven't set up the Fatal Action manager, or we unregistered it 19 : // as the server terminated. 20 : ActionManagerUnset, 21 : 22 : // Another thread beat us to running the Fatal Actions. 23 : RunningOnAnotherThread, 24 : 25 : // We have already ran those actions on this thread. 26 : AlreadyRanOnThisThread, 27 : }; 28 : 29 : // A simple class which manages the Fatal Actions registered via the 30 : // extension point. 31 : class FatalActionManager { 32 : public: 33 : FatalActionManager(FatalActionPtrList safe_actions, FatalActionPtrList unsafe_actions, 34 : Thread::ThreadFactory& thread_factory) 35 : : safe_actions_(std::move(safe_actions)), unsafe_actions_(std::move(unsafe_actions)), 36 131 : thread_factory_(thread_factory) {} 37 : 38 0 : const FatalActionPtrList& getSafeActions() const { return safe_actions_; } 39 0 : const FatalActionPtrList& getUnsafeActions() const { return unsafe_actions_; } 40 0 : Thread::ThreadFactory& getThreadFactory() const { return thread_factory_; } 41 : 42 : private: 43 : FatalActionPtrList safe_actions_; 44 : FatalActionPtrList unsafe_actions_; 45 : Thread::ThreadFactory& thread_factory_; 46 : }; 47 : 48 : } // namespace FatalAction 49 : } // namespace Envoy