20#define ADC_LIBCURL_PLUGIN_PORT_DEFAULT "443"
21#define ADC_LIBCURL_PLUGIN_URL_DEFAULT "https://localhost"
47 const std::vector<string> tags;
55 if (mode != pi_config)
64 const string get(
const std::map< string, string >& m,
67 auto it = m.find(
field);
72 char *ec = getenv(en.c_str());
80 string get_temp_file_name() {
81 string tplt = fdir +
"/json-msg-XXXXXX";
82 char * cstr =
new char [tplt.length()+1];
83 std::strcpy (cstr, tplt.c_str());
84 int fd = mkstemp(cstr);
92 std::cout<<
"mkstemp failed" <<std::endl;
98 int libcurl_send(std::string_view json)
108 libcurl_plugin() : vers(
"0.0.0") , tags({
"unimplemented"}), state(ok), paused(
false), mode(pi_config) {
109 std::cout <<
"Constructing libcurl_plugin" << std::endl;
113 int publish(std::shared_ptr< builder_api > b) {
118 if (mode != pi_pub_or_final)
120 string json = b->serialize();
125 int config(
const std::map< std::string, std::string >& m) {
129 int config(
const std::map< std::string, std::string >& m, std::string_view env_prefix) {
130 string url = get(m,
"URL", env_prefix);
131 string port = get(m,
"PORT", env_prefix);
132 return config(url, port);
140 std::map <string, string >m;
144 if (mode != pi_init) {
147 if ( state == err ) {
148 std::cout <<
"libcurl plugin initialize found pre-existing error" << std::endl;
152 std::filesystem::create_directories(fdir, ec);
153 if (ec.value() != 0 && ec.value() != EEXIST ) {
155 std::cout <<
"unable to create scratch directory for plugin 'libcurl'; "
156 << fdir <<
" : " << ec.message() << std::endl;
159 std::cout <<
"created " << fdir <<std::endl;
160 mode = pi_pub_or_final;
166 if (mode == pi_pub_or_final) {
171 std::cout <<
"libcurl plugin finalize on non-running plugin" << std::endl;
192 std::cout <<
"Destructing libcurl_plugin" << std::endl;
NOT yet implemented publisher plugin that will eventually use libcurl.
int config(const std::map< std::string, std::string > &m)
Configure the plugin with the options given.
const std::map< const std::string, const std::string > & get_option_defaults()
Look up the settable options and their defaults.
int publish(std::shared_ptr< builder_api > b)
NOT IMPLEMENTED .libcurl_plugin::libcurl_send pending.
void pause()
Pause publishing until a call to resume. Duplicate calls are allowed.
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 resume()
Resume publishing Duplicate calls are allowed.
string_view version() const
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.
Publisher plugin interface.
#define ADC_LIBCURL_PLUGIN_PORT_DEFAULT
#define ADC_LIBCURL_PLUGIN_URL_DEFAULT
std::string_view string_view
const string plugin_libcurl_prefix("ADC_LIBCURL_PLUGIN_")
const std::map< string, string > plugin_libcurl_config_defaults