ConnectionProvider.qm.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
// @file ConnectionProvider.qm Qore user module providing an API for providing connections to %Qore
/* ConnectionProvider.qm Copyright 2016 - 2017 Qore Technologies, s.r.o.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
// this module requires Qore 0.8.13 or better
namespace ConnectionProvider {
public struct ConnectionInfo {
string name;
string desc;
*date last_check;
bool loopback;
bool monitor;
*hash opts;
string status;
string type;
bool up = False;
*date updated;
string url;
hash url_hash;
};
public struct ConfigInfo {
string name;
string desc;
string url;
*hash opts;
};
public struct PingInfo {
string name;
string desc;
*hash opts;
string url;
bool ok;
date time;
string info;
*hash ping_info;
};
string get_connection_url(string str);
AbstractConnection get_connection(string conn);
*hash<string, AbstractConnection> get_connections(*bool verbose);
*hash<string, hash<ConnectionInfo>> get_connection_hash(*bool verbose);
class AbstractConnection {
public:
public :
string name;
string desc;
string url;
string safe_url;
*hash orig_opts;
*hash opts;
hash urlh;
date last_check;
string status = "not checked";
bool up = False;
bool monitor;
date updated;
bool loopback = False;
static *code post_processing;
public:
private :
Mutex m();
public:
constructor(string n_name, string n_desc, string n_url, bool n_monitor, *hash n_opts, hash n_urlh, *string n_safe_url);
private:
static string getSafeUrl(hash urlh);
public:
hash<PingInfo> ping(bool throw_exception = False);
private:
hash<PingInfo> pingIntern(hash<PingInfo> rv);
public:
hash<ConnectionInfo> getInfo(bool with_password = False);
hash<ConfigInfo> getConfigHash();
*hash getOptions();
*hash getRuntimeOptions();
*hash getDefaultOptions();
*hash getRealOptions();
object get(bool connect = True, *hash rtopts);
parseTextOptions();
private:
abstract object getImpl(bool connect = True, *hash rtopts);
public:
abstract string getType();
};
class InvalidConnection : public AbstractConnection {
public:
private :
string error;
public:
constructor(string n_name, string n_desc, string n_url, *hash n_opts, string n_error, hash urlh) ;
object getImpl (bool connect=True, *hash rtopts);
string getType();
};
class HttpBasedConnection : public AbstractConnection {
public:
public :
string real_url;
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
};
class FtpConnection : public AbstractConnection {
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
string getType();
*hash getRuntimeOptions();
private:
FtpClient getImpl(bool connect = True, *hash rtopts);
public:
static FtpConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
class HttpConnection : public AbstractConnection {
public:
public :
const Options = (
"http_version": True,
"max_redirects": True,
"proxy": True,
"timeout": True,
"connect_timeout": True,
"ssl_cert_path": True,
"ssl_key_password": True,
"ssl_key_path": True,
"ssl_verify_cert": True,
);
const DefaultOptions = (
"timeout": 45s,
"connect_timeout": 45s,
);
const OptionList = Options.keys();
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh) ;
private:
Qore::HTTPClient getImpl(bool connect = True, *hash rtopts);
public:
hash getOptions();
*hash getDefaultOptions();
string getType();
static HttpConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
class FilesystemConnection : public AbstractConnection {
public:
public :
const Options = (
"readonly": True,
);
const OptionList = Options.keys();
public:
constructor(string name, string desc, string url, bool monitor, *hash opts, hash n_urlh) ;
string getType();
private:
Dir getImpl(bool connect = True, *hash rtopts);
public:
hash getOptions();
static FilesystemConnection make(string name, string desc, string url, bool monitor, *hash opts, hash urlh);
};
};
// private, non-exported namespace
namespace Priv {
*hash priv_try_get_connections(string mod);
ConnectionProvider::AbstractConnection priv_try_get_connection(string mod, string conn);
};
ConnectionProvider::get_connections
*hash< string, AbstractConnection > get_connections(*bool verbose)
returns all known connections as a hash keyed by connection identifier; values are AbstractConnection...
ConnectionProvider::AbstractConnection::monitor
bool monitor
monitoring flag
Definition: ConnectionProvider.qm.dox.h:246
date
date date(date dt)
ConnectionProvider::ConfigInfo::opts
*hash opts
the options set on the connection
Definition: ConnectionProvider.qm.dox.h:117
ConnectionProvider::HttpBasedConnection
base class for HTTP-based connections that need their URLs rewritten to create the real connection ob...
Definition: ConnectionProvider.qm.dox.h:382
ConnectionProvider::AbstractConnection::last_check
date last_check
date/time of last check/ping
Definition: ConnectionProvider.qm.dox.h:237
ConnectionProvider::ConnectionInfo::last_check
*date last_check
the date/time value of the last connection check (or NOTHING if not checked)
Definition: ConnectionProvider.qm.dox.h:100
ConnectionProvider::FilesystemConnection
class for filesystem connections; returns an object of type Qore::Dir; this can be used to monitor fi...
Definition: ConnectionProvider.qm.dox.h:538
ConnectionProvider::ConnectionInfo::name
string name
the connection name
Definition: ConnectionProvider.qm.dox.h:98
ConnectionProvider::AbstractConnection::opts
*hash opts
connection options
Definition: ConnectionProvider.qm.dox.h:231
ConnectionProvider::HttpConnection
class for HTTP connections; returns Qore::HTTPClient objects
Definition: ConnectionProvider.qm.dox.h:453
ConnectionProvider::ConnectionInfo::status
string status
a string giving the connection&#39;s status
Definition: ConnectionProvider.qm.dox.h:104
ConnectionProvider::PingInfo::info
string info
a string giving the result of the ping ("OK" or an error message)
Definition: ConnectionProvider.qm.dox.h:128
True
const True
ConnectionProvider::AbstractConnection::name
string name
connection name
Definition: ConnectionProvider.qm.dox.h:216
ConnectionProvider::ConfigInfo::url
string url
the full URL (including any username & password)
Definition: ConnectionProvider.qm.dox.h:116
ConnectionProvider::get_connection
AbstractConnection get_connection(string conn)
returns an AbstractConnection object if the identifier is known to a registered connection provider ...
ConnectionProvider::ConnectionInfo::updated
*date updated
the date/time value of the update (or NOTHING if not updated)
Definition: ConnectionProvider.qm.dox.h:107
ConnectionProvider::ConnectionInfo::up
bool up
a boolean vaue indicating the connection is known to be up (will be False if not checked) ...
Definition: ConnectionProvider.qm.dox.h:106
ConnectionProvider::AbstractConnection::urlh
hash urlh
broken down URL hash (as returned by Qore::parse_url())
Definition: ConnectionProvider.qm.dox.h:234
ConnectionProvider::AbstractConnection::post_processing
static *code post_processing
optional code for default post-processing of objects created by getImpl(); must take the object creat...
Definition: ConnectionProvider.qm.dox.h:255
False
const False
ConnectionProvider::AbstractConnection::orig_opts
*hash orig_opts
original connection options
Definition: ConnectionProvider.qm.dox.h:228
ConnectionProvider::AbstractConnection
abstract base class for connections
Definition: ConnectionProvider.qm.dox.h:211
ConnectionProvider::AbstractConnection::safe_url
string safe_url
"safe" URL (password information removed)
Definition: ConnectionProvider.qm.dox.h:225
ConnectionProvider::PingInfo
ping response info as returned by AbstractConnection::ping()
Definition: ConnectionProvider.qm.dox.h:121
ConnectionProvider::ConfigInfo::name
string name
the name of the connection
Definition: ConnectionProvider.qm.dox.h:114
Qore::HTTPClient
ConnectionProvider::ConnectionInfo::type
string type
the connection type
Definition: ConnectionProvider.qm.dox.h:105
ConnectionProvider::PingInfo::url
string url
a safe version of the URL (without passwords)
Definition: ConnectionProvider.qm.dox.h:125
ConnectionProvider::InvalidConnection
this class is used to mark invalid connections so they can be loaded and reported as invalid ...
Definition: ConnectionProvider.qm.dox.h:360
ConnectionProvider::ConnectionInfo::monitor
bool monitor
a boolean vaue indicating if the connection should be monitored or not
Definition: ConnectionProvider.qm.dox.h:102
ConnectionProvider::PingInfo::opts
*hash opts
the options set on the connection
Definition: ConnectionProvider.qm.dox.h:124
ConnectionProvider::ConfigInfo
config informaton as returned by AbstractConnection::getConfigHash()
Definition: ConnectionProvider.qm.dox.h:113
ConnectionProvider::ConnectionInfo::url_hash
hash url_hash
a hash of URL information as returned by parse_url()
Definition: ConnectionProvider.qm.dox.h:109
ConnectionProvider::ConnectionInfo::loopback
bool loopback
a boolean vaue indicating if the connection is a loopback connection
Definition: ConnectionProvider.qm.dox.h:101
ConnectionProvider::ConfigInfo::desc
string desc
the description
Definition: ConnectionProvider.qm.dox.h:115
ConnectionProvider::PingInfo::time
date time
a relative date/time value giving the elapsed time of the ping operation
Definition: ConnectionProvider.qm.dox.h:127
ConnectionProvider::ConnectionInfo::opts
*hash opts
the original options used to create the object
Definition: ConnectionProvider.qm.dox.h:103
ConnectionProvider::ConnectionInfo::url
string url
the URL for the connection including the password (if any present and the with_password argument is T...
Definition: ConnectionProvider.qm.dox.h:108
ConnectionProvider::PingInfo::desc
string desc
the description
Definition: ConnectionProvider.qm.dox.h:123
ConnectionProvider::AbstractConnection::desc
string desc
connection description
Definition: ConnectionProvider.qm.dox.h:219
ConnectionProvider::AbstractConnection::updated
date updated
date/time of last update
Definition: ConnectionProvider.qm.dox.h:249
ConnectionProvider::PingInfo::name
string name
the name of the connection
Definition: ConnectionProvider.qm.dox.h:122
Priv
Definition: ConnectionProvider.qm.dox.h:592
ConnectionProvider::get_connection_url
string get_connection_url(string str)
returns a URL string for the given identifier if the identifier is known to a registered connection p...
ConnectionProvider::ConnectionInfo
connection information hash as returned by AbstractConnection::getInfo()
Definition: ConnectionProvider.qm.dox.h:97
ConnectionProvider::FtpConnection
class for FTP connections; returns Qore::FtpClient objects
Definition: ConnectionProvider.qm.dox.h:399
ConnectionProvider::PingInfo::ok
bool ok
a boolean value giving the result of the ping
Definition: ConnectionProvider.qm.dox.h:126
ConnectionProvider::get_connection_hash
*hash< string, hash< ConnectionInfo > > get_connection_hash(*bool verbose)
returns a hash of connection information keyed by connection identifier; values are ConnectionInfo ha...
ConnectionProvider::PingInfo::ping_info
*hash ping_info
an optional free-form hash giving additional info regarding ping operation or the remote system ...
Definition: ConnectionProvider.qm.dox.h:129
ConnectionProvider::AbstractConnection::url
string url
connection URL (potentially with password info)
Definition: ConnectionProvider.qm.dox.h:222
hash
hash hash(object obj)
ConnectionProvider::ConnectionInfo::desc
string desc
the connection description
Definition: ConnectionProvider.qm.dox.h:99
ConnectionProvider
the ConnectionProvider namespace contains all the objects in the ConnectionProvider module ...
Definition: ConnectionProvider.qm.dox.h:95