16#define ADC_LIBCURL_PLUGIN_PORT_DEFAULT "443"
17#define ADC_LIBCURL_PLUGIN_URL_DEFAULT "https://localhost"
43 const std::vector<string> tags;
51 if (mode != pi_config)
60 const string get(
const std::map< string, string >& m,
63 auto it = m.find(
field);
68 char *ec = getenv(en.c_str());
76 string get_temp_file_name() {
77 string tplt = fdir +
"/json-msg-XXXXXX";
78 char * cstr =
new char [tplt.length()+1];
79 std::strcpy (cstr, tplt.c_str());
80 int fd = mkstemp(cstr);
88 std::cout<<
"mkstemp failed" <<std::endl;
94 int libcurl_send(std::string_view json)
104 libcurl_plugin() : vers(
"0.0.0") , tags({
"unimplemented"}), state(ok), paused(
false), mode(pi_config) {
105 std::cout <<
"Constructing libcurl_plugin" << std::endl;
109 int publish(std::shared_ptr< builder_api > b) {
114 if (mode != pi_pub_or_final)
116 string json = b->serialize();
121 int config(
const std::map< std::string, std::string >& m) {
125 int config(
const std::map< std::string, std::string >& m, std::string_view env_prefix) {
126 string url = get(m,
"URL", env_prefix);
127 string port = get(m,
"PORT", env_prefix);
128 return config(url, port);
136 std::map <string, string >m;
140 if (mode != pi_init) {
143 if ( state == err ) {
144 std::cout <<
"libcurl plugin initialize found pre-existing error" << std::endl;
148 std::filesystem::create_directories(fdir, ec);
149 if (ec.value() != 0 && ec.value() != EEXIST ) {
151 std::cout <<
"unable to create scratch directory for plugin 'libcurl'; "
152 << fdir <<
" : " << ec.message() << std::endl;
155 std::cout <<
"created " << fdir <<std::endl;
156 mode = pi_pub_or_final;
162 if (mode == pi_pub_or_final) {
167 std::cout <<
"libcurl plugin finalize on non-running plugin" << std::endl;
188 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