Qore ConnectionProvider Module Reference 2.0.1
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 - 2024 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
33const PF_THROW_EXCEPTION = (1 << 0);
34
36
39const PF_AUTOMATIC_PING = (1 << 1);
41
46const CCS_UNSUPPORTED = "unsupported";
47
49
51const CCS_UNCUSTOMIZED = "uncustomized";
52
54
56const CCS_IN_PROGRESS = "in-progress";
57
59
61const CCS_CUSTOMIZED = "customized";
63
65
69class AbstractConnection : public Qore::Serializable, public Logger::LoggerWrapper, public OptionHelper {
70
71public:
73 string name;
74
77
79 *string short_desc;
80
82 string desc;
83
85 string url;
86
88 string safe_url;
89
91 string real_url;
92
94 *hash<auto> orig_opts;
95
97 *hash<auto> opts;
98
100 hash<auto> urlh;
101
104
106 string status = "not checked";
107
109 bool up = True;
110
113
116
118 bool loopback = False;
119
122
125
128
130
132 static *code post_processing;
133
135 bool enabled = True;
136
138 bool locked = False;
139
141 bool debug_data = False;
142
144 hash<auto> tags = {};
145
148
151
154
157
160
162 hash<auto> internal_info;
163
166
168 transient hash<auto> transient_info;
169
171
173 const CF_LOGGER = "logger";
174
176
182 const CF_UPDATE_OPTIONS = "update-options";
183
185 const DefaultDescription = "n/a; update connection to use the `AbstractConnectionWithInfo` class instead";
186
189
190
192
207 deprecated
208 constructor(string name, string desc, string url, bool monitor, *hash opts, hash urlh, *string safe_url, *bool enabled);
209
210
212
233 deprecated constructor(string name, string description, string url, hash<auto> attributes = {}, hash<auto> options = {}, *LoggerInterface logger) ;
234
236
254 constructor(hash<auto> config, *hash<auto> attr);
255
256
258
262 string getName();
263
264
266
271
272
274
279
280
282
287
288
290
294 string getUrl();
295
296
298
302 string getSafeUrl();
303
304
306
313 bool needsAuth();
314
315
317
321 *string getAppName();
322
323
325
329 hash<PingInfo> ping(bool throw_exception);
330
331
333
339 hash<PingInfo> ping(int ping_flags = 0);
340
341
343
346
347
349
355 startCustomization(*bool restart);
356
357
359protected:
360 hash<PingInfo> pingIntern(hash<PingInfo> rv);
361public:
362
363
365
371 hash<ConnectionInfo> getInfo(bool with_password = False);
372
373
375
383 hash<ConnectionInfo> getInfo(*hash<auto> opts);
384
385
387
396 hash<ConnectionDataInfo> getInfoAsData(*hash<auto> opts);
397
398
400
402 *hash<string, bool> getFeatures();
403
404
406
418 hash<auto> getExtendedInfo(*hash<auto> opts);
419
420
422
433 hash<auto> getExtendedInfoAsData(*hash<auto> opts);
434
435
437
439 hash<ConfigInfo> getConfigHash();
440
441
443 hash<ConnectionSchemeInfo> getConnectionSchemeInfo();
444
445
447 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
448
449
451 *hash<auto> getOptions();
452
453
455 *hash<auto> getRuntimeOptions();
456
457
459 *hash<auto> getDefaultOptions();
460
461
463 *hash<auto> getRealOptions();
464
465
467 *hash<auto> getConnectionOptions(*hash<auto> rtopts);
468
469
471
473 object get(bool connect = True, *hash<auto> rtopts);
474
475
477
481
482
484 hash<auto> getTags();
485
486
488 auto getTag(string tag);
489
490
492
494 auto getTagEx(string tag);
495
496
498
508
509
511
526 AbstractDataProvider getDataProvider(*hash<auto> constructor_options);
527
528
530
543 AbstractDataProvider getDataProvider(string subtype, *hash<auto> constructor_options);
544
545
547
551 *hash<string, hash<DataProviderOptionInfo>> getDataProviderConstructorOptions();
552
553
555
561 *hash<string, *hash<string, hash<DataProviderOptionInfo>>> getDataProviderSubtypes();
562
563
565
577
578
580
590 Qore::AbstractPollOperation startPollConnect(*Logger::LoggerInterface logger);
591
592
594
598 object getPollImpl();
599
600
602 handlePingSuccess(date delta);
603
604
606 handlePingFailed(date delta, hash<ExceptionInfo> ex);
607
608
610 handlePingFailed(date delta, string err);
611
612
614 static hash<ConnectionOptionInfo> getConnectionOptionInfo(hash<DataProviderOptionInfo> dinfo);
615
617 static hash<string, hash<ConnectionOptionInfo>> getConnectionOptionInfo( hash<string, hash<DataProviderOptionInfo>> dinfo);
618
620 static string getRealUrl(string url, hash<ConnectionSchemeInfo> info, string type);
621
623
625protected:
627public:
628
629
631
647protected:
648 AbstractDataProvider getDataProviderImpl(string subtype, *hash<auto> constructor_options);
649public:
650
651
653
657protected:
658 *hash<string, hash<DataProviderOptionInfo>> getDataProviderConstructorOptionsImpl();
659public:
660
661
663
667protected:
668 *hash<string, *hash<string, hash<DataProviderOptionInfo>>> getDataProviderSubtypesImpl();
669public:
670
671
673
676protected:
677 *hash<auto> getSubtypeOptions(*hash<string, hash<DataProviderOptionInfo>> subtype_options, *hash<auto> constructor_options);
678public:
679
680
682
684protected:
686public:
687
688
690
698protected:
699 hash<UrlInfo> parseUrl(string url);
700public:
701
702
704
717protected:
718 string getSafeUrl(hash<auto> urlh);
719public:
720
721
723
732protected:
733 hash<auto> validateOptions(hash<auto> options, bool check_required = True);
734public:
735
736
738
756private:
757 constructorInit(hash<auto> config, *hash<auto> attr);
758public:
759
760
762
766protected:
767 setRealUrl(*string url);
768public:
769
770
772
776protected:
777 *hash<string, bool> getFeaturesImpl();
778public:
779
780
782protected:
784public:
785
786
788 abstract string getType();
789
791
797protected:
798 abstract object getImpl(bool connect = True, *hash<auto> rtopts);
799public:
800};
801}; // ConnectionProvider namespace
Abstract base class for connections.
Definition AbstractConnection.qc.dox.h:69
string desc
Connection description with markdown formatting.
Definition AbstractConnection.qc.dox.h:82
bool locked
locked/unlocked flag
Definition AbstractConnection.qc.dox.h:138
string display_name
Display name.
Definition AbstractConnection.qc.dox.h:76
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
const DefaultDescription
Default option description.
Definition AbstractConnection.qc.dox.h:185
bool children_can_support_transactions
if the data provider or any of its children support transaction management
Definition AbstractConnection.qc.dox.h:159
*hash< auto > opts
connection options
Definition AbstractConnection.qc.dox.h:97
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
const CF_LOGGER
Connection feature: Logger support.
Definition AbstractConnection.qc.dox.h:173
*hash< string, hash< DataProviderOptionInfo > > getDataProviderConstructorOptionsImpl()
Returns a hash of data provider constructor option info, if applicable.
auto getTagEx(string tag)
returns the value of the given tag or throws an exception if the tag is not set with a value
const CommonConnectionKeys
Connection info keys mapped 1:1 to DataProviderOptionInfo keys.
Definition AbstractConnection.qc.dox.h:188
bool needsAuth()
Returns True if the connection requires OAuth2 authorization before it can be used.
hash< auto > internal_info
internal tags (serializable)
Definition AbstractConnection.qc.dox.h:162
*hash< auto > orig_opts
original connection options
Definition AbstractConnection.qc.dox.h:94
*hash< auto > getRuntimeOptions()
returns runtime options
string url
Connection URL (potentially with password info)
Definition AbstractConnection.qc.dox.h:85
bool children_can_support_messages
if the data provider or any of its children support messages
Definition AbstractConnection.qc.dox.h:156
AbstractDataProvider getDataProvider(string subtype, *hash< auto > constructor_options)
Returns a data provider object for the connection and subtype passed as an argument.
persistInfo(AbstractConnection old)
Called after a new connection object is created from an existing connection.
*hash< string, bool > getFeaturesImpl()
Returns a hash of connection-defined features.
hash< auto > getExtendedInfo(*hash< auto > opts)
Returns connection info plus any extended information returned by the connection.
Qore::AbstractPollOperation startPollConnect(*Logger::LoggerInterface logger)
Called to start the connection polling operation.
bool monitor
monitoring flag
Definition AbstractConnection.qc.dox.h:112
string safe_url
"safe" URL (password information removed)
Definition AbstractConnection.qc.dox.h:88
static hash< ConnectionOptionInfo > getConnectionOptionInfo(hash< DataProviderOptionInfo > dinfo)
Returns a ConnectionOptionInfo hash from a DataProviderOptionInfo hash.
static string getRealUrl(string url, hash< ConnectionSchemeInfo > info, string type)
Returns the real URL for a connection URL.
setChildCapabilities()
Override to set child data provider capabilities once per child class.
hash< auto > tags
connection tags; user-defined key-value pairs
Definition AbstractConnection.qc.dox.h:144
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:135
hash< PingInfo > ping(bool throw_exception)
returns a hash with the results of the ping operation
string real_url
A string containing the real URL using a non-abstract / technical scheme.
Definition AbstractConnection.qc.dox.h:91
*hash< auto > getConnectionOptions(*hash< auto > rtopts)
returns options for creating a new connection
bool up
connection status flag; set by monitoring or explicit pings/connections
Definition AbstractConnection.qc.dox.h:109
string getDescription()
Returns the connection description.
hash< ConnectionSchemeInfo > getConnectionSchemeInfo()
Returns a default ConnectionSchemeInfo hash.
static hash< string, hash< ConnectionOptionInfo > > getConnectionOptionInfo(hash< string, hash< DataProviderOptionInfo > > dinfo)
Returns a hash of ConnectionOptionInfo hashes from a hash of DataProviderOptionInfo hashes.
const CF_UPDATE_OPTIONS
Connection feature: Update Options support.
Definition AbstractConnection.qc.dox.h:182
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
string customization_status
Customization status.
Definition AbstractConnection.qc.dox.h:124
hash< PingInfo > ping(int ping_flags=0)
returns a hash with the results of the ping operation
bool debug_data
debug data flag; to be used an an indication for a higher-level implementation
Definition AbstractConnection.qc.dox.h:141
string name
Connection name.
Definition AbstractConnection.qc.dox.h:73
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
*hash< string, *hash< string, hash< DataProviderOptionInfo > > > getDataProviderSubtypesImpl()
Returns a hash of supported data provider subtypes.
startCustomization(*bool restart)
Starts customization for the object.
setRealUrl(*string url)
Called by the constructor to set the real URL.
transient hash< auto > transient_info
internal transient tags (non-serializable)
Definition AbstractConnection.qc.dox.h:168
deprecated constructor(string name, string description, string url, hash< auto > attributes={}, hash< auto > options={}, *LoggerInterface logger)
creates the AbstractConnection object
*string getAppName()
Returns the data provider application name this connection serves, if any.
*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
handlePingFailed(date delta, hash< ExceptionInfo > ex)
Handles a failed ping operation on the connection.
hash< auto > validateOptions(hash< auto > options, bool check_required=True)
performs options validation in the constructor
string getSafeUrl()
Returns the connection safe URL (without password info)
constructorInit(hash< auto > config, *hash< auto > attr)
Common construtor implementation.
string getUrl()
Returns the connection URL.
*hash< auto > getDefaultOptions()
returns default options
auto getTag(string tag)
returns the value of the given tag or NOTHING if not present
string getShortDescription()
Returns the connection short description.
AbstractDataProvider getDataProviderImpl(string subtype, *hash< auto > constructor_options)
returns a data provider object for the connection and subtype passed as an argument
string status
status string; in case of a connection error this string will be the error string
Definition AbstractConnection.qc.dox.h:106
parseTextOptions()
this method is called when parsing connection file definitions from text files when loading into the ...
hash< ConnectionDataInfo > getInfoAsData(*hash< auto > opts)
Returns a ConnectionDataInfo hash of information about the connection.
date updated
date/time of last update
Definition AbstractConnection.qc.dox.h:115
string getDisplayName()
Returns the connection display name.
bool children_can_support_apis
if the data provider or any of its children support requests (APIs)
Definition AbstractConnection.qc.dox.h:147
static *code post_processing
optional code for default post-processing of objects created by getImpl()
Definition AbstractConnection.qc.dox.h:132
bool loopback
set to True for loopback connections
Definition AbstractConnection.qc.dox.h:118
bool children_can_support_observers
if the data provider or any of its children support events
Definition AbstractConnection.qc.dox.h:153
*date customization_timestamp
Customization timestamp.
Definition AbstractConnection.qc.dox.h:127
bool children_can_support_records
if the data provider or any of its children support records
Definition AbstractConnection.qc.dox.h:150
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.
bool supports_customization
Customization support?
Definition AbstractConnection.qc.dox.h:121
hash< auto > urlh
broken down URL hash (as returned by Qore::parse_url())
Definition AbstractConnection.qc.dox.h:100
*hash< string, hash< DataProviderOptionInfo > > getDataProviderConstructorOptions()
Returns a hash of data provider constructor option info, if applicable.
constructor(hash< auto > config, *hash< auto > attr)
creates the AbstractConnection object
startCustomizationImpl()
Starts customization for the object.
*hash< auto > getSubtypeOptions(*hash< string, hash< DataProviderOptionInfo > > subtype_options, *hash< auto > constructor_options)
Returns options for each data provider subtype.
*string short_desc
Connection short description in plain text.
Definition AbstractConnection.qc.dox.h:79
*hash< auto > getRealOptions()
returns options for saving the connection's configuration information
hash< auto > getExtendedInfoAsData(*hash< auto > opts)
Returns connection info plus any extended information returned by the connection.
AbstractDataProvider getDataProvider(*hash< auto > constructor_options)
returns a data provider object for this connection, if supported
*hash< string, *hash< string, hash< DataProviderOptionInfo > > > getDataProviderSubtypes()
Returns a hash of supported data provider subtypes and constructor option info.
*hash< string, bool > getFeatures()
Returns a list of connection-defined features.
bool disable_automatic_pings
If automatic pings are disabled.
Definition AbstractConnection.qc.dox.h:165
handlePingSuccess(date delta)
Handles a successful ping operation on the connection.
*date last_check
date/time of last check/ping
Definition AbstractConnection.qc.dox.h:103
Class with helper methods to options in a hash.
Definition OptionHelper.qc.dox.h:30
const CCS_IN_PROGRESS
Customization status: in-progress.
Definition AbstractConnection.qc.dox.h:56
const CCS_CUSTOMIZED
Customization status: customized.
Definition AbstractConnection.qc.dox.h:61
const CCS_UNSUPPORTED
Definition AbstractConnection.qc.dox.h:46
const CCS_UNCUSTOMIZED
Customization status: uncustomized.
Definition AbstractConnection.qc.dox.h:51
const PF_THROW_EXCEPTION
Definition AbstractConnection.qc.dox.h:33
const PF_AUTOMATIC_PING
Ping flag: automatic / scheduled ping.
Definition AbstractConnection.qc.dox.h:39
The ConnectionProvider namespace.
Definition AbstractConnection.qc.dox.h:28