Qore ConnectionProvider Module Reference 1.9.2
Loading...
Searching...
No Matches
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
30
35
36public:
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
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
79 static *code post_processing;
80
82 bool enabled = True;
83
85 bool locked = False;
86
88 bool debug_data = False;
89
91 hash<auto> tags = {};
92
95
98
101
104
107
109 hash<auto> internal_info;
110
112 transient hash<auto> transient_info;
113
115
125 deprecated
127 string desc,
128 string url,
129 bool monitor,
130 *hash opts,
131 hash urlh,
132 *string safe_url,
133 *bool enabled) {
134 // remove "enabled" option from option hash, if any
135 *bool opt_enabled = remove opts.enabled;
136 hash<auto> attributes = {
137 "monitor": monitor,
138 "enabled": enabled ?? opt_enabled ?? True,
139 };
140 constructorInit(name, desc, url, attributes, opts ?? {});
141 }
142
144
161 constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {});
162
163
165
169 string getName();
170
171
173
178
179
181
185 string getUrl();
186
187
189
193 string getSafeUrl();
194
195
197
201 hash<PingInfo> ping(bool throw_exception = False);
202
203
205protected:
206 hash<PingInfo> pingIntern(hash<PingInfo> rv);
207public:
208
209
211
217 hash<ConnectionInfo> getInfo(bool with_password = False);
218
219
221
226 hash<ConnectionInfo> getInfo(*hash<auto> opts);
227
228
230
234 hash<auto> getExtendedInfo(*hash<auto> opts);
235
236
238
240 hash<ConfigInfo> getConfigHash();
241
242
244 hash<ConnectionSchemeInfo> getConnectionSchemeInfo();
245
246
248 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
249
250
252 *hash<auto> getOptions();
253
254
256 *hash<auto> getRuntimeOptions();
257
258
260 *hash<auto> getDefaultOptions();
261
262
264 *hash<auto> getRealOptions();
265
266
268
270 object get(bool connect = True, *hash<auto> rtopts);
271
272
274
278
279
281 hash<auto> getTags();
282
283
285 auto getTag(string tag);
286
287
289
291 auto getTagEx(string tag);
292
293
295
306 AbstractDataProvider getDataProvider();
307
308
310
320
321
323
335
336
338
347
348
350
354 object getPollImpl();
355
356
358 handlePingSuccess(date delta);
359
360
362 handlePingFailed(date delta, hash<ExceptionInfo> ex);
363
364
366 handlePingFailed(date delta, string err);
367
368
370
372protected:
374public:
375
376
378
386protected:
387 hash<UrlInfo> parseUrl(string url);
388public:
389
390
392
405protected:
406 string getSafeUrl(hash<auto> urlh);
407public:
408
409
411
418protected:
419 hash<auto> validateOptions(hash<auto> options);
420public:
421
422
424
427 private:internal constructorInit(string name, string description, string url, hash<auto> attributes,
428 hash<auto> options) {
429 // metadata
430 self.name = name;
431 desc = description;
432
433 // url handling
434 self.url = url;
435 urlh = parseUrl(self.url);
436 safe_url = getSafeUrl(self.urlh);
437
438 // attributes
439 monitor = attributes.monitor ?? True;
440 enabled = attributes.enabled ?? True;
441 locked = attributes.locked ?? False;
442 debug_data = attributes.debug_data ?? False;
443 tags = attributes.tags ?? {};
444
445 opts = validateOptions(options);
446 orig_opts = opts;
448 }
449
451protected:
453public:
454
455
457 abstract string getType();
458
460
466protected:
467 abstract object getImpl(bool connect = True, *hash<auto> rtopts);
468public:
469};
470}; // ConnectionProvider namespace
abstract base class for connections
Definition: AbstractConnection.qc.dox.h:34
string desc
connection description
Definition: AbstractConnection.qc.dox.h:41
internal constructorInit(string name, string description, string url, hash< auto > attributes, hash< auto > options)
Common construtor implementation.
Definition: AbstractConnection.qc.dox.h:427
bool locked
locked/unlocked flag
Definition: AbstractConnection.qc.dox.h:85
string getName()
Returns the connection name.
pingImpl()
performs the internal ping
hash< ConnectionInfo > getInfo(*hash< auto > opts)
returns a ConnectionInfo hash of information about the connection
hash< ConnectionInfo > getInfo(bool with_password=False)
returns a ConnectionInfo hash of information about the connection
bool hasDataProvider()
returns True if the connection returns a data provider with the getDataProvider() method
bool children_can_support_transactions
if the data provider or any of its children support transaction management
Definition: AbstractConnection.qc.dox.h:106
*hash< auto > opts
connection options
Definition: AbstractConnection.qc.dox.h:53
object getPollImpl()
Returns an unconnected object for a non-blocking poll operation.
object get(bool connect=True, *hash< auto > rtopts)
returns the underlying connection object
auto getTagEx(string tag)
returns the value of the given tag or throws an exception if the tag is not set with a value
hash< auto > internal_info
internal tags (serializable)
Definition: AbstractConnection.qc.dox.h:109
*hash< auto > orig_opts
original connection options
Definition: AbstractConnection.qc.dox.h:50
*hash< auto > getRuntimeOptions()
returns runtime options
string url
connection URL (potentially with password info)
Definition: AbstractConnection.qc.dox.h:44
bool children_can_support_messages
if the data provider or any of its children support messages
Definition: AbstractConnection.qc.dox.h:103
hash< auto > getExtendedInfo(*hash< auto > opts)
Returns connection info plus any extended information returned by the connection.
bool monitor
monitoring flag
Definition: AbstractConnection.qc.dox.h:68
string safe_url
"safe" URL (password information removed)
Definition: AbstractConnection.qc.dox.h:47
setChildCapabilities()
Override to set child data provider capabilities once per child class.
Qore::AbstractPollOperation startPollConnect()
Called to start the connection polling operation.
hash< auto > tags
connection tags; user-defined key-value pairs
Definition: AbstractConnection.qc.dox.h:91
string getSafeUrl(hash< auto > urlh)
creates a "safe" URL string with password information removed
bool enabled
enabled/disabled indicator flag
Definition: AbstractConnection.qc.dox.h:82
AbstractDataProvider getDataProvider()
returns a data provider object for this connection, if supported
date last_check
date/time of last check/ping
Definition: AbstractConnection.qc.dox.h:59
bool up
connection status flag; set by monitoring or explicit pings/connections
Definition: AbstractConnection.qc.dox.h:65
hash< auto > validateOptions(hash< auto > options)
performs options validation in the constructor
string getDescription()
Returns the connection description.
hash< ConnectionSchemeInfo > getConnectionSchemeInfo()
Returns a default ConnectionSchemeInfo hash.
hash< ConnectionSchemeInfo > getConnectionSchemeInfoImpl()
Override in subclasses to return a native ConnectionSchemeInfo hash.
hash< PingInfo > pingIntern(hash< PingInfo > rv)
performs the ping by executing get(); returns a PingInfo hash
bool supportsPollingApi()
returns True if the connection supports the Qore Socket-based polling API
bool debug_data
debug data flag; to be used an an indication for a higher-level implementation
Definition: AbstractConnection.qc.dox.h:88
string name
connection name
Definition: AbstractConnection.qc.dox.h:38
hash< UrlInfo > parseUrl(string url)
Parse the URL to a hash.
hash< ConfigInfo > getConfigHash()
returns a ConfigInfo hash of static configuration information about the connection
transient hash< auto > transient_info
internal transient tags (non-serializable)
Definition: AbstractConnection.qc.dox.h:112
*hash< auto > getOptions()
returns static / initialization options
hash< auto > getTags()
returns all tags associated with the connection
abstract object getImpl(bool connect=True, *hash< auto > rtopts)
this method must return the connection object corresponding to the object's configuration
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:126
handlePingFailed(date delta, hash< ExceptionInfo > ex)
Handles a failed ping operation on the connection.
string getSafeUrl()
Returns the connection safe URL (without password info)
string getUrl()
Returns the connection URL.
*hash< auto > getDefaultOptions()
returns default options
constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={})
creates the AbstractConnection object
auto getTag(string tag)
returns the value of the given tag or NOTHING if not present
string status
status string; in case of a connection error this string will be the error string
Definition: AbstractConnection.qc.dox.h:62
parseTextOptions()
this method is called when parsing connection file definitions from text files when loading into the ...
date updated
date/time of last update
Definition: AbstractConnection.qc.dox.h:71
bool children_can_support_apis
if the data provider or any of its children support requests (APIs)
Definition: AbstractConnection.qc.dox.h:94
static *code post_processing
optional code for default post-processing of objects created by getImpl()
Definition: AbstractConnection.qc.dox.h:79
bool loopback
set to True for loopback connections
Definition: AbstractConnection.qc.dox.h:74
bool children_can_support_observers
if the data provider or any of its children support events
Definition: AbstractConnection.qc.dox.h:100
bool children_can_support_records
if the data provider or any of its children support records
Definition: AbstractConnection.qc.dox.h:97
abstract string getType()
returns the string type name for the connection object
handlePingFailed(date delta, string err)
Handles a failed ping operation on the connection.
hash< auto > urlh
broken down URL hash (as returned by Qore::parse_url())
Definition: AbstractConnection.qc.dox.h:56
hash< PingInfo > ping(bool throw_exception=False)
returns a hash with the results of the ping operation
*hash< auto > getRealOptions()
returns options for saving the connection's configuration information
handlePingSuccess(date delta)
Handles a successful ping operation on the connection.
The ConnectionProvider namespace.
Definition: AbstractConnection.qc.dox.h:28