libadc-cxx 1.0.0
Structured logging for scientific computing
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
adc::script_plugin Class Reference

User script publisher plugin. The program specified by environment variable is used to asynchronously deliver published messages. It is invoked in a shell as: ($prog $messagefile > /dev/null 2>&1 || /bin/rm $messagefile) &. More...

Inheritance diagram for adc::script_plugin:
Inheritance graph
[legend]
Collaboration diagram for adc::script_plugin:
Collaboration graph
[legend]

Public Member Functions

 script_plugin ()
 
int publish (std::shared_ptr< builder_api > b)
 Publish the content of the builder.
 
int config (const std::map< std::string, std::string > &m)
 Configure the plugin with the options given.
 
int config (const std::map< std::string, std::string > &m, std::string_view env_prefix)
 Configure the plugin with the options given and the corresponding environment variables.
 
const std::map< const std::string, const std::string > & get_option_defaults ()
 Look up the settable options and their defaults.
 
int initialize ()
 Ready the plugin to publish following the configuration options set or defaulted.
 
void finalize ()
 Stop publishing and release any resources held for managing publication.
 
void pause ()
 Pause publishing until a call to resume. Duplicate calls are allowed.
 
void resume ()
 Resume publishing Duplicate calls are allowed.
 
string_view name () const
 
string_view version () const
 
 ~script_plugin ()
 

Static Public Attributes

static const char * adc_script_plugin_dir_default = "/dev/shm/adc"
 The default scratch directory for user script messages. This directory must be globally writable and should be fast. Overridden with env("ADC_SCRIPT_PLUGIN_DIRECTORY").
 
static const char * adc_script_plugin_prog_default = ":"
 The default path to a user script or program. This program should be user accessible. Overridden with env("ADC_SCRIPT_PLUGIN_PROG"). The default : is a non-operation.
 
static const char * adc_script_plugin_debug_default = "0"
 ADC script plugin enable debug messages; (default "0": none) "2" provides message send debugging "1" provides lighter debugging Overridden with env("ADC_SCRIPT_PLUGIN_DEBUG").
 

Detailed Description

User script publisher plugin. The program specified by environment variable is used to asynchronously deliver published messages. It is invoked in a shell as: ($prog $messagefile > /dev/null 2>&1 || /bin/rm $messagefile) &.

Definition at line 22 of file script.ipp.

Constructor & Destructor Documentation

◆ script_plugin()

adc::script_plugin::script_plugin ( )
inline

Definition at line 135 of file script.ipp.

◆ ~script_plugin()

adc::script_plugin::~script_plugin ( )
inline

Definition at line 243 of file script.ipp.

Member Function Documentation

◆ publish()

int adc::script_plugin::publish ( std::shared_ptr< builder_api b)
inlinevirtual

Publish the content of the builder.

Parameters
bconverted to a single json object and published

Implements adc::publisher_api.

Definition at line 137 of file script.ipp.

◆ config() [1/2]

int adc::script_plugin::config ( const std::map< std::string, std::string > &  m)
inlinevirtual

Configure the plugin with the options given.

Parameters
ma map with keys documented in the plugin-specific header.

For plugin QQQ, Environment variables ADC_QQQ_PLUGIN_* will override the source code default for any key not defined in m. Here QQQ is the uppercase version of the plugin name.

Implements adc::publisher_api.

Definition at line 172 of file script.ipp.

◆ config() [2/2]

int adc::script_plugin::config ( const std::map< std::string, std::string > &  m,
std::string_view  env_prefix 
)
inlinevirtual

Configure the plugin with the options given and the corresponding environment variables.

Parameters
ma map with keys documented in the plugin-specific header.
env_prefixis prepended to the expected keys for the plugin and values found with getenv that match are used, overriding elements of m. Typically, env_prefix will be PPP_ADC_QQQ_PLUGIN_ if application PPP wants to override the defaults of plugin QQQ. Here QQQ is the uppercase version of the plugin name.

Implements adc::publisher_api.

Definition at line 176 of file script.ipp.

◆ get_option_defaults()

const std::map< const std::string, const std::string > & adc::script_plugin::get_option_defaults ( )
inlinevirtual

Look up the settable options and their defaults.

Some plugins without options will return an empty map.

Implements adc::publisher_api.

Definition at line 183 of file script.ipp.

◆ initialize()

int adc::script_plugin::initialize ( )
inlinevirtual

Ready the plugin to publish following the configuration options set or defaulted.

Implements adc::publisher_api.

Definition at line 187 of file script.ipp.

◆ finalize()

void adc::script_plugin::finalize ( )
inlinevirtual

Stop publishing and release any resources held for managing publication.

Implements adc::publisher_api.

Definition at line 215 of file script.ipp.

◆ pause()

void adc::script_plugin::pause ( )
inlinevirtual

Pause publishing until a call to resume. Duplicate calls are allowed.

Implements adc::publisher_api.

Definition at line 227 of file script.ipp.

◆ resume()

void adc::script_plugin::resume ( )
inlinevirtual

Resume publishing Duplicate calls are allowed.

Implements adc::publisher_api.

Definition at line 231 of file script.ipp.

◆ name()

string_view adc::script_plugin::name ( ) const
inlinevirtual
Returns
the name of the plugin

Implements adc::publisher_api.

Definition at line 235 of file script.ipp.

◆ version()

string_view adc::script_plugin::version ( ) const
inlinevirtual
Returns
the version of the plugin (should follow semantic versioning practices)

Implements adc::publisher_api.

Definition at line 239 of file script.ipp.

Member Data Documentation

◆ adc_script_plugin_dir_default

const char* adc::script_plugin::adc_script_plugin_dir_default = "/dev/shm/adc"
inlinestatic

The default scratch directory for user script messages. This directory must be globally writable and should be fast. Overridden with env("ADC_SCRIPT_PLUGIN_DIRECTORY").

Definition at line 38 of file script.ipp.

◆ adc_script_plugin_prog_default

const char* adc::script_plugin::adc_script_plugin_prog_default = ":"
inlinestatic

The default path to a user script or program. This program should be user accessible. Overridden with env("ADC_SCRIPT_PLUGIN_PROG"). The default : is a non-operation.

Definition at line 44 of file script.ipp.

◆ adc_script_plugin_debug_default

const char* adc::script_plugin::adc_script_plugin_debug_default = "0"
inlinestatic

ADC script plugin enable debug messages; (default "0": none) "2" provides message send debugging "1" provides lighter debugging Overridden with env("ADC_SCRIPT_PLUGIN_DEBUG").

Definition at line 50 of file script.ipp.


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