VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::StatusService Class Reference

Build text and JSON diagnostics from named providers. More...

#include <StatusService.hpp>

Public Types

using Provider = std::function< std::string()>
 Returns this section's payload as JSON text (an object or scalar).
 
using HealthCheck = std::function< bool()>
 Optional plugin-specific health predicate.
 

Public Member Functions

void RegisterSection (std::string name, Provider provider)
 Add a section, replacing any existing one with the same name.
 
bool IsHealthy () const
 The registered health result, or true when no predicate is registered.
 
std::string BuildJson () const
 One JSON object with a key per section, plus a top-level healthy flag.
 
std::string BuildText () const
 Human-readable multi-line rendering of the same sections.
 
void InstallCommand (std::string_view name, std::string_view helpText, HealthCheck healthy={})
 Install the server command that reports this status.
 

Detailed Description

Build text and JSON diagnostics from named providers.

Providers run on demand in registration order. VoltMod registers framework sections during load; plugins add their sections in Load and expose the combined report with InstallCommand. A provider returns compact JSON text, normally built with VoltMod::Json::Write from <VoltMod/Core/Text/Json.hpp>.

Definition at line 22 of file StatusService.hpp.

Member Typedef Documentation

◆ HealthCheck

Optional plugin-specific health predicate.

Definition at line 29 of file StatusService.hpp.

◆ Provider

using VoltMod::StatusService::Provider = std::function<std::string()>

Returns this section's payload as JSON text (an object or scalar).

Definition at line 26 of file StatusService.hpp.

Member Function Documentation

◆ BuildJson()

std::string VoltMod::StatusService::BuildJson ( ) const

One JSON object with a key per section, plus a top-level healthy flag.

Definition at line 31 of file StatusService.cpp.

References IsHealthy(), VoltMod::ReadFile(), and VoltMod::Json::Write().

◆ BuildText()

std::string VoltMod::StatusService::BuildText ( ) const

Human-readable multi-line rendering of the same sections.

Definition at line 45 of file StatusService.cpp.

References VoltMod::Json::ParseDocument(), and VoltMod::ReadFile().

Referenced by InstallCommand().

◆ InstallCommand()

void VoltMod::StatusService::InstallCommand ( std::string_view  name,
std::string_view  helpText,
HealthCheck  healthy = {} 
)

Install the server command that reports this status.

<name> prints BuildText. <name> json emits BuildJson as one STATUS_JSON {...} line for RCON tooling. The command unregisters when this service is destroyed.

Definition at line 77 of file StatusService.cpp.

References BuildText(), IsHealthy(), and VoltMod::ReadFile().

◆ IsHealthy()

bool VoltMod::StatusService::IsHealthy ( ) const

The registered health result, or true when no predicate is registered.

Definition at line 26 of file StatusService.cpp.

Referenced by BuildJson(), and InstallCommand().

◆ RegisterSection()

void VoltMod::StatusService::RegisterSection ( std::string  name,
Provider  provider 
)

Add a section, replacing any existing one with the same name.

Definition at line 13 of file StatusService.cpp.

References VoltMod::ReadFile().


The documentation for this class was generated from the following files: