Qore ConnectionProvider Module Reference  1.2.1
AbstractConnection.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
2 // Qore AbstractConnection class definition
3 
4 /* AbstractConnection.qc Copyright 2016 - 2019 Qore Technologies, s.r.o.
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23 */
24 
25 
27 namespace ConnectionProvider {
29 
32 
33 public:
35  string name;
36 
38  string desc;
39 
41  string url;
42 
44  string safe_url;
45 
48 
51 
54 
57 
59  string status = "not checked";
60 
62  bool up = False;
63 
65  bool monitor;
66 
69 
71  bool loopback = False;
72 
74  static *code post_processing;
75 
77  bool enabled = True;
78 
80  bool locked = False;
81 
83  hash<auto> tags = {};
84 
86 
95  deprecated
96 constructor(string n_name, string n_desc, string n_url, bool n_monitor, *hash n_opts, hash n_urlh, *string n_safe_url, *bool n_enabled);
97 
98 
100 
116  constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {});
117 
118 
119 private:
120  constructorInit(string name, string description, string url, hash<auto> attributes, hash<auto> options);
121 public:
122 
123 
125 
131  hash<auto> validateOptions(hash<auto> options);
132 
133 
135 
143 protected:
144  hash<UrlInfo> parseUrl(string url);
145 public:
146 
147 
149 
162 protected:
163  string getSafeUrl(hash<auto> urlh);
164 public:
165 
166 
168 
172  hash<PingInfo> ping(bool throw_exception = False);
173 
174 
176 protected:
177  hash<PingInfo> pingIntern(hash<PingInfo> rv);
178 public:
179 
180 
182 
186  hash<ConnectionInfo> getInfo(bool with_password = False);
187 
188 
190 
192  hash<ConfigInfo> getConfigHash();
193 
194 
196  *hash getOptions();
197 
198 
201 
202 
205 
206 
208  *hash getRealOptions();
209 
210 
212 
214  object get(bool connect = True, *hash rtopts);
215 
216 
218 
222  hash<ConnectionConstructorInfo> getConstructorInfo();
223 
224 
226 
229 
230 
232  hash<auto> getTags();
233 
234 
236  auto getTag(string tag);
237 
238 
240 
242  auto getTagEx(string tag);
243 
244 
246 
251 protected:
252  abstract object getImpl(bool connect = True, *hash rtopts);
253 public:
254 
256 
260 protected:
261  abstract hash<ConnectionConstructorInfo> getConstructorInfoImpl();
262 public:
263 
265  abstract string getType();
266  };
267 }; // ConnectionProvider namespace
parseTextOptions()
this method is called when parsing connection file definitions from text files when loading into the ...
auto getTag(string tag)
returns the value of the given tag or NOTHING if not present
*hash getRuntimeOptions()
returns runtime options
bool monitor
monitoring flag
Definition: AbstractConnection.qc.dox.h:65
date date(date dt)
date last_check
date/time of last check/ping
Definition: AbstractConnection.qc.dox.h:56
bool locked
locked/unlocked flag
Definition: AbstractConnection.qc.dox.h:80
hash< ConnectionInfo > getInfo(bool with_password=False)
returns a ConnectionInfo hash of information about the connection
string getSafeUrl(hash< auto > urlh)
creates a "safe" URL string with password information removed
abstract hash< ConnectionConstructorInfo > getConstructorInfoImpl()
this method must return a ConnectionConstructorInfo hash for creating the connection object dynamical...
abstract object getImpl(bool connect=True, *hash rtopts)
this method must return the connection object corresponding to the object's configuration
*hash opts
connection options
Definition: AbstractConnection.qc.dox.h:50
hash< ConnectionConstructorInfo > getConstructorInfo()
returns a ConnectionConstructorInfo hash for creating the connection object dynamically
const True
deprecated constructor(string n_name, string n_desc, string n_url, bool n_monitor, *hash n_opts, hash n_urlh, *string n_safe_url, *bool n_enabled)
creates the AbstractConnection object
string name
connection name
Definition: AbstractConnection.qc.dox.h:35
*hash getDefaultOptions()
returns default options
hash urlh
broken down URL hash (as returned by Qore::parse_url())
Definition: AbstractConnection.qc.dox.h:53
static *code post_processing
optional code for default post-processing of objects created by getImpl(); must take the object creat...
Definition: AbstractConnection.qc.dox.h:74
hash< PingInfo > ping(bool throw_exception=False)
returns a hash with the results of the ping operation
const False
string status
status string; in case of a connection error this string will be the error string
Definition: AbstractConnection.qc.dox.h:59
*hash orig_opts
original connection options
Definition: AbstractConnection.qc.dox.h:47
hash< auto > tags
connection tags; user-defined key-value pairs
Definition: AbstractConnection.qc.dox.h:83
abstract base class for connections
Definition: AbstractConnection.qc.dox.h:31
*hash getOptions()
returns static / initialization options
string safe_url
"safe" URL (password information removed)
Definition: AbstractConnection.qc.dox.h:44
bool enabled
enabled/disabled indicator flag
Definition: AbstractConnection.qc.dox.h:77
auto getTagEx(string tag)
returns the value of the given tag or throws an exception if the tag is not set with a value
abstract string getType()
returns the string type name for the connection object
object get(bool connect=True, *hash rtopts)
returns the underlying connection object
*hash getRealOptions()
returns options for saving the connection's configuration information
hash< ConfigInfo > getConfigHash()
returns a ConfigInfo hash of static configuration information about the connection
hash< auto > getTags()
returns all tags associated with the connection
string desc
connection description
Definition: AbstractConnection.qc.dox.h:38
hash< auto > hash(object obj)
date updated
date/time of last update
Definition: AbstractConnection.qc.dox.h:68
hash< auto > validateOptions(hash< auto > options)
performs options validation in the constructor
hash< UrlInfo > parseUrl(string url)
Parse the URL to a hash.
bool up
connection status flag; set by monitoring or explicit pings/connections
Definition: AbstractConnection.qc.dox.h:62
string url
connection URL (potentially with password info)
Definition: AbstractConnection.qc.dox.h:41
hash< PingInfo > pingIntern(hash< PingInfo > rv)
performs the ping by executing get(); returns a PingInfo hash
bool loopback
set to True for loopback connections
Definition: AbstractConnection.qc.dox.h:71
the ConnectionProvider namespace. All classes used in the ConnectionProvider module should be inside ...
Definition: AbstractConnection.qc.dox.h:27