|
ADCT Python
Python client API implementation for publishing ADCT data
|

Classes | |
| class | Mode |
| For plugins managing external resources (files, pipes), this enum is used to track where in the lifecycle they are. More... | |
| class | State |
| For plugins where the output target becomes unrecoverable, state == ERR means no further output will be attempted. More... | |
Public Member Functions | |
| __init__ (self) | |
| str | name (self) |
| Get the name which a factory or error message should use. | |
| str | version (self) |
| dict[str, str] | get_option_defaults (self) |
| int | config (self, **kwargs) |
| Configure the plugin with the options given. | |
| int | initialize (self) |
| Set up any resources needed for reuse in publish(). | |
| int | publish (self, builder.Builder b) |
| Publish json extracted from builder. | |
| None | finalize (self) |
| Clean up any resources set up in initialize (files, pipes, etc). | |
| None | pause (self) |
| Cause publish calls to be ignored until resume is called. | |
| None | resume (self) |
| Cancel an prior calls to pause. | |
| int | publish_str (self, str json_string) |
| int | publish_obj (self, obj) |
Static Public Member Functions | |
| tuple[float] | get_timeout_defaults () |
| Get the adc server connect and response timeouts defined in the environment ADC_SERVER_CONNECT_TIMEOUT and ADC_SERVER_POST_TIMEOUT as a tuple or default values if not defined. | |
| str | get_url_default () |
| Get the alleged adc server url base from environment ADC_SERVER_URL or the default if it is not present. | |
| str | get_port_default () |
| Get the adc server port number to use if it is properly defined in the environment ADC_SERVER_PORT or the default if it is not. | |
Public Attributes | |
| defaults | |
| plugin_prefix | |
| paused | |
| state | |
| mode | |
Static Public Attributes | |
| API_VERSION = adc_version.AdcVersion()._dict() | |
Protected Member Functions | |
| str | _get (self, dict[str, str] opts, str field) |
| bool | _get_bool (self, dict[str, str] opts, str field) |
Static Protected Attributes | |
| str | _name = "unknown" |
| str | _version = "0.0.0" |
The API for various implementations which publish Builder objects.
Subclasses need to implement __init__, config, initialize, publish, finalize only.
In subclass __init__, data items
self.defaults: dict[str,str]
self.plugin_prefix: str
need to be set for the plugin.
In each subclass, data members
_name: str
_version: str
need to be reassigned.
Particularly simple subclasses may not need to use data items: state, mode.
@ingroup pub_impl
| adctk.publisher.Publisher.__init__ | ( | self | ) |
Reimplemented in adctk.file_publisher.FilePublisher, adctk.http_publisher.HttpPublisher, adctk.ldms_publisher.LDMSPipePublisher, adctk.ldms_publisher.LDMSSystemPublisher, adctk.ldms_publisher.LDMSPipeMessagePublisher, adctk.ldms_publisher.LDMSSystemMessagePublisher, adctk.multifile_publisher.MultiFilePublisher, adctk.none_publisher.NonePublisher, adctk.stdout_publisher.StdoutPublisher, adctk.syslog_publisher.SyslogPublisher, and adctk.debug_file_publisher.DebugFilePublisher.
|
protected |
Check for short option named by field in opts and return if present.
(In most cases the short name is in all capitals.)
When named field is not present, use opts[env_prefix]
(or if opts[env_prefix] is not present, then self.plugin_prefix)
to search for env(prefix+field) and return that value if present.
If no environment value found, return self.defaults[field].
|
protected |
| int adctk.publisher.Publisher.config | ( | self, | |
| ** | kwargs | ||
| ) |
Configure the plugin with the options given.
For plugin QQQ, Environment variables ADC_QQQ_PLUGIN_<key> will override the plugin default for any key not defined in kwargs. Here QQQ is plugin.name().upper(). Generic options:
| kwargs | If env_prefix is included in kwargs, replaces plugin environment variables with those which are prefixed using env_prefix. |
| env_prefix | Typically, env_prefix is set to "PPP_ADC_QQQ_PLUGIN_" if application PPP wants to override the defaults of adctk plugin QQQ. Here QQQ is plugin.name().upper(). If no prefixed version of the variable is present, the plugin default is used. kwargs takes precedence over environment variables. Plugin defaults are used if not overridden by kwargs or an environment variable. |
Reimplemented in adctk.debug_file_publisher.DebugFilePublisher, adctk.file_publisher.FilePublisher, adctk.http_publisher.HttpPublisher, adctk.ldms_publisher.LDMSPipePublisher, adctk.ldms_publisher.LDMSSystemPublisher, adctk.ldms_publisher.LDMSPipeMessagePublisher, adctk.ldms_publisher.LDMSSystemMessagePublisher, adctk.multifile_publisher.MultiFilePublisher, adctk.none_publisher.NonePublisher, adctk.stdout_publisher.StdoutPublisher, and adctk.syslog_publisher.SyslogPublisher.
| None adctk.publisher.Publisher.finalize | ( | self | ) |
Clean up any resources set up in initialize (files, pipes, etc).
Reimplemented in adctk.debug_file_publisher.DebugFilePublisher, adctk.file_publisher.FilePublisher, adctk.http_publisher.HttpPublisher, adctk.ldms_publisher.LDMSPipePublisher, adctk.ldms_publisher.LDMSPipeMessagePublisher, adctk.multifile_publisher.MultiFilePublisher, adctk.none_publisher.NonePublisher, adctk.stdout_publisher.StdoutPublisher, and adctk.syslog_publisher.SyslogPublisher.
| dict[str,str] adctk.publisher.Publisher.get_option_defaults | ( | self | ) |
|
static |
Get the adc server port number to use if it is properly defined in the environment ADC_SERVER_PORT or the default if it is not.
|
static |
Get the adc server connect and response timeouts defined in the environment ADC_SERVER_CONNECT_TIMEOUT and ADC_SERVER_POST_TIMEOUT as a tuple or default values if not defined.
|
static |
Get the alleged adc server url base from environment ADC_SERVER_URL or the default if it is not present.
| int adctk.publisher.Publisher.initialize | ( | self | ) |
Set up any resources needed for reuse in publish().
Reimplemented in adctk.debug_file_publisher.DebugFilePublisher, adctk.file_publisher.FilePublisher, adctk.http_publisher.HttpPublisher, adctk.ldms_publisher.LDMSPipePublisher, adctk.ldms_publisher.LDMSPipeMessagePublisher, adctk.multifile_publisher.MultiFilePublisher, adctk.none_publisher.NonePublisher, adctk.stdout_publisher.StdoutPublisher, and adctk.syslog_publisher.SyslogPublisher.
| str adctk.publisher.Publisher.name | ( | self | ) |
Get the name which a factory or error message should use.
| None adctk.publisher.Publisher.pause | ( | self | ) |
Cause publish calls to be ignored until resume is called.
| int adctk.publisher.Publisher.publish | ( | self, | |
| builder.Builder | b | ||
| ) |
Publish json extracted from builder.
Reimplemented in adctk.http_publisher.HttpPublisher, adctk.debug_file_publisher.DebugFilePublisher, adctk.file_publisher.FilePublisher, adctk.ldms_publisher.LDMSPipePublisher, adctk.ldms_publisher.LDMSPipeMessagePublisher, adctk.multifile_publisher.MultiFilePublisher, adctk.none_publisher.NonePublisher, adctk.stdout_publisher.StdoutPublisher, and adctk.syslog_publisher.SyslogPublisher.
| int adctk.publisher.Publisher.publish_obj | ( | self, | |
| obj | |||
| ) |
Deprecated function. Call publish_str with the result of json.dumps(obj), if possible. Returns EINVAL when dumps fails. Use of this method is discouraged
Reimplemented in adctk.debug_file_publisher.DebugFilePublisher, and adctk.http_publisher.HttpPublisher.
| int adctk.publisher.Publisher.publish_str | ( | self, | |
| str | json_string | ||
| ) |
Deprecated function; prefer publish() Publish json string supplied by user, by creating a Builder and defining the application block to contain the string given as a single field. Use of this method is discouraged, as it hides important datatype information from downstream consumers and it must generate an application name.
Reimplemented in adctk.debug_file_publisher.DebugFilePublisher, and adctk.http_publisher.HttpPublisher.
| None adctk.publisher.Publisher.resume | ( | self | ) |
Cancel an prior calls to pause.
| str adctk.publisher.Publisher.version | ( | self | ) |
|
staticprotected |
|
staticprotected |
|
static |
| adctk.publisher.Publisher.defaults |
| adctk.publisher.Publisher.mode |
| adctk.publisher.Publisher.paused |
| adctk.publisher.Publisher.plugin_prefix |
| adctk.publisher.Publisher.state |