Qore ConnectionProvider Module Reference 2.0
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
349 startCustomization(*bool restart);
350
351
353protected:
354 hash<PingInfo> pingIntern(hash<PingInfo> rv);
355public:
356
357
359
365 hash<ConnectionInfo> getInfo(bool with_password = False);
366
367
369
377 hash<ConnectionInfo> getInfo(*hash<auto> opts);
378
379
381
390 hash<ConnectionDataInfo> getInfoAsData(*hash<auto> opts);
391
392
394
396 *hash<string, bool> getFeatures();
397
398
400
412 hash<auto> getExtendedInfo(*hash<auto> opts);
413
414
416
427 hash<auto> getExtendedInfoAsData(*hash<auto> opts);
428
429
431
433 hash<ConfigInfo> getConfigHash();
434
435
437 hash<ConnectionSchemeInfo> getConnectionSchemeInfo();
438
439
441 hash<ConnectionSchemeInfo> getConnectionSchemeInfoImpl();
442
443
445 *hash<auto> getOptions();
446
447
449 *hash<auto> getRuntimeOptions();
450
451
453 *hash<auto> getDefaultOptions();
454
455
457 *hash<auto> getRealOptions();
458
459
461 *hash<auto> getConnectionOptions(*hash<auto> rtopts);
462
463
465
467 object get(bool connect = True, *hash<auto> rtopts);
468
469
471
475
476
478 hash<auto> getTags();
479
480
482 auto getTag(string tag);
483
484
486
488 auto getTagEx(string tag);
489
490
492
502
503
505
520 AbstractDataProvider getDataProvider(*hash<auto> constructor_options);
521
522
524
537 AbstractDataProvider getDataProvider(string subtype, *hash<auto> constructor_options);
538
539
541
545 *hash<string, hash<DataProviderOptionInfo>> getDataProviderConstructorOptions();
546
547
549
555 *hash<string, *hash<string, hash<DataProviderOptionInfo>>> getDataProviderSubtypes();
556
557
559
571
572
574
584 Qore::AbstractPollOperation startPollConnect(*Logger::LoggerInterface logger);
585
586
588
592 object getPollImpl();
593
594
596 handlePingSuccess(date delta);
597
598
600 handlePingFailed(date delta, hash<ExceptionInfo> ex);
601
602
604 handlePingFailed(date delta, string err);
605
606
608 static hash<ConnectionOptionInfo> getConnectionOptionInfo(hash<DataProviderOptionInfo> dinfo);
609
611 static hash<string, hash<ConnectionOptionInfo>> getConnectionOptionInfo( hash<string, hash<DataProviderOptionInfo>> dinfo);
612
614 static string getRealUrl(string url, hash<ConnectionSchemeInfo> info, string type);
615
617
619protected:
621public:
622
623
625
641protected:
642 AbstractDataProvider getDataProviderImpl(string subtype, *hash<auto> constructor_options);
643public:
644
645
647
651protected:
652 *hash<string, hash<DataProviderOptionInfo>> getDataProviderConstructorOptionsImpl();
653public:
654
655
657
661protected:
662 *hash<string, *hash<string, hash<DataProviderOptionInfo>>> getDataProviderSubtypesImpl();
663public:
664
665
667
670protected:
671 *hash<auto> getSubtypeOptions(*hash<string, hash<DataProviderOptionInfo>> subtype_options, *hash<auto> constructor_options);
672public:
673
674
676
678protected:
680public:
681
682
684
692protected:
693 hash<UrlInfo> parseUrl(string url);
694public:
695
696
698
711protected:
712 string getSafeUrl(hash<auto> urlh);
713public:
714
715
717
726protected:
727 hash<auto> validateOptions(hash<auto> options, bool check_required = True);
728public:
729
730
732
750private:
751 constructorInit(hash<auto> config, *hash<auto> attr);
752public:
753
754
756
760protected:
761 setRealUrl(*string url);
762public:
763
764
766
770protected:
771 *hash<string, bool> getFeaturesImpl();
772public:
773
774
776protected:
778public:
779
780
782 abstract string getType();
783
785
791protected:
792 abstract object getImpl(bool connect = True, *hash<auto> rtopts);
793public:
794};
795}; // 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.
*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