LCOV - code coverage report
Current view: top level - envoy/init - target.h (source / functions) Hit Total Coverage
Test: coverage.dat Lines: 2 2 100.0 %
Date: 2024-01-05 06:35:25 Functions: 2 2 100.0 %

          Line data    Source code
       1             : #pragma once
       2             : 
       3             : #include <memory>
       4             : 
       5             : #include "envoy/common/pure.h"
       6             : #include "envoy/init/watcher.h"
       7             : 
       8             : #include "absl/strings/string_view.h"
       9             : 
      10             : namespace Envoy {
      11             : namespace Init {
      12             : 
      13             : /**
      14             :  * A TargetHandle functions as a weak reference to a Target. It is how an implementation of
      15             :  * Init::Manager would safely tell a target to `initialize` with no guarantees about the
      16             :  * target's lifetime. Typical usage (outside of Init::ManagerImpl) does not require touching
      17             :  * TargetHandles at all.
      18             :  */
      19             : struct TargetHandle {
      20         314 :   virtual ~TargetHandle() = default;
      21             : 
      22             :   /**
      23             :    * Tell the target to begin initialization, if it is still available.
      24             :    * @param watcher A Watcher for the target to notify when it has initialized.
      25             :    * @return true if the target received this call, false if the target was already destroyed.
      26             :    */
      27             :   virtual bool initialize(const Watcher& watcher) const PURE;
      28             : 
      29             :   /**
      30             :    * @return a human-readable target name, for logging / debugging / tracking target names.
      31             :    * The target name has to be unique.
      32             :    */
      33             :   virtual absl::string_view name() const PURE;
      34             : };
      35             : using TargetHandlePtr = std::unique_ptr<TargetHandle>;
      36             : 
      37             : /**
      38             :  * An initialization Target is an entity that can be registered with a Manager for initialization.
      39             :  * It can only be invoked through a TargetHandle.
      40             :  */
      41             : struct Target {
      42         352 :   virtual ~Target() = default;
      43             : 
      44             :   /**
      45             :    * @return a human-readable target name, for logging / debugging.
      46             :    */
      47             :   virtual absl::string_view name() const PURE;
      48             : 
      49             :   /**
      50             :    * Create a new handle that can initialize this target.
      51             :    * @param name a human readable handle name, for logging / debugging.
      52             :    * @return a new handle that can initialize this target.
      53             :    */
      54             :   virtual TargetHandlePtr createHandle(absl::string_view name) const PURE;
      55             : };
      56             : 
      57             : } // namespace Init
      58             : } // namespace Envoy

Generated by: LCOV version 1.15