dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
DXEndpoint.hpp
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "../detail/Conf.hpp"
7
8DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251)
9
10#include "../detail/JavaObjectHandle.hpp"
11#include "../detail/StringParam.hpp"
12#include "../executors/InPlaceExecutor.hpp"
13#include "../util/Handler.hpp"
14#include "../util/TimePeriod.hpp"
15#include "../util/TimePeriodInfo.hpp"
16#include "./ConnectionError.hpp"
17#include "./DXFeed.hpp"
18#include "./DXPublisher.hpp"
19#include "./MessageConnectorInfo.hpp"
20
21#include <chrono>
22#include <cstdint>
23#include <functional>
24#include <optional>
25#include <string>
26#include <type_traits>
27#include <unordered_map>
28#include <unordered_set>
29#include <vector>
30
31/**
32 * \addtogroup dxfcpp_api
33 * @{
34 */
35
36DXFCPP_BEGIN_NAMESPACE
37
38struct DXPublisher;
39struct DXFeed;
40struct OnDemandService;
41
42/**
43 * Manages network connections to @ref DXFeed "feed" or
44 * @ref DXPublisher "publisher". There are per-process (per GraalVM Isolate for now) ready-to-use singleton instances
45 * that are available with DXEndpoint::getInstance() and DXEndpoint::getInstance(Role) methods as well as
46 * factory methods DXEndpoint::create() and DXEndpoint::create(Role), and a number of configuration methods. Advanced
47 * properties can be configured using
48 * @ref DXEndpoint::newBuilder() "newBuilder()"->@ref DXEndpoint::Builder::withProperty(StringParam, StringParam)
49 * "withProperty(key, value)"->@ref DXEndpoint::Builder::build() "build()".
50 *
51 * See DXFeed for details on how to subscribe to symbols and receive events.
52 *
53 * <h3>Endpoint role</h3>
54 *
55 * Each endpoint has a role that is specified on its creation and cannot be changed afterward.
56 * The default factory method DXEndpoint::create() creates an endpoint with a @ref Role::FEED "FEED" role.
57 * Endpoints with other roles are created with DXEndpoint::create(Role) factory method. Endpoint role is
58 * represented by @ref Role "DXEndpoint::Role" enumeration.
59 *
60 * Endpoint role defines the behavior of its @ref DXEndpoint::connect(StringParam) "connect" method:
61 *
62 * - @ref Role::FEED "FEED" connects to the remote data feed provider and is optimized for real-time or
63 * delayed data processing (<b>this is a default role</b>).
64 * DXEndpoint::getFeed() method returns a feed object that subscribes to this remote data feed provider and receives
65 * events from it. When event processing threads cannot keep up (don't have enough CPU time), data is dynamically
66 * conflated to minimize latency between received events and their processing time. For example,
67 * - <b>`DXEndpoint::create()->connect("demo.dxfeed.com:7300")->getFeed()`</b> returns a demo feed from dxFeed with
68 * sample market quotes.
69 * - <b>`DXEndpoint::create()->connect("localhost:7400")->getFeed()`</b> returns a feed connected to a
70 * publisher that is running on the same host. See the example below.
71 * - <b>`DXEndpoint::create()->connect("file:demo-sample.data")->getFeed()`</b> returns a feed that is connected to
72 * a "demo-sample.data" file and plays back it as if it was received in real time.
73 *
74 * This endpoint is automatically connected to the configured data feed, as explained in the default properties
75 * section.
76 * - @ref Role::ON_DEMAND_FEED "ON_DEMAND_FEED" is similar to @ref Role::FEED "FEED", but it is designed to be used with
77 * OnDemandService for historical data replay only. It is configured with default properties but is not connected
78 * automatically to the data provider until the OnDemandService::replay method is invoked.
79 * - @ref Role::STREAM_FEED "STREAM_FEED" is similar to @ref Role::FEED "FEED" and also connects to the remote data
80 * feed provider, but is designed for bulk parsing of data from files. DXEndpoint::getFeed() method returns feed
81 * object that subscribes to the data from the opened files and receives events from them. Events from the files are
82 * not conflated and are processed as fast as possible. Note that in this role, the DXFeed::getLastEvent () method
83 * does not work and time-series subscription is not supported. For example,
84 * ```cpp
85 * auto endpoint = DXEndpoint::create(DXEndpoint::Role::STREAM_FEED);
86 * auto feed = endpoint->getFeed();
87 * ```
88 * creates a feed that is ready to read data from the file as soon as the following code is invoked:
89 * ```cpp
90 * endpoint->connect("file:demo-sample.data[speed=max]");
91 * ```
92 * "[speed=max]" clause forces to the file reader to play back all the data from "demo-sample.data" file as fast as
93 * data subscribers are processing it.
94 * - @ref Role::PUBLISHER "PUBLISHER" connects to the remote publisher hub (also known as multiplexor) or creates a
95 * publisher on the local host. DXEndpoint::getPublisher() method returns a publisher object that publishes events to
96 * all connected feeds. For example,
97 * <b>`DXEndpoint::create(DXEndpoint::Role::PUBLISHER)->connect(":7400")->getPublisher()`</b> returns a publisher
98 * waiting for connections on TCP/IP port 7400. The published events will be delivered to all feeds that are
99 * connected to this publisher. This endpoint is automatically connected to the configured data feed, as explained in
100 * the default properties section.
101 * - @ref Role::LOCAL_HUB "LOCAL_HUB" creates a local hub without the ability to establish network connections.
102 * Events that are published via @ref DXEndpoint::getPublisher() "publisher" are delivered to local @ref
103 * DXEndpoint::getFeed() "feed" only.
104 *
105 * <h3>Endpoint state</h3>
106 *
107 * Each endpoint has a state that can be retrieved with the DXEndpoint::getState method.
108 * When an endpoint is created with any role and the default address is not specified in default properties, then it is
109 * not connected to any remote endpoint. Its state is @ref State::NOT_CONNECTED "NOT_CONNECTED".
110 *
111 * @ref Role::FEED "Feed" and @ref Role::PUBLISHER "publisher" endpoints can connect to remote endpoints of the opposite
112 * role. Connection is initiated by @ref DXEndpoint::connect(StringParam) "connect" method.
113 * The endpoint state becomes @ref State::CONNECTING "CONNECTING".
114 *
115 * When the actual connection to the remote endpoint is established, the endpoint state becomes
116 * @ref State::CONNECTED "CONNECTED".
117 *
118 * Network connections can temporarily break and return endpoint back into the @ref State::CONNECTING "CONNECTING"
119 * state. File connections can be completed and return endpoint into the @ref State::NOT_CONNECTED "NOT_CONNECTED"
120 * state.
121 *
122 * Connection to the remote endpoint can be terminated with the DXEndpoint::disconnect() method.
123 * The endpoint state becomes @ref State::NOT_CONNECTED "NOT_CONNECTED".
124 *
125 * Endpoint can be closed with DXEndpoint::close() method. The endpoint state becomes @ref State::CLOSED "CLOSED". This
126 * is a final state. All connections are terminated and all internal resources that are held by this endpoint are freed.
127 * No further connections can be initiated.
128 *
129 * <h3>Event times</h3>
130 *
131 * The EventType::getEventTime() on received events is available only when the endpoint is created with
132 * DXEndpoint::DXENDPOINT_EVENT_TIME_PROPERTY property and the data source has embedded event times. This is typically
133 * true only for data events that are read from historical tape files (see above) and from OnDemandService. Events that
134 * are coming from network connections do not have embedded event time information, and event time is not available
135 * for them anyway.
136 *
137 * <h3><a name="defaultPropertiesSection">Default properties</a></h3>
138 *
139 * Default properties are loaded from the "dxfeed.properties" or "dxpublisher.properties" file depending on
140 * the @ref Role "role" of the created endpoint. "dxfeed.properties" is used for @ref Role::FEED "FEED" and
141 * @ref Role::ON_DEMAND_FEED "ON_DEMAND_FEED", "dxpublisher.properties" is used for @ref Role::PUBLISHER "PUBLISHER".
142 * @ref Role::STREAM_FEED "STREAM_FEED" and @ref Role::LOCAL_HUB "LOCAL_HUB" do not support the properties file.
143 *
144 * The location of this file can be specified using
145 * @ref Builder::withProperty(StringParam, StringParam) "withProperty"(::DXFEED_PROPERTIES_PROPERTY, path)
146 * or
147 * @ref Builder::withProperty(StringParam, StringParam) "withProperty"(::DXPUBLISHER_PROPERTIES_PROPERTY,
148 * path) correspondingly. When the location of this file is not explicitly specified using
149 * @ref Builder::withProperty(StringParam, StringParam) "withProperty" method, then the file path is taken
150 * from a system property with the corresponding name.
151 *
152 * Defaults for individual properties can be also provided using system properties when they are not specified
153 * in the configuration file.
154 *
155 * The DXEndpoint::NAME_PROPERTY is the exception to the above rule. It is never loaded from system properties.
156 * It can be only specified in the configuration file or programmatically. There is a convenience
157 * @ref Builder::withName(StringParam) "Builder.withName" method for it. It is recommended to assign short and
158 * meaningful endpoint names when multiple endpoints are used in the same process (one GraalVM Isolate for now).
159 * The name of the endpoint shall describe its role in the particular application.
160 *
161 * Note that individual properties that are programmatically set using @ref Builder::withProperty(StringParam,
162 * StringParam) "withProperty" method always take precedence.
163 *
164 * @ref Role::FEED "FEED" and @ref Role::PUBLISHER "PUBLISHER" automatically establish connection on creation
165 * when the corresponding DXEndpoint::DXFEED_ADDRESS_PROPERTY or DXEndpoint::DXPUBLISHER_ADDRESS_PROPERTY is
166 * specified.
167 *
168 * <h3>Permanent subscription</h3>
169 *
170 * Endpoint properties can define permanent subscription for specific sets of symbols and event types in
171 * the data feed, so that DXFeed methods like @ref DXFeed::getLastEventIfSubscribed "getLastEventIfSubscribed",
172 * @ref DXFeed::getIndexedEventsIfSubscribed "getIndexedEventsIfSubscribed" and
173 * @ref DXFeed::getTimeSeriesIfSubscribed "getTimeSeriesIfSubscribed" can be used without a need to create a
174 * separate DXFeedSubscription object. Please contact dxFeed support for details
175 * on the required configuration.
176 *
177 * <h3>Threads and locks</h3>
178 *
179 * This class is thread-safe and can be used concurrently from multiple threads without external synchronization.
180 *
181 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html)
182 *
183 * Some methods that are not marked `noexcept` may throw exceptions:
184 *
185 * @throws InvalidArgumentException if the entity's handle is invalid.
186 * @throws JavaException if something happened with the dxFeed API backend
187 * @throws GraalException if something happened with the GraalVM
188 */
190 /// The alias to a type of shared pointer to the DXEndpoint object
191 using Ptr = std::shared_ptr<DXEndpoint>;
192
193 /// The alias to a type of unique pointer to the DXEndpoint object
195
196 friend struct OnDemandService;
197
198 /**
199 * `"name"`
200 *
201 * Defines property for endpoint name that is used to distinguish multiple endpoints
202 * in the same process in logs and in other diagnostic means.
203 * Use Builder::withProperty(StringParam, StringParam) method.
204 * This property is also changed by the Builder::withName(StringParam) method.
205 */
206 static constexpr char NAME_PROPERTY[] = "name";
207
208 /**
209 * `"dxfeed.properties"`
210 *
211 * Defines a path to a file with properties for an endpoint with the role @ref Role::FEED "FEED" or
212 * @ref Role::ON_DEMAND_FEED "ON_DEMAND_FEED".
213 * By default, properties are loaded from a path resource named "dxfeed.properties".
214 *
215 * The SDK writes to its log (at the INFO level) the name of the loaded file, `DXEndpoint is loading properties
216 * from <name>`, and the resulting address, `<name> DXEndpoint with dxfeed.address=<address>`: look for these lines
217 * when the endpoint connects to an unexpected address.
218 *
219 * @see Builder::withProperty(StringParam, StringParam)
220 */
221 static constexpr char DXFEED_PROPERTIES_PROPERTY[] = "dxfeed.properties";
222
223 /**
224 * `"dxfeed.address"`
225 *
226 * Defines default connection address for an endpoint with the role @ref Role::FEED "FEED"
227 * or @ref Role::ON_DEMAND_FEED "ON_DEMAND_FEED".
228 * Connection is established to this address by the role @ref Role::FEED "FEED" as soon as the endpoint is created,
229 * while the role @ref Role::ON_DEMAND_FEED "ON_DEMAND_FEED" waits until OnDemandService::(std::int64_t, double) is
230 * invoked before connecting.
231 *
232 * By default, without this property, a connection is not established until @ref DXEndpoint::connect(StringParam)
233 * "connect(address)" is invoked.
234 *
235 * Credentials for access to premium services may be configured with
236 * DXEndpoint::DXFEED_USER_PROPERTY and DXEndpoint::DXFEED_PASSWORD_PROPERTY.
237 *
238 * @see Builder::withProperty(StringParam, StringParam)
239 */
240 static constexpr char DXFEED_ADDRESS_PROPERTY[] = "dxfeed.address";
241
242 /**
243 * `"dxfeed.user"`
244 *
245 * Defines default username for an endpoint with the role @ref Role::FEED "FEED" or @ref Role::ON_DEMAND_FEED
246 * "ON_DEMAND_FEED".
247 *
248 * @see DXEndpoint::user(StringParam)
249 */
250 static constexpr char DXFEED_USER_PROPERTY[] = "dxfeed.user";
251
252 /**
253 * `"dxfeed.password"`
254 *
255 * Defines default password for an endpoint with role @ref Role::FEED "FEED" or @ref Role::ON_DEMAND_FEED
256 * "ON_DEMAND_FEED".
257 *
258 * @see DXEndpoint::password(StringParam)
259 */
260 static constexpr char DXFEED_PASSWORD_PROPERTY[] = "dxfeed.password";
261
262 /**
263 * `"dxfeed.threadPoolSize"`
264 *
265 * Defines thread pool size for an endpoint with the role @ref Role::FEED "FEED".
266 * By default, the thread pool size is equal to the number of available processors.
267 * @see Builder::withProperty(StringParam, StringParam)
268 */
269 static constexpr char DXFEED_THREAD_POOL_SIZE_PROPERTY[] = "dxfeed.threadPoolSize";
270
271 /**
272 * `"dxfeed.aggregationPeriod"`
273 *
274 * Defines a data aggregation period for an endpoint with the role @ref Role::FEED "FEED" that
275 * limits the rate of data notifications. For example, setting the value of this property
276 * to "0.1s" limits notification to once every "100ms" (at most 10 per second).
277 * @see Builder::withProperty(StringParam, StringParam)
278 */
279 static constexpr char DXFEED_AGGREGATION_PERIOD_PROPERTY[] = "dxfeed.aggregationPeriod";
280
281 /**
282 * `"dxfeed.wildcard.enable"`
283 *
284 * Set this property to `true` to turn on wildcard support.
285 * By default, the endpoint does not support wildcards. This property is needed for
286 * WildcardSymbol support and for the use of "tape:..." address in DXPublisher.
287 */
288 static constexpr char DXFEED_WILDCARD_ENABLE_PROPERTY[] = "dxfeed.wildcard.enable";
289
290 /**
291 * `"dxfeed.stripe"`
292 *
293 * Defines a symbol striping strategy for an endpoint.
294 * @see Builder::withProperty(StringParam, StringParam)
295 */
296 static constexpr char DXFEED_STRIPE_PROPERTY[] = "dxfeed.stripe";
297
298 /**
299 * `"dxfeed.stickySubscriptionPeriod"`
300 *
301 * Defines a sticky subscription period in the format of TimePeriod.
302 * @see Builder::withProperty(StringParam, StringParam)
303 */
304 static constexpr char DXFEED_STICKY_SUBSCRIPTION_PROPERTY[] = "dxfeed.stickySubscriptionPeriod";
305
306 /**
307 * `"dxfeed.requestedAggregationPeriod"`
308 *
309 * Defines a requested aggregation period to be negotiated with the server. The server applies its own rules and
310 * limits to the request and applies the resulting period on the server side to control the data transmission rate
311 * (reduces network traffic and server load).
312 *
313 * Differs from DXEndpoint::DXFEED_AGGREGATION_PERIOD_PROPERTY, which is local and client-side only: the client
314 * throttles locally, but the server sends at its own rate.
315 *
316 * Format: a TimePeriod string (e.g., "1s", "0.5s", "0" for real-time). If not specified, the server uses its
317 * default.
318 * @see DXEndpoint::setRequestedAggregationPeriod()
319 * @see Builder::withProperty(StringParam, StringParam)
320 */
321 static constexpr char DXFEED_REQUESTED_AGGREGATION_PERIOD_PROPERTY[] = "dxfeed.requestedAggregationPeriod";
322
323 /**
324 * `"dxpublisher.properties"`
325 *
326 * Defines a path to a file with properties for an endpoint with the role @ref Role::PUBLISHER "PUBLISHER".
327 * By default, properties are loaded from a classpath resource named "dxpublisher.properties".
328 * @see Builder::withProperty(StringParam, StringParam)
329 */
330 static constexpr char DXPUBLISHER_PROPERTIES_PROPERTY[] = "dxpublisher.properties";
331
332 /**
333 * `"dxpublisher.address"`
334 *
335 * Defines default connection address for an endpoint with the role @ref Role::PUBLISHER "PUBLISHER".
336 * Connection is established to this address as soon as an endpoint is created.
337 * By default, the connection is not established until DXEndpoint::connect(StringParam) is invoked.
338 * @see Builder::withProperty(StringParam, StringParam)
339 */
340 static constexpr char DXPUBLISHER_ADDRESS_PROPERTY[] = "dxpublisher.address";
341
342 /**
343 * `"dxpublisher.threadPoolSize"`
344 *
345 * Defines thread pool size for an endpoint with the role @ref Role::PUBLISHER "PUBLISHER".
346 * By default, the thread pool size is equal to the number of available processors.
347 * @see Builder#withProperty(StringParam, StringParam)
348 */
349 static constexpr char DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY[] = "dxpublisher.threadPoolSize";
350
351 /**
352 * `"dxendpoint.eventTime"`
353 *
354 * Set this property to `true` to enable @ref EventType::getEventTime() "event time" support.
355 * By default, the endpoint does not support event time.
356 *
357 * The event time is available only when the corresponding DXEndpoint is created with this property and
358 * the data source has embedded event times. This is typically true only for data events
359 * that are read from historical tape files and from OnDemandService.
360 * Events that are coming from network connections do not have embedded event time information, and
361 * event time is not available for them anyway.
362 *
363 * Use this property if you need to work with historical data coming from files
364 * or from OnDemandService or writing data with times to file via DXPublisher using a "tape:..." address.
365 */
366 static constexpr char DXENDPOINT_EVENT_TIME_PROPERTY[] = "dxendpoint.eventTime";
367
368 /**
369 * `"dxendpoint.storeEverything"`
370 *
371 * Set this property to store all @ref LastingEvent "lasting" and @ref IndexedEvent "indexed" events even when
372 * there is no subscription on them. By default, the endpoint stores only events from subscriptions. It works in
373 * the same way both for DXFeed and DXPublisher.
374 *
375 * Use this property with extreme care,
376 * since API does not currently provide any means to remove those events from the storage, and there might
377 * be an effective memory leak if the spaces of symbols on which events are published grow without a bound.
378 */
379 static constexpr char DXENDPOINT_STORE_EVERYTHING_PROPERTY[] = "dxendpoint.storeEverything";
380
381 /**
382 * `"dxscheme.nanoTime"`
383 *
384 * Set this property to `true` to turn on nanoseconds precision business time.
385 * By default, this feature is turned off.
386 * Business time in most events is available with
387 * millisecond precision by default, while Quote events business @ref Quote::getTime() "time" is available with
388 * seconds precision.
389 *
390 * This method provides a higher-level control than turning on individual properties that are responsible
391 * for nano-time via DXEndpoint::DXSCHEME_ENABLED_PROPERTY_PREFIX. The later can be used to override of fine-time
392 * nano-time support for individual fields. Setting this property to `true` is essentially
393 * equivalent to setting:
394 * ```ini
395 * dxscheme.enabled.Sequence=*
396 * dxscheme.enabled.TimeNanoPart=*
397 * ```
398 */
399 static constexpr char DXSCHEME_NANO_TIME_PROPERTY[] = "dxscheme.nanoTime";
400
401 /**
402 * `"dxscheme.enabled."`
403 *
404 * Defines whether a specified field from the scheme should be enabled instead of its default behavior.
405 * Use it according to the following format:
406 * <b>`dxscheme.enabled.<field_property_name>=<event_name_mask_glob>`</b>
407 *
408 * For example, <b>`dxscheme.enabled.TimeNanoPart=Trade`</b> enables `NanoTimePart` internal field
409 * only in Trade events.
410 *
411 * There is a shortcut for turning on nano-time support using DXEndpoint::DXSCHEME_NANO_TIME_PROPERTY.
412 */
413 static constexpr char DXSCHEME_ENABLED_PROPERTY_PREFIX[] = "dxscheme.enabled.";
414
415 /**
416 * Represents the role of an endpoint that was specified during its @ref DXEndpoint::create() "creation".
417 *
418 * @see DXEndpoint
419 */
420 enum class Role : std::int32_t {
421 /**
422 * `FEED` endpoint connects to the remote data feed provider and is optimized for real-time or
423 * delayed data processing (<b>this is a default role</b>). DXEndpoint::getFeed() method
424 * returns the feed object that subscribes to the remote data feed provider and receives events from it.
425 * When event processing threads cannot keep up (don't have enough CPU time), data is dynamically conflated to
426 * minimize latency between received events and their processing time.
427 *
428 * This endpoint is automatically connected to the configured data feed, as explained in
429 * <a href="#defaultPropertiesSection">the default properties section</a>.
430 */
432
433 /**
434 * `ON_DEMAND_FEED` endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandService
435 * for historical data replay only. It is configured with <a href="#defaultPropertiesSection">default
436 * properties</a>, but is not connected automatically to the data provider until OnDemandService::replay()
437 * method is invoked.
438 *
439 * `ON_DEMAND_FEED` endpoint cannot be connected to an ordinary data feed at all.
440 * OnDemandService::stopAndResume() will have a similar effect to OnDemandService::stopAndClear().
441 *
442 * @see OnDemandService
443 */
445
446 /**
447 * `STREAM_FEED` endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provider,
448 * but is designed for bulk parsing of data from files. DXEndpoint::getFeed() method
449 * returns feed object that subscribes to the data from the opened files and receives events from them.
450 * Events from the files are not conflated, are not skipped, and are processed as fast as possible.
451 * Note that in this role, the DXFeed::getLastEvent method does not work.
452 */
454
455 /**
456 * `PUBLISHER` endpoint connects to the remote publisher hub (also known as multiplexor) or
457 * creates a publisher on the local host. DXEndpoint#getPublisher() method returns
458 * a publisher object that publishes events to all connected feeds.
459 * Note that in this role, the DXFeed::getLastEvent method does not work and
460 * time-series subscription is not supported.
461 *
462 * This endpoint is automatically connected to the configured data feed, as explained in
463 * <a href="#defaultPropertiesSection">the default properties section</a>.
464 */
466
467 /**
468 * `STREAM_PUBLISHER` endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publisher
469 * hub, but is designed for bulk publishing of data. DXEndpoint::getPublisher() method returns a
470 * publisher object that publishes events to all connected feeds. Published events are not conflated, are not
471 * skipped, and are processed as fast as possible. Note that in this role, the DXFeed::getLastEvent method
472 * does not work and time-series subscription is not supported.
473 */
475
476 /**
477 * `LOCAL_HUB` endpoint is a local hub without the ability to establish network connections.
478 * Events that are published via @ref DXEndpoint::getPublisher() "publisher" are delivered to local
479 * @ref DXEndpoint::getFeed() "feed" only.
480 */
482 };
483
484 static std::string roleToString(Role role);
485
486 /**
487 * Represents the current state of endpoint.
488 *
489 * @see DXEndpoint
490 */
491 enum class State : std::int32_t {
492 /**
493 * Endpoint was created by is not connected to remote endpoints.
494 */
496
497 /**
498 * The @ref DXEndpoint::connect(StringParam) "connect" method was called to establish connection to
499 * remove endpoint, but the connection is not established yet or was lost.
500 */
502
503 /**
504 * The connection to the remote endpoint is established.
505 */
507
508 /**
509 * Endpoint was @ref DXEndpoint::close() "closed".
510 */
512 };
513
514 static std::string stateToString(State state);
515
516 private:
517 JavaObjectHandle<DXEndpoint> handle_{};
518 Role role_ = Role::FEED;
519 std::string name_{};
520 JavaObjectHandle<DXEndpointStateChangeListener> stateChangeListenerHandle_{};
521 SimpleHandler<void(State, State)> onStateChange_{"DXEndpoint"};
522
523 // Throws:
524 // - std::bad_alloc if it was not possible to allocate the required amount of memory
525 // - InvalidArgumentException if endpointHandle is nullptr
526 // - JavaException if something happened with the dxFeed API backend
527 // - GraalException if something happened with the GraalVM
528 static std::shared_ptr<DXEndpoint> create(void *endpointHandle, Role role,
529 const std::unordered_map<std::string, std::string> &properties);
530
531 // Returns the on-demand service of this endpoint: one instance, created on the first call.
532 std::shared_ptr<OnDemandService> getOnDemandService();
533
534 // The silence watchdog of a subscription counts the silence only while the endpoint of its feed is connected.
535 friend class DXFeedSubscription;
536
537 // Returns the time of the last transition to CONNECTED, or nothing while the endpoint is not connected.
538 std::optional<std::chrono::steady_clock::time_point> getConnectedSince() const noexcept;
539
540 struct Impl;
541
542 std::unique_ptr<Impl> impl_;
543
544 public:
545 explicit DXEndpoint(LockExternalConstructionTag);
546 DXEndpoint(LockExternalConstructionTag, JavaObjectHandle<DXEndpoint> &&handle, Role role, std::string name);
547
548 ~DXEndpoint() noexcept override;
549
550 /**
551 * Returns a default application-wide singleton instance of DXEndpoint with a @ref Role::FEED "FEED" role.
552 * Most applications use only a single data-source and should rely on this method to get one.
553 * This method creates an endpoint on the first use with a default configuration, as explained in
554 * <a href="#defaultPropertiesSection">the default properties section</a> of DXEndpoint class documentation.
555 * You can provide configuration via system properties as explained there.
556 *
557 * This is a shortcut to
558 * @ref DXEndpoint::getInstance(Role) "getInstance"(@ref DXEndpoint "DXEndpoint"::@ref DXEndpoint::Role "Role"::@ref
559 * DXEndpoint.Role::FEED "FEED").
560 * @see DXEndpoint::getInstance(Role)
561 * @throws InvalidArgumentException
562 * @throws JavaException
563 * @throws GraalException
564 */
565 static std::shared_ptr<DXEndpoint> getInstance();
566
567 /**
568 * Returns a default application-wide singleton instance of DXEndpoint for a specific role.
569 * Most applications use only a single data-source and should rely on this method to get one.
570 * This method creates an endpoint with the corresponding role on the first use with a default configuration, as
571 * explained in <a href="#defaultPropertiesSection">the default properties section</a> of DXEndpoint class
572 * documentation. You can provide configuration via system properties as explained there.
573 *
574 * The configuration does not have to include an address. You can use @ref DXEndpoint::connect(StringParam)
575 * "connect(address)" and DXEndpoint::disconnect() methods on the instance that is returned by this method to
576 * programmatically establish and tear-down connection to a user-provided address.
577 *
578 * If you need a fully programmatic configuration and/or multiple endpoints of the same role in your
579 * application, then create a custom instance of DXEndpoint with DXEndpoint::newBuilder() method, configure it,
580 * and use Builder::build() method.
581 *
582 * @param role The role of DXEndpoint instance
583 * @return The DXEndpoint instance
584 * @throws InvalidArgumentException
585 * @throws JavaException
586 * @throws GraalException
587 */
588 static std::shared_ptr<DXEndpoint> getInstance(Role role);
589
590 class Builder;
591
592 /**
593 * Creates a new Builder instance.
594 * Use Builder::build() to build an instance of DXEndpoint when all configuration properties were set.
595 *
596 * @return the created endpoint builder.
597 * @throws InvalidArgumentException
598 * @throws JavaException
599 * @throws GraalException
600 */
601 static std::shared_ptr<Builder> newBuilder();
602
603 /**
604 * Creates an endpoint with @ref Role::FEED "FEED" role.
605 * The result of this method is the same as <b>`create(DXEndpoint::Role::FEED)`</b>.
606 * This is a shortcut to
607 * @ref DXEndpoint::newBuilder() "newBuilder()"->@ref Builder::build() "build()"
608 *
609 * @return the created endpoint.
610 * @throws InvalidArgumentException
611 * @throws JavaException
612 * @throws GraalException
613 */
614 static std::shared_ptr<DXEndpoint> create();
615
616 /**
617 * Creates an endpoint with a specified role.
618 * This is a shortcut to
619 * @ref DXEndpoint::newBuilder() "newBuilder()"->@ref Builder::withRole(Role) "withRole(role)"->@ref
620 * Builder::build() "build()"
621 *
622 * @param role the role.
623 * @return the created endpoint.
624 * @throws InvalidArgumentException
625 * @throws JavaException
626 * @throws GraalException
627 */
628 static std::shared_ptr<DXEndpoint> create(Role role);
629
630 /**
631 * Returns the role of this endpoint.
632 *
633 * @return the role.
634 *
635 * @see DXEndpoint
636 */
637 Role getRole() const noexcept;
638
639 /**
640 * Returns the state of this endpoint.
641 *
642 * @return the state.
643 *
644 * @see DXEndpoint
645 * @throws InvalidArgumentException
646 * @throws JavaException
647 * @throws GraalException
648 */
649 State getState() const;
650
651 /**
652 * @return `true` if the endpoint is closed
653 * @throws InvalidArgumentException
654 * @throws JavaException
655 * @throws GraalException
656 */
657 bool isClosed() const;
658
659 /**
660 * @return The user defined endpoint's name
661 */
662 const std::string &getName() const & noexcept;
663
664 /**
665 * Adds a listener notified about changes in @ref DXEndpoint::getState() "state" property.
666 *
667 * <p>Installed listener can be removed by `id` with DXEndpoint::removeStateChangeListener method or by call
668 * `::onStateChange() -= id`;
669 *
670 * @param listener The listener to add
671 * @return the listener id
672 */
673 std::size_t addStateChangeListener(std::function<void(State, State)> listener) noexcept {
674 return onStateChange_ += std::move(listener);
675 }
676
677 /**
678 * Removes a listener notified about changes in @ref DXEndpoint::getState() "state" property.
679 * It removes the listener previously installed with DXEndpoint::addStateChangeListener method.
680 *
681 * @param listenerId The listener id to remove
682 */
683 void removeStateChangeListener(std::size_t listenerId) noexcept;
684
685 /**
686 * Returns the onStateChange @ref SimpleHandler "handler" that can be used to add or remove
687 * listeners.
688 *
689 * @return onStateChange handler with `void(State, State)` signature
690 */
692
693 /**
694 * Returns the last connection error of this endpoint: the newest failed connect attempt or dropped connection of
695 * all its connectors.
696 *
697 * A successful connection clears nothing: the time of the error tells how old it is. The error stays after a
698 * connect to another address and after the endpoint is closed.
699 *
700 * Read the error in a @ref DXEndpoint::addMessageConnectorListener() "connector listener": the error is recorded
701 * before that listener is called. A @ref DXEndpoint::addStateChangeListener() "state change listener" gives no such
702 * order (the state of the endpoint is computed on another thread, so the listener may be called before the error
703 * of that change is recorded), and failed connect attempts do not change the state of the endpoint at all: it stays
704 * @ref State::CONNECTING "CONNECTING" between them. There, compare the time or the count of the error with those
705 * seen before. See @ref connection_troubleshooting "Connection troubleshooting".
706 *
707 * This is an experimental API, it may change in future versions.
708 *
709 * @return The last connection error, or `std::nullopt` when the endpoint has had none.
710 * @throws JavaException if something happened with the dxFeed API backend.
711 * @throws GraalException if something happened with the GraalVM, or the dxFeed Graal Native SDK library does not
712 * match the one the library was built with.
713 */
715
716 /**
717 * Returns the snapshots of the message connectors of this endpoint: one for each address it connects to.
718 *
719 * The list is empty when the endpoint is not connected, has the @ref Role::LOCAL_HUB "LOCAL_HUB" role, or is
720 * closed. Each call reads the connectors anew; the values of a snapshot are read one by one (see
721 * MessageConnectorInfo). See @ref connection_troubleshooting "Connection troubleshooting".
722 *
723 * This is an experimental API, it may change in future versions.
724 *
725 * @return The snapshots of the connectors.
726 * @throws JavaException if something happened with the dxFeed API backend.
727 * @throws GraalException if something happened with the GraalVM, or the dxFeed Graal Native SDK library does not
728 * match the one the library was built with.
729 */
731
732 /**
733 * Adds a listener called after the state of a message connector of this endpoint changes, with a snapshot of that
734 * connector taken at the call.
735 *
736 * The listener is called on one thread of the dxFeed Graal Native SDK for all the endpoints, not on the executor of
737 * the endpoint, one call at a time, never inside DXEndpoint::connect(); it should return quickly, since the next call
738 * waits for it. The connection error of a change is recorded before the call, so
739 * MessageConnectorInfo::lastError and DXEndpoint::getLastConnectionError() already return it. Fast changes of one
740 * connector may come as one call, and the first call for a new connector may read
741 * @ref MessageConnectorInfo::State::DISCONNECTED "DISCONNECTED" before a later one reads
742 * @ref MessageConnectorInfo::State::CONNECTING "CONNECTING". The current states are not passed to a listener when
743 * it is added: call DXEndpoint::getConnectors() after adding it. An exception of the listener is reported to
744 * ErrorManager. Once the endpoint is closed no new call starts and the listeners are removed. DXEndpoint::close()
745 * may wait for a call in progress, so the listener must not wait for the thread that closes the endpoint; the call
746 * may also end after DXEndpoint::close() returns.
747 *
748 * The first call registers a listener of the endpoint in the dxFeed Graal Native SDK, so it can fail.
749 *
750 * This is an experimental API, it may change in future versions.
751 *
752 * @param listener The listener to add.
753 * @return The listener id, for DXEndpoint::removeMessageConnectorListener().
754 * @throws JavaException if something happened with the dxFeed API backend.
755 * @throws GraalException if something happened with the GraalVM, or the dxFeed Graal Native SDK library does not
756 * match the one the library was built with.
757 */
758 std::size_t addMessageConnectorListener(std::function<void(const MessageConnectorInfo &)> listener);
759
760 /**
761 * Removes a listener added with DXEndpoint::addMessageConnectorListener(). Outside a listener of the library, waits
762 * for the calls of the listener in progress on the other threads.
763 *
764 * This is an experimental API, it may change in future versions.
765 *
766 * @param listenerId The listener id.
767 */
768 void removeMessageConnectorListener(std::size_t listenerId) noexcept;
769
770 /**
771 * Changes username for this endpoint.
772 * This method shall be called before @ref DXEndpoint::connect(StringParam) "connect"
773 * with @ref DXEndpoint::password(StringParam) "password" to configure service access credentials.
774 *
775 * @param user The username.
776 *
777 * @return this DXEndpoint.
778 * @throws InvalidArgumentException if the username is not valid UTF-8 (the message names the offset, not the
779 * bytes).
780 * @throws JavaException
781 * @throws GraalException
782 */
783 std::shared_ptr<DXEndpoint> user(StringParam user);
784
785 /**
786 * Changes password for this endpoint.
787 * This method shall be called before @ref DXEndpoint::connect(StringParam) "connect"
788 * with @ref DXEndpoint::user(StringParam) "user" to configure service access credentials.
789 *
790 * @param password The password.
791 *
792 * @return this DXEndpoint.
793 * @throws InvalidArgumentException if the password is not valid UTF-8 (the message names the offset, not the
794 * bytes).
795 * @throws JavaException
796 * @throws GraalException
797 */
798 std::shared_ptr<DXEndpoint> password(StringParam password);
799
800 /**
801 * Connects to the specified remote address. Previously established connections are closed if
802 * the new address is different from the old one.
803 * This method does nothing if the address does not change or if this endpoint is @ref State::CLOSED "CLOSED".
804 * The endpoint @ref DXEndpoint::getState() "state" immediately becomes @ref State::CONNECTING "CONNECTING"
805 * otherwise.
806 *
807 * <p> The address string is provided with the market data vendor agreement.
808 * Use "demo.dxfeed.com:7300" for a demo quote feed.
809 *
810 * <p> The simplest address strings have the following format:
811 * * `host:port` to establish a TCP/IP connection.
812 * * `:port` to listen for a TCP/IP connection with a plain socket connector (good for up to a
813 * few hundred of connections).
814 * * `host:port[login=entitle:token]` to log in with a token.
815 * * `dxlink:wss://host/path[login=dxlink:token]` to connect to dxLink (an experimental feature of the SDK).
816 *
817 * <p>An address that starts with `http://`, `https://`, `ws://` or `wss://` is not an address of an endpoint
818 * (for example, the URLs of REST, CometD and IPF services): such an address throws InvalidArgumentException before
819 * the SDK is called. A QD configuration URL `http(s)://host/path/<name>.config#<name>` is passed to the SDK.
820 *
821 * <p>For premium services access credentials must be configured before invocation of `connect` method
822 * using @ref user(StringParam) "user" and @ref password(StringParam) "password" methods.
823 *
824 * <p> <b>This method does not wait until the connection actually gets established</b>. The actual connection
825 * establishment happens asynchronously after the invocation of this method. However, this method waits until
826 * notification about state transition from State::NOT_CONNECTED to State::CONNECTING gets processed by all
827 * listeners.
828 *
829 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#connect-java.lang.String-)
830 *
831 * @param address The data source address.
832 * @return this DXEndpoint.
833 *
834 * @throws InvalidArgumentException if the address is not valid UTF-8, for example
835 * `DXEndpoint::connect(address): invalid UTF-8 at byte 12: 0xC3 0x28`, or if it is an `http(s)://` or `ws(s)://`
836 * URL; the message names the expected form of the address and does not repeat the address.
837 * @throws JavaException if something happened with the dxFeed API backend or if the address string is malformed.
838 * @throws GraalException
839 */
840 std::shared_ptr<DXEndpoint> connect(StringParam address);
841
842 /**
843 * Terminates all established network connections and initiates connecting again with the same address.
844 *
845 * <p>The effect of the method is alike to invoking ::disconnect() and ::connect(StringParam)
846 * with the current address, but internal resources used for connections may be reused by implementation.
847 * TCP connections with multiple target addresses will try to switch to an alternative address, configured
848 * reconnect timeouts will apply.
849 *
850 * <p><b>Note:</b> The method will not connect an endpoint that was not initially connected with
851 * ::connect(StringParam) method or was disconnected with ::disconnect() method.
852 *
853 * <p>The method initiates a short-pathway for reconnecting, so whether observers will have a chance to see
854 * an intermediate state State#NOT_CONNECTED depends on the implementation.
855 *
856 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#reconnect--)
857 *
858 * @throws InvalidArgumentException
859 * @throws JavaException
860 * @throws GraalException
861 */
862 void reconnect() const;
863
864 /**
865 * Terminates all remote network connections.
866 * This method does nothing if this endpoint is @ref State#CLOSED "CLOSED".
867 * The endpoint @ref getState() "state" immediately becomes @ref State::NOT_CONNECTED "NOT_CONNECTED" otherwise.
868 *
869 * <p>This method does not release all resources that are associated with this endpoint.
870 * Use ::close() method to release all resources.
871 *
872 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#disconnect--)
873 *
874 * @throws InvalidArgumentException
875 * @throws JavaException
876 * @throws GraalException
877 */
878 void disconnect() const;
879
880 /**
881 * Terminates all remote network connections and clears stored data.
882 * This method does nothing if this endpoint is @ref State::CLOSED "CLOSED".
883 * The endpoint @ref getState() "state" immediately becomes @ref State::NOT_CONNECTED "NOT_CONNECTED" otherwise.
884 *
885 * <p>This method does not release all resources that are associated with this endpoint.
886 * Use the close() method to release all resources.
887 *
888 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#disconnectAndClear--)
889 *
890 * @throws InvalidArgumentException
891 * @throws JavaException
892 * @throws GraalException
893 */
894 void disconnectAndClear() const;
895
896 /**
897 * Closes this endpoint. All network connections are terminated as with the ::disconnect() method, and no further
898 * connections can be established.
899 *
900 * The endpoint @ref getState() "state" immediately becomes @ref State::CLOSED "CLOSED".
901 * All resources associated with this endpoint are released.
902 * A created endpoint lives until it is closed: see @ref entity_lifetime "Lifetime of the entities" and AutoClose.
903 *
904 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#close--)
905 *
906 * @throws InvalidArgumentException
907 * @throws JavaException
908 * @throws GraalException
909 */
910 void close() const;
911
912 /**
913 * Waits while this endpoint @ref getState() "state" becomes @ref State::NOT_CONNECTED "NOT_CONNECTED" or
914 * @ref State::CLOSED "CLOSED". It is a signal that any files opened with the
915 * @ref connect(StringParam) "connect(\"file:...\")" method were finished reading, but not necessarily were
916 * completely processed by the corresponding subscription listeners. Use closeAndAwaitTermination() after this
917 * method returns to make sure that all processing has completed.
918 *
919 * <p><b>This method is blocking.</b>
920 *
921 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitNotConnected--)
922 *
923 * @throws InvalidArgumentException
924 * @throws JavaException
925 * @throws GraalException
926 */
927 void awaitNotConnected() const;
928
929 /**
930 * Waits until this endpoint stops processing data (becomes quiescent).
931 * This is important when writing data to file via "tape:..." connector to make sure that
932 * all published data was written before closing this endpoint.
933 *
934 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#awaitProcessed--)
935 *
936 * @throws InvalidArgumentException
937 * @throws JavaException
938 * @throws GraalException
939 */
940 void awaitProcessed() const;
941
942 /**
943 * Closes this endpoint and wait until all pending data processing tasks are completed.
944 * This method performs the same actions as ::close(), but also awaits
945 * termination of all outstanding data processing tasks. It is designed to be used
946 * with @ref Role::STREAM_FEED "STREAM_FEED" role after ::awaitNotConnected() method returns
947 * to make sure that the file was completely processed.
948 *
949 * <p><b>This method is blocking.</b>
950 *
951 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#closeAndAwaitTermination--)
952 *
953 * @throws InvalidArgumentException
954 * @throws JavaException
955 * @throws GraalException
956 */
957 void closeAndAwaitTermination() const;
958
959 std::unordered_set<EventTypeEnum> getEventTypes() const;
960
961 /**
962 * @return The feed that is associated with this endpoint.
963 * @throws InvalidArgumentException
964 * @throws JavaException
965 * @throws GraalException
966 */
967 std::shared_ptr<DXFeed> getFeed() const;
968
969 /**
970 * @return The publisher that is associated with this endpoint.
971 * @throws InvalidArgumentException
972 * @throws JavaException
973 * @throws GraalException
974 */
975 std::shared_ptr<DXPublisher> getPublisher() const;
976
977 /**
978 * Returns the aggregation period that this endpoint requests from the server, or an empty value if no period is
979 * requested.
980 *
981 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#getRequestedAggregationPeriod--)
982 *
983 * @return The requested aggregation period or `std::nullopt`.
984 * @throws InvalidArgumentException
985 * @throws JavaException
986 * @throws GraalException
987 */
989
990 /**
991 * Sets the aggregation period that this endpoint requests from the server.
992 *
993 * The server applies the period on its side, reducing the network traffic and the load of the server and the
994 * client, and may adjust it by its own rules and limits: getAggregationPeriodInfo() returns the period in effect.
995 * TimePeriod::ZERO requests real-time delivery (no aggregation). The period can also be requested with the
996 * DXEndpoint::DXFEED_REQUESTED_AGGREGATION_PERIOD_PROPERTY property.
997 *
998 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#setRequestedAggregationPeriod-com.devexperts.util.TimePeriod-)
999 *
1000 * @param requestedAggregationPeriod The requested aggregation period. It must not exceed 24 hours.
1001 * @throws InvalidArgumentException
1002 * @throws JavaException "IllegalArgumentException" if the period exceeds 24 hours.
1003 * @throws GraalException
1004 */
1005 void setRequestedAggregationPeriod(const TimePeriod &requestedAggregationPeriod) const;
1006
1007 /**
1008 * Sets the aggregation period that this endpoint requests from the server.
1009 * See setRequestedAggregationPeriod(const TimePeriod &) const.
1010 *
1011 * @param requestedAggregationPeriod The requested aggregation period. It must not be negative or exceed 24 hours.
1012 * @throws InvalidArgumentException
1013 * @throws JavaException "IllegalArgumentException" if the period is negative or exceeds 24 hours.
1014 * @throws GraalException
1015 */
1016 void setRequestedAggregationPeriod(std::chrono::milliseconds requestedAggregationPeriod) const;
1017
1018 /**
1019 * Sets the aggregation period that this endpoint requests from the server.
1020 * See setRequestedAggregationPeriod(const TimePeriod &) const.
1021 *
1022 * @param requestedAggregationPeriod The requested aggregation period in milliseconds. It must not be negative or
1023 * exceed 24 hours (86400000).
1024 * @throws InvalidArgumentException
1025 * @throws JavaException "IllegalArgumentException" if the period is negative or exceeds 24 hours.
1026 * @throws GraalException
1027 */
1028 void setRequestedAggregationPeriod(std::int64_t requestedAggregationPeriod) const;
1029
1030 /**
1031 * Clears the aggregation period that this endpoint requests from the server: the server falls back to its default
1032 * period. The same as `setRequestedAggregationPeriod(null)` in Java.
1033 *
1034 * ```cpp
1035 * endpoint->setRequestedAggregationPeriod(std::nullopt);
1036 * ```
1037 *
1038 * @throws InvalidArgumentException
1039 * @throws JavaException
1040 * @throws GraalException
1041 */
1043
1044 /**
1045 * Returns the aggregation period that the servers report, over all connections of this endpoint.
1046 *
1047 * The servers report the period when a connection is established, so the result is TimePeriodInfo::UNKNOWN until
1048 * then, and also when no server reports it (for example, without connections or with an older server). The
1049 * period applied to the events of a subscription is returned by DXFeedSubscription::getAggregationPeriodInfo().
1050 *
1051 * [Javadoc.](https://docs.dxfeed.com/dxfeed/api/com/dxfeed/api/DXEndpoint.html#getAggregationPeriodInfo--)
1052 *
1053 * @return The aggregation period info reported by the servers, or TimePeriodInfo::UNKNOWN.
1054 * @throws InvalidArgumentException
1055 * @throws JavaException
1056 * @throws GraalException
1057 */
1059
1060 /**
1061 * Builder class for DXEndpoint that supports additional configuration properties.
1062 *
1063 * Some methods that are not marked `noexcept` may throw exceptions:
1064 *
1065 * @throws InvalidArgumentException if the handle is invalid.
1066 * @throws JavaException if something happened with the dxFeed API backend
1067 * @throws GraalException if something happened with the GraalVM
1068 */
1070 friend DXEndpoint;
1071
1072 JavaObjectHandle<Builder> handle_{};
1073 Role role_ = Role::FEED;
1074 std::unordered_map<std::string, std::string> properties_{};
1075
1076 // Throws:
1077 // - std::bad_alloc if it was not possible to allocate the required amount of memory
1078 // - JavaException if something happened with the dxFeed API backend
1079 // - GraalException if something happened with the GraalVM
1080 static std::shared_ptr<Builder> create();
1081
1082 void withExecutorImpl(const JavaObjectHandle<ExecutorTag> &executor) const;
1083
1084 /**
1085 * Tries to load the default properties file for Role::FEED, Role::ON_DEMAND_FEED, or Role::PUBLISHER role.
1086 *
1087 * The default properties file is loaded only if there are no system properties or user properties set with the
1088 * same key, and the file itself exists and is readable.
1089 *
1090 * This file must be in the <a href="https://en.wikipedia.org/wiki/.properties">Java properties file format</a>.
1091 * File be named "dxfeed.properties" for Role::FEED and Role::ON_DEMAND_FEED roles
1092 * or "dxpublisher.properties" for the Role::PUBLISHER role.
1093 *
1094 * Not thread-safe.
1095 * @throws InvalidArgumentException
1096 * @throws JavaException
1097 * @throws GraalException
1098 */
1099 void loadDefaultPropertiesImpl();
1100
1101 public:
1102 explicit Builder(LockExternalConstructionTag) noexcept;
1103
1104 /// Releases the GraalVM handle
1105 ~Builder() noexcept override;
1106
1107 /**
1108 * Changes the name used to distinguish multiple endpoints
1109 * in the same process (GraalVM Isolate) in logs and in other diagnostic means.
1110 * This is a shortcut for @ref withProperty "withProperty"(::NAME_PROPERTY, `name`)
1111 *
1112 * @param name The endpoint's name
1113 *
1114 * @return `this` endpoint builder.
1115 * @throws InvalidArgumentException
1116 * @throws JavaException
1117 * @throws GraalException
1118 */
1119 std::shared_ptr<Builder> withName(StringParam name);
1120
1121 /**
1122 * Sets role for the created DXEndpoint.
1123 * The default role is @ref Role::FEED "FEED".
1124 *
1125 * @param role The endpoint's role
1126 *
1127 * @return `this` endpoint builder.
1128 * @throws InvalidArgumentException
1129 * @throws JavaException
1130 * @throws GraalException
1131 */
1132 std::shared_ptr<Builder> withRole(Role role);
1133
1134 /**
1135 * Sets the specified property. Unsupported properties are ignored.
1136 *
1137 * @param key The endpoint's property key
1138 * @param value The endpoint's property value
1139 * @return `this` endpoint builder.
1140 *
1141 * @see ::supportsProperty(StringParam)
1142 * @throws InvalidArgumentException
1143 * @throws JavaException
1144 * @throws GraalException
1145 */
1146 std::shared_ptr<Builder> withProperty(StringParam key, StringParam value);
1147
1148 /**
1149 * Sets all supported properties from the provided properties object.
1150 *
1151 * @tparam Properties The properties' type (std::map, std::unordered_map, etc.)
1152 * @param properties The endpoint's properties
1153 * @return `this` endpoint builder.
1154 *
1155 * @see ::withProperty(StringParam, StringParam)
1156 * @throws InvalidArgumentException
1157 * @throws JavaException
1158 * @throws GraalException
1159 */
1160 template <typename Properties> std::shared_ptr<Builder> withProperties(Properties &&properties) {
1161 for (auto &&[k, v] : properties) {
1162 withProperty(k, v);
1163 }
1164
1165 return sharedAs<Builder>();
1166 }
1167
1168 /**
1169 * Checks if a property is supported
1170 *
1171 * @param key The property's key to be checked for support
1172 * @return `true` if the corresponding property key is supported.
1173 *
1174 * @see ::withProperty(StringParam, StringParam)
1175 * @throws InvalidArgumentException
1176 * @throws JavaException
1177 * @throws GraalException
1178 */
1179 bool supportsProperty(StringParam key) const;
1180
1181 /**
1182 * Sets the executor that is used for notifications (events, state changes, etc.) of the endpoint to build.
1183 * By default, the endpoint uses a thread pool whose size is set by the
1184 * DXEndpoint::DXFEED_THREAD_POOL_SIZE_PROPERTY or DXEndpoint::DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY
1185 * property.
1186 *
1187 * @tparam Executor The executor's type (for example, InPlaceExecutor).
1188 * @param executor The executor.
1189 * @return `this` endpoint builder.
1190 * @throws InvalidArgumentException
1191 * @throws JavaException
1192 * @throws GraalException
1193 */
1194 template <typename Executor> std::shared_ptr<Builder> withExecutor(const std::shared_ptr<Executor> &executor) {
1195 withExecutorImpl(executor->getHandle());
1196
1197 return sharedAs<Builder>();
1198 }
1199
1200 /**
1201 * Builds DXEndpoint instance.
1202 *
1203 * @return the created endpoint.
1204 * @throws InvalidArgumentException
1205 * @throws JavaException
1206 * @throws GraalException
1207 */
1208 std::shared_ptr<DXEndpoint> build();
1209 };
1210
1211 std::string toString() const override;
1212};
1213
1214DXFCPP_END_NAMESPACE
1215
1216/// @}
1217
1218template <typename OS> OS &operator<<(OS &os, dxfcpp::DXEndpoint::State state) {
1219 os << dxfcpp::DXEndpoint::stateToString(state);
1220
1221 return os;
1222}
1223
1224DXFCXX_DISABLE_MSC_WARNINGS_POP()
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builderHandle, const char *name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:1125
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, const dxfc_dxendpoint_property_t **properties, size_t size)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.cpp:1168
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:1451
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1652
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, DXFC_OUT int *supports)
Checks if a property is supported.
Definition DXEndpoint.cpp:1200
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds a listener notified about changes in state property.
Definition DXEndpoint.cpp:1598
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1513
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:219
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint)
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:1395
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint)
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:1564
void(*) dxfc_dxendpoint_state_change_listener(dxfc_dxendpoint_state_t old_state, dxfc_dxendpoint_state_t new_state, void *user_data)
The endpoint current state change listener.
Definition api.h:190
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:161
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:181
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:165
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but the connection is not...
Definition api.h:171
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the remote endpoint is established.
Definition api.h:176
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of dxFeed endpoint with a FEED role.
Definition DXEndpoint.cpp:1264
#define DXFC_OUT
Definition api.h:17
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state)
Returns the state of this endpoint.
Definition DXEndpoint.cpp:1581
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:210
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, const char *value)
Sets the specified property.
Definition DXEndpoint.cpp:1146
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:1252
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:1473
dxfc_error_code_t
List of error codes.
Definition api.h:61
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:72
@ DXFC_EC_SUCCESS
OK.
Definition api.h:65
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:69
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:1624
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value)
Sets the system property indicated by the specified key.
Definition System.cpp:208
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Builds the new dxFeed endpoint instance.
Definition DXEndpoint.cpp:1222
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1647
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint)
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:1547
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:1378
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates a new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:1087
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint)
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:1496
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role)
Returns the role of this endpoint.
Definition DXEndpoint.cpp:1412
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:1429
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size)
Gets the system property indicated by the specified key.
dxfc_dxendpoint_role_t
Represents the role of an endpoint that was specified during its creation.
Definition api.h:101
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:139
@ DXFC_DXENDPOINT_ROLE_STREAM_FEED
STREAM_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data fee...
Definition api.h:128
@ DXFC_DXENDPOINT_ROLE_FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition api.h:111
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:148
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition api.h:155
@ DXFC_DXENDPOINT_ROLE_ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with d...
Definition api.h:119
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:229
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:1321
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:1292
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:224
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role)
Sets role for the created dxFeed endpoint.
Definition DXEndpoint.cpp:1108
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:1349
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1657
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:1530
T & operator*() const noexcept
Definition AutoClose.hpp:173
AutoClose() noexcept=default
Creates an empty AutoClose.
AutoClose(std::shared_ptr< T > entity) noexcept
Creates an AutoClose that closes the entity.
Definition AutoClose.hpp:119
~AutoClose() noexcept
Closes the entity.
Definition AutoClose.hpp:140
const std::shared_ptr< T > & get() const noexcept
Definition AutoClose.hpp:163
std::shared_ptr< T > release() noexcept
Makes this AutoClose empty without closing the entity.
Definition AutoClose.hpp:158
AutoClose & operator=(AutoClose &&other) noexcept
Closes the current entity and takes the entity of the other AutoClose, which becomes empty.
Definition AutoClose.hpp:130
operator bool() const noexcept
Definition AutoClose.hpp:178
AutoClose(AutoClose &&other) noexcept
Takes the entity of the other AutoClose, which becomes empty.
Definition AutoClose.hpp:126
T * operator->() const noexcept
Definition AutoClose.hpp:168
void reset() noexcept
Closes the entity now and makes this AutoClose empty.
Definition AutoClose.hpp:145
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:1069
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:695
std::shared_ptr< Builder > withExecutor(const std::shared_ptr< Executor > &executor)
Sets the executor that is used for notifications (events, state changes, etc.) of the endpoint to bui...
Definition DXEndpoint.hpp:1194
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:1160
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:733
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:647
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:189
void removeMessageConnectorListener(std::size_t listenerId) noexcept
Removes a listener added with DXEndpoint::addMessageConnectorListener().
Definition DXEndpoint.cpp:946
bool isClosed() const
Definition DXEndpoint.cpp:901
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:918
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:888
void setRequestedAggregationPeriod(const TimePeriod &requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:568
static constexpr char DXFEED_AGGREGATION_PERIOD_PROPERTY[]
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:279
static constexpr char DXENDPOINT_EVENT_TIME_PROPERTY[]
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:366
void setRequestedAggregationPeriod(std::chrono::milliseconds requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:573
static constexpr char NAME_PROPERTY[]
"name"
Definition DXEndpoint.hpp:206
static constexpr char DXFEED_PASSWORD_PROPERTY[]
"dxfeed.password"
Definition DXEndpoint.hpp:260
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:528
static constexpr char DXSCHEME_NANO_TIME_PROPERTY[]
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:399
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:491
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:511
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:501
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:506
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:495
static constexpr char DXFEED_THREAD_POOL_SIZE_PROPERTY[]
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:269
TimePeriodInfo getAggregationPeriodInfo() const
Returns the aggregation period that the servers report, over all connections of this endpoint.
Definition DXEndpoint.cpp:586
static constexpr char DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY[]
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:349
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:473
std::shared_ptr< DXEndpoint > Ptr
The alias to a type of shared pointer to the DXEndpoint object.
Definition DXEndpoint.hpp:191
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:879
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:909
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:905
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:420
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:465
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:453
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:481
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:444
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:474
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:431
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:754
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:509
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:537
static constexpr char DXFEED_PROPERTIES_PROPERTY[]
"dxfeed.properties"
Definition DXEndpoint.hpp:221
std::optional< TimePeriod > getRequestedAggregationPeriod() const
Returns the aggregation period that this endpoint requests from the server, or an empty value if no p...
Definition DXEndpoint.cpp:556
static constexpr char DXSCHEME_ENABLED_PROPERTY_PREFIX[]
"dxscheme.enabled."
Definition DXEndpoint.hpp:413
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:433
static constexpr char DXPUBLISHER_ADDRESS_PROPERTY[]
"dxpublisher.address"
Definition DXEndpoint.hpp:340
std::vector< MessageConnectorInfo > getConnectors() const
Returns the snapshots of the message connectors of this endpoint: one for each address it connects to...
Definition DXEndpoint.cpp:926
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:500
static constexpr char DXFEED_STRIPE_PROPERTY[]
"dxfeed.stripe"
Definition DXEndpoint.hpp:296
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:861
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:956
static constexpr char DXFEED_REQUESTED_AGGREGATION_PERIOD_PROPERTY[]
"dxfeed.requestedAggregationPeriod"
Definition DXEndpoint.hpp:321
void setRequestedAggregationPeriod(std::int64_t requestedAggregationPeriod) const
Sets the aggregation period that this endpoint requests from the server.
Definition DXEndpoint.cpp:577
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:482
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:518
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:852
static constexpr char DXPUBLISHER_PROPERTIES_PROPERTY[]
"dxpublisher.properties"
Definition DXEndpoint.hpp:330
static constexpr char DXFEED_WILDCARD_ENABLE_PROPERTY[]
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:288
static constexpr char DXFEED_ADDRESS_PROPERTY[]
"dxfeed.address"
Definition DXEndpoint.hpp:240
static constexpr char DXFEED_STICKY_SUBSCRIPTION_PROPERTY[]
"dxfeed.stickySubscriptionPeriod"
Definition DXEndpoint.hpp:304
static constexpr char DXFEED_USER_PROPERTY[]
"dxfeed.user"
Definition DXEndpoint.hpp:250
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:491
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:897
std::optional< ConnectionError > getLastConnectionError() const
Returns the last connection error of this endpoint: the newest failed connect attempt or dropped conn...
Definition DXEndpoint.cpp:922
static constexpr char DXENDPOINT_STORE_EVERYTHING_PROPERTY[]
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:379
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:870
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:142
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:62
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:42
std::string toString() const override
Returns a string representation of the current object.
Definition api.cpp:57
virtual std::int64_t getEventTime() const noexcept
Returns time when an event was created or zero when time is not available.
Definition api.cpp:44
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition api.cpp:53
virtual void setEventTime(std::int64_t eventTime) noexcept
Changes event creation time.
Definition api.cpp:48
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:77
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
A thread-safe list of listeners with a given signature.
Definition Handler.hpp:63
Immutable value class for a range of time periods: the minimum and the maximum period in milliseconds...
Definition TimePeriodInfo.hpp:30
Value class for a period of time with support for ISO8601 duration format.
Definition TimePeriod.hpp:29
The simple key-value structure that represents an endpoint's property.
Definition api.h:196
const char * key
The property's key.
Definition api.h:198
const char * value
The property's value.
Definition api.h:200