$darkmode

| Qore ConnectionProvider Module Reference 1.7.4

AbstractConnection.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
2// Qore AbstractConnection class definition
3
4/* AbstractConnection.qc Copyright 2016 - 2023 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
26
28 namespace ConnectionProvider {
30
34 class AbstractConnection : public Qore::Serializable {
35
36 public:
38 string name;
39
41 string desc;
42
44 string url;
45
47 string safe_url;
48
50 *hash<auto> orig_opts;
51
53 *hash<auto> opts;
54
56 hash<auto> urlh;
57
59 date last_check;
60
62 string status = "not checked";
63
65 bool up = False;
66
68 bool monitor;
69
71 date updated;
72
74 bool loopback = False;
75
77 static *code post_processing;
78
80 bool enabled = True;
81
83 bool locked = False;
84
86 bool debug_data = False;
87
89 hash<auto> tags = {};
90
92 bool children_can_support_apis = False;
93
95 bool children_can_support_records = False;
96
98 bool children_can_support_observers = False;
99
101 bool children_can_support_messages = False;
102
104 hash<auto> internal_info;
105
107
116 deprecated
117 constructor(string name,
118 string desc,
119 string url,
120 bool monitor,
121 *hash opts,
122 hash urlh,
123 *string safe_url,
124 *bool enabled) {
125 // remove "enabled" option from option hash, if any
126 *bool opt_enabled = remove opts.enabled;
127 hash<auto> attributes = {
128 "monitor": monitor,
129 "enabled": enabled ?? opt_enabled ?? True,
130 };
131 constructorInit(name, desc, url, attributes, opts ?? {});
132 }
133
135
152 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {});
153
154
156
160 string getName();
161
162
164
168 string getDescription();
169
170
172
176 string getUrl();
177
178
180
184 string getSafeUrl();
185
186
188
192 hash<PingInfo> ping(bool throw_exception = False);
193
194
196 protected:
197 hash<PingInfo> pingIntern(hash<PingInfo> rv);
198 public:
199
200
202
208 hash<ConnectionInfo> getInfo(bool with_password = False);
209
210
212
217 hash<ConnectionInfo> getInfo(*hash<auto> opts);
218
219
221
225 hash<auto> getExtendedInfo(*hash<auto> opts);
226
227
229
231 hash<ConfigInfo> getConfigHash();
232
233
235 hash<ConnectionSchemeInfo> getConnectionSchemeInfo();
236
237
239 *hash<auto> getOptions();
240
241
243 *hash<auto> getRuntimeOptions();
244
245
247 *hash<auto> getDefaultOptions();
248
249
251 *hash<auto> getRealOptions();
252
253
255
257 object get(bool connect = True, *hash<auto> rtopts);
258
259
261
263 parseTextOptions();
264
265
267 hash<auto> getTags();
268
269
271 auto getTag(string tag);
272
273
275
277 auto getTagEx(string tag);
278
279
281
292 AbstractDataProvider getDataProvider();
293
294
296
305 bool hasDataProvider();
306
307
309
320 bool supportsPollingApi();
321
322
324
332 Qore::AbstractPollOperation startPollConnect();
333
334
336
340 object getPollImpl();
341
342
344 handlePingSuccess(date delta);
345
346
348 handlePingFailed(date delta, hash<ExceptionInfo> ex);
349
350
352 handlePingFailed(date delta, string err);
353
354
356
358 protected:
359 pingImpl();
360 public:
361
362
364
372 protected:
373 hash<UrlInfo> parseUrl(string url);
374 public:
375
376
378
391 protected:
392 string getSafeUrl(hash<auto> urlh);
393 public:
394
395
397
404 protected:
405 hash<auto> validateOptions(hash<auto> options);
406 public:
407
408
410
413 private:
414 constructorInit(string name, string description, string url, hash<auto> attributes, hash<auto> options);
415 public:
416
417
419 protected:
420 setChildCapabilities();
421 public:
422
423
425 abstract string getType();
426
428
434 protected:
435 abstract object getImpl(bool connect = True, *hash<auto> rtopts);
436 public:
437};
438}; // ConnectionProvider namespace
ConnectionProvider::AbstractConnection
abstract base class for connections
Definition: AbstractConnection.qc.dox.h:34
ConnectionProvider::AbstractConnection::desc
string desc
connection description
Definition: AbstractConnection.qc.dox.h:41
ConnectionProvider::AbstractConnection::locked
bool locked
locked/unlocked flag
Definition: AbstractConnection.qc.dox.h:83
ConnectionProvider::AbstractConnection::getName
string getName()
Returns the connection name.
ConnectionProvider::AbstractConnection::pingImpl
pingImpl()
performs the internal ping
ConnectionProvider::AbstractConnection::getInfo
hash< ConnectionInfo > getInfo(*hash< auto > opts)
returns a ConnectionInfo hash of information about the connection
ConnectionProvider::AbstractConnection::getInfo
hash< ConnectionInfo > getInfo(bool with_password=False)
returns a ConnectionInfo hash of information about the connection
ConnectionProvider::AbstractConnection::hasDataProvider
bool hasDataProvider()
returns True if the connection returns a data provider with the getDataProvider() method
ConnectionProvider::AbstractConnection::opts
*hash< auto > opts
connection options
Definition: AbstractConnection.qc.dox.h:53
ConnectionProvider::AbstractConnection::getPollImpl
object getPollImpl()
Returns an unconnected object for a non-blocking poll operation.
ConnectionProvider::AbstractConnection::get
object get(bool connect=True, *hash< auto > rtopts)
returns the underlying connection object
ConnectionProvider::AbstractConnection::getTagEx
auto getTagEx(string tag)
returns the value of the given tag or throws an exception if the tag is not set with a value
ConnectionProvider::AbstractConnection::internal_info
hash< auto > internal_info
internal tags
Definition: AbstractConnection.qc.dox.h:104
ConnectionProvider::AbstractConnection::orig_opts
*hash< auto > orig_opts
original connection options
Definition: AbstractConnection.qc.dox.h:50
ConnectionProvider::AbstractConnection::getRuntimeOptions
*hash< auto > getRuntimeOptions()
returns runtime options
ConnectionProvider::AbstractConnection::url
string url
connection URL (potentially with password info)
Definition: AbstractConnection.qc.dox.h:44
ConnectionProvider::AbstractConnection::children_can_support_messages
bool children_can_support_messages
if the data provider or any of its children support messages
Definition: AbstractConnection.qc.dox.h:101
ConnectionProvider::AbstractConnection::getExtendedInfo
hash< auto > getExtendedInfo(*hash< auto > opts)
Returns connection info plus any extended information returned by the connection.
ConnectionProvider::AbstractConnection::monitor
bool monitor
monitoring flag
Definition: AbstractConnection.qc.dox.h:68
ConnectionProvider::AbstractConnection::safe_url
string safe_url
"safe" URL (password information removed)
Definition: AbstractConnection.qc.dox.h:47
ConnectionProvider::AbstractConnection::setChildCapabilities
setChildCapabilities()
Override to set child data provider capabilities once per child class.
ConnectionProvider::AbstractConnection::startPollConnect
Qore::AbstractPollOperation startPollConnect()
Called to start the connection polling operation.
ConnectionProvider::AbstractConnection::tags
hash< auto > tags
connection tags; user-defined key-value pairs
Definition: AbstractConnection.qc.dox.h:89
ConnectionProvider::AbstractConnection::getSafeUrl
string getSafeUrl(hash< auto > urlh)
creates a "safe" URL string with password information removed
ConnectionProvider::AbstractConnection::enabled
bool enabled
enabled/disabled indicator flag
Definition: AbstractConnection.qc.dox.h:80
ConnectionProvider::AbstractConnection::getDataProvider
AbstractDataProvider getDataProvider()
returns a data provider object for this connection, if supported
ConnectionProvider::AbstractConnection::last_check
date last_check
date/time of last check/ping
Definition: AbstractConnection.qc.dox.h:59
ConnectionProvider::AbstractConnection::up
bool up
connection status flag; set by monitoring or explicit pings/connections
Definition: AbstractConnection.qc.dox.h:65
ConnectionProvider::AbstractConnection::validateOptions
hash< auto > validateOptions(hash< auto > options)
performs options validation in the constructor
ConnectionProvider::AbstractConnection::getDescription
string getDescription()
Returns the connection description.
ConnectionProvider::AbstractConnection::getConnectionSchemeInfo
hash< ConnectionSchemeInfo > getConnectionSchemeInfo()
Returns a default ConnectionSchemeInfo hash.
ConnectionProvider::AbstractConnection::pingIntern
hash< PingInfo > pingIntern(hash< PingInfo > rv)
performs the ping by executing get(); returns a PingInfo hash
ConnectionProvider::AbstractConnection::supportsPollingApi
bool supportsPollingApi()
returns True if the connection supports the Qore Socket-based polling API
ConnectionProvider::AbstractConnection::debug_data
bool debug_data
debug data flag; to be used an an indication for a higher-level implementation
Definition: AbstractConnection.qc.dox.h:86
ConnectionProvider::AbstractConnection::constructorInit
constructorInit(string name, string description, string url, hash< auto > attributes, hash< auto > options)
Common construtor implementation.
ConnectionProvider::AbstractConnection::name
string name
connection name
Definition: AbstractConnection.qc.dox.h:38
ConnectionProvider::AbstractConnection::parseUrl
hash< UrlInfo > parseUrl(string url)
Parse the URL to a hash.
ConnectionProvider::AbstractConnection::getConfigHash
hash< ConfigInfo > getConfigHash()
returns a ConfigInfo hash of static configuration information about the connection
ConnectionProvider::AbstractConnection::getOptions
*hash< auto > getOptions()
returns static / initialization options
ConnectionProvider::AbstractConnection::getTags
hash< auto > getTags()
returns all tags associated with the connection
ConnectionProvider::AbstractConnection::getImpl
abstract object getImpl(bool connect=True, *hash< auto > rtopts)
this method must return the connection object corresponding to the object's configuration
ConnectionProvider::AbstractConnection::constructor
deprecated constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh, *string safe_url, *bool enabled)
creates the AbstractConnection object
Definition: AbstractConnection.qc.dox.h:117
ConnectionProvider::AbstractConnection::handlePingFailed
handlePingFailed(date delta, hash< ExceptionInfo > ex)
Handles a failed ping operation on the connection.
ConnectionProvider::AbstractConnection::getSafeUrl
string getSafeUrl()
Returns the connection safe URL (without password info)
ConnectionProvider::AbstractConnection::getUrl
string getUrl()
Returns the connection URL.
ConnectionProvider::AbstractConnection::getDefaultOptions
*hash< auto > getDefaultOptions()
returns default options
ConnectionProvider::AbstractConnection::constructor
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the AbstractConnection object
ConnectionProvider::AbstractConnection::getTag
auto getTag(string tag)
returns the value of the given tag or NOTHING if not present
ConnectionProvider::AbstractConnection::status
string status
status string; in case of a connection error this string will be the error string
Definition: AbstractConnection.qc.dox.h:62
ConnectionProvider::AbstractConnection::parseTextOptions
parseTextOptions()
this method is called when parsing connection file definitions from text files when loading into the ...
ConnectionProvider::AbstractConnection::updated
date updated
date/time of last update
Definition: AbstractConnection.qc.dox.h:71
ConnectionProvider::AbstractConnection::children_can_support_apis
bool children_can_support_apis
if the data provider or any of its children support requests (APIs)
Definition: AbstractConnection.qc.dox.h:92
ConnectionProvider::AbstractConnection::post_processing
static *code post_processing
optional code for default post-processing of objects created by getImpl(); must take the connection o...
Definition: AbstractConnection.qc.dox.h:77
ConnectionProvider::AbstractConnection::loopback
bool loopback
set to True for loopback connections
Definition: AbstractConnection.qc.dox.h:74
ConnectionProvider::AbstractConnection::children_can_support_observers
bool children_can_support_observers
if the data provider or any of its children support events
Definition: AbstractConnection.qc.dox.h:98
ConnectionProvider::AbstractConnection::children_can_support_records
bool children_can_support_records
if the data provider or any of its children support records
Definition: AbstractConnection.qc.dox.h:95
ConnectionProvider::AbstractConnection::getType
abstract string getType()
returns the string type name for the connection object
ConnectionProvider::AbstractConnection::handlePingFailed
handlePingFailed(date delta, string err)
Handles a failed ping operation on the connection.
ConnectionProvider::AbstractConnection::urlh
hash< auto > urlh
broken down URL hash (as returned by Qore::parse_url())
Definition: AbstractConnection.qc.dox.h:56
ConnectionProvider::AbstractConnection::ping
hash< PingInfo > ping(bool throw_exception=False)
returns a hash with the results of the ping operation
ConnectionProvider::AbstractConnection::getRealOptions
*hash< auto > getRealOptions()
returns options for saving the connection's configuration information
ConnectionProvider::AbstractConnection::handlePingSuccess
handlePingSuccess(date delta)
Handles a successful ping operation on the connection.
Qore::AbstractPollOperation
Qore::Serializable
True
const True
False
const False
date
date date(date dt)
hash
hash< auto > hash(object obj)
ConnectionProvider
The ConnectionProvider namespace.
Definition: AbstractConnection.qc.dox.h:28