dxFeed Graal CXX API v9.0.0
Loading...
Searching...
No Matches
ErrorManager.hpp
1// Copyright (c) 2026 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/StringParam.hpp"
11
12#include <cstddef>
13#include <cstdint>
14#include <exception>
15#include <functional>
16#include <optional>
17#include <source_location>
18#include <string>
19#include <vector>
20
21/**
22 * @page error_handling Error handling
23 *
24 * The library reports an error through one of two channels.
25 *
26 * - **A call that fails** throws an exception to its caller: JavaException when the Java code of the dxFeed Graal
27 * SDK throws, GraalException when the call cannot enter the isolate, InvalidArgumentException, RuntimeException.
28 * The Java exception belongs to the call that failed, a later call does not get it, even when the failure is
29 * reported by a result (System::setProperty() returns `false`). When an SDK function that has no null result returns
30 * null without a Java exception, the call throws RuntimeException.
31 * - **An error without a caller** goes to ErrorManager. Such an error happens in the code that the library runs on
32 * its own: a callback of the dxFeed Graal SDK (events of a subscription, a state change of an endpoint or of an
33 * instrument profile connection, a change of a subscription, instrument profiles of a collector, the events of a
34 * model). An exception of that code would otherwise terminate the process, and the caller's thread could not see
35 * it anyway: the callback runs on a thread of the SDK.
36 * - **A release that fails** goes to ErrorManager as well: a destructor or a function that frees the native data of
37 * the SDK (for example, the destructor of a subscription or of a model that closes it) does not throw. From the
38 * start of the shutdown of the library (dxfcpp::shutdown(), the exit of the process) a failure of a release is not
39 * reported: the SDK is being closed or is closed already.
40 * - **A failed creation of the Graal isolate** (an invalid argument of System::setIsolateArguments() or of the
41 * `DXFCPP_ISOLATE_ARGUMENTS` environment variable, see @ref isolate_arguments "Isolate arguments") is reported to the
42 * caller of the first call that needs Java and of every next one: GraalException with the numeric code, its text and
43 * the reason. The library does not try to create the isolate again. System::getProperty() and System::setProperty()
44 * throw it too, instead of returning an empty string or `false`; the functions of the C API return `DXFC_EC_ERROR`.
45 * The messages never contain the values of the arguments.
46 * - **A warning** is reported from inside a call that goes on (for example, a `fromTime` in the future given to a
47 * TimeSeriesTxModel, a candle symbol string without a period given to CandleSymbol::valueOf(), see
48 * @ref candle_symbols "Candle symbols"; a slow listener of a subscription, see
49 * @ref listener_threads "Listeners and threads"; a subscription without events while its endpoint is connected,
50 * when its silence watchdog is on, see DXFeedSubscription::setSilenceWatchdog()): the call does not throw and does
51 * not change its result. The
52 * library reports it with ErrorManager::reportWarning(), and it has the level ErrorInfo::Level::WARN, while the
53 * errors have ErrorInfo::Level::ERROR (ErrorInfo::level). A warning shares the handler, the journal and
54 * ErrorManager::getLastError() with the errors.
55 * - **An INFO message** (ErrorInfo::Level::INFO) is not a problem: the library reports it on its own, once per process,
56 * when the first endpoint is created (DXEndpoint::create(), DXEndpoint::Builder::build(), DXEndpoint::getInstance(),
57 * DXFeed::getInstance(), DXPublisher::getInstance()). It names the versions of the dxFeed Graal C++ API and of the
58 * dxFeed Graal Native SDK and the platform, the first thing to send to the support:
59 * `[dxfcpp] INFO #1 DXEndpoint: dxFeed Graal C++ API v9.0.0, dxFeed Graal Native SDK 3.18.0, Windows x86_64(16 cores)`. The version of QD follows in the log of the SDK: `Using QDS-<version>, (C) Devexperts`.
60 *
61 * ErrorManager passes each error, warning and INFO message to the handler and keeps the last ones in a journal:
62 *
63 * - The default handler writes one line per error to `stderr`; a warning is marked with `WARN ` before its number,
64 * an INFO message with `INFO `: `[dxfcpp] WARN #7 Component (File.cpp:42): message`. ErrorManager::setHandler()
65 * replaces it, a null handler turns the output off, ErrorManager::resetHandler() restores the default one. A
66 * handler that logs the errors may check ErrorInfo::level to log the INFO messages at a lower level.
67 * - The handler is called on the thread where the error happened, without the locks of ErrorManager held: it may
68 * read the journal and change the handler. Errors of several threads call it at the same time, so it must be
69 * thread-safe. Keep it short, it delays the thread that reported the error (for example, the delivery of the
70 * events of a subscription). An exception of the handler is ignored; an error reported from inside the handler
71 * goes to the journal only.
72 * - The journal keeps the last ErrorManager::getCapacity() errors (ErrorManager::DEFAULT_CAPACITY by default):
73 * ErrorManager::getErrors(), ErrorManager::getLastError(), ErrorManager::clearErrors().
74 *
75 * Events of the types that the C++ API does not implement (for example, EventTypeEnum::CONFIGURATION) are skipped
76 * in the event callbacks: the other events of the batch are delivered, and one error per type and batch is reported
77 * with the number of the skipped events. A listener of a subscription is not called when all the events of a batch
78 * are skipped.
79 *
80 * ErrorManager works during the exit of the process and after dxfcpp::shutdown(): it is never destroyed and does not
81 * call the SDK. The handler can be called at exit from a thread of the SDK while the static objects of the program
82 * are being destroyed, as the listeners can (see dxfcpp::shutdown()).
83 *
84 * ```cpp
85 * dxfcpp::ErrorManager::setHandler([](const dxfcpp::ErrorInfo &error) {
86 * myLogger.error(error.toString());
87 * });
88 * ```
89 */
90
91/**
92 * \addtogroup dxfcpp_exceptions
93 * @{
94 */
95
96DXFCPP_BEGIN_NAMESPACE
97
98/**
99 * An error without a caller, reported to ErrorManager. A value: copies do not change when ErrorManager gets new
100 * errors.
101 */
102struct DXFCPP_EXPORT ErrorInfo {
103 /// The number of the error, from 1, increasing in the order of the reports.
104 std::uint64_t id{};
105
106 /// The time of the report, in milliseconds since the UNIX epoch (UTC).
107 std::int64_t time{};
108
109 /// The hash of the `std::thread::id` of the thread that reported the error.
110 std::uint64_t threadId{};
111
112 /// The part of the library that reported the error, for example `DXFeedSubscription`.
113 std::string component{};
114
115 /// The source file and the line of the report, for example `DXFeedSubscription.cpp:42`.
116 std::string location{};
117
118 /// The message of the error. For a Java exception, the message of the Java exception.
119 std::string message{};
120
121 /// The class of the Java exception, or an empty string when the error is not a Java exception.
122 std::string javaClassName{};
123
124 /// The stack trace of the Java exception, or an empty string when the error is not a Java exception.
125 std::string javaStackTrace{};
126
127 /// The level of a report.
128 enum class Level {
129 // windows.h defines ERROR as a macro: it is hidden here and restored after the enumerator.
130#pragma push_macro("ERROR")
131#undef ERROR
132 /// A failure: reported by ErrorManager::report() and ErrorManager::reportException(). The default level.
133 ERROR,
134#pragma pop_macro("ERROR")
135
136 /// A warning: reported by ErrorManager::reportWarning(). The call that reported it went on.
137 WARN,
138
139 /// A message of the library that is not a problem, for example the line of the versions at the creation of
140 /// the first endpoint. Only the library reports it.
141 INFO
142 };
143
144 /// The level of the report, the last member: a value of ErrorInfo without it gets the level of an error.
145 Level level{};
146
147 /**
148 * Returns a string representation of the error: the component, the location, the Java class (if any) and the
149 * message, in one line. A warning starts with `WARN `, an INFO message with `INFO ` and has no location.
150 *
151 * @return The string representation of the error.
152 */
153 std::string toString() const;
154};
155
156/**
157 * Receives the errors that have no caller: the exceptions of the callbacks of the dxFeed Graal SDK and of the code
158 * the library runs on its own. See @ref error_handling "Error handling".
159 */
160struct DXFCPP_EXPORT ErrorManager final {
161 /// The handler of the errors. A null handler turns the output off.
162 using Handler = std::function<void(const ErrorInfo &)>;
163
164 /// The default capacity of the journal.
165 static constexpr std::size_t DEFAULT_CAPACITY = 128;
166
167 ErrorManager() = delete;
168
169 /**
170 * Reports an error: adds it to the journal and passes it to the handler.
171 *
172 * @param component The part of the code that reports the error.
173 * @param message The message of the error.
174 * @param location The source location of the report.
175 */
176 static void report(StringParam component, StringParam message,
177 const std::source_location &location = std::source_location::current()) noexcept;
178
179 /**
180 * Reports an exception: adds it to the journal and passes it to the handler. A JavaException gives the Java
181 * class and stack trace, another `std::exception` its `what()`, any other exception the message
182 * `unknown exception`.
183 *
184 * @param component The part of the code that reports the error.
185 * @param exception The exception, usually `std::current_exception()` in a `catch` block.
186 * @param location The source location of the report.
187 */
188 static void reportException(StringParam component, const std::exception_ptr &exception,
189 const std::source_location &location = std::source_location::current()) noexcept;
190
191 /**
192 * Reports a warning: adds it to the journal and passes it to the handler like an error, with the level
193 * ErrorInfo::Level::WARN. The ids come from the same counter as the ids of the errors.
194 *
195 * @param component The part of the code that reports the warning.
196 * @param message The message of the warning.
197 * @param location The source location of the report.
198 */
199 static void reportWarning(StringParam component, StringParam message,
200 const std::source_location &location = std::source_location::current()) noexcept;
201
202 /**
203 * Sets the handler of the errors.
204 *
205 * @param handler The new handler, or a null handler to turn the output off (the journal keeps the errors).
206 */
207 static void setHandler(Handler handler);
208
209 /// Restores the default handler, which writes one line per error to `stderr`.
210 static void resetHandler() noexcept;
211
212 /**
213 * The default handler: writes ErrorInfo::toString() of the error as one line to `stderr`.
214 *
215 * @param error The error.
216 */
217 static void defaultHandler(const ErrorInfo &error) noexcept;
218
219 /**
220 * Sets the number of the last errors that the journal keeps. Older errors are dropped at once if there are more.
221 *
222 * @param capacity The capacity; 0 turns the journal off.
223 */
224 static void setCapacity(std::size_t capacity);
225
226 /// @return The number of the last errors that the journal keeps.
227 static std::size_t getCapacity() noexcept;
228
229 /// @return The copies of the errors in the journal, from the oldest to the newest.
230 static std::vector<ErrorInfo> getErrors();
231
232 /// @return The copy of the newest error in the journal, or an empty optional when the journal is empty.
233 static std::optional<ErrorInfo> getLastError();
234
235 /// Removes all the errors from the journal. The numbers of the next errors continue.
236 static void clearErrors() noexcept;
237};
238
239DXFCPP_END_NAMESPACE
240
241/// @}
242
243DXFCXX_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
static bool isActive() noexcept
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:77
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:80
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:95
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:60
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:49
std::shared_ptr< SharedEntity > Ptr
The alias to a type of shared pointer to the SharedEntity object.
Definition SharedEntity.hpp:27
bool is() const noexcept
Checks that the object is of type T: its dynamic type is T or derived from T.
Definition SharedEntity.hpp:38
void remove(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:309
SimpleHandler(const char *component) noexcept
Creates the new handler.
Definition Handler.hpp:197
void removeAll()
Removes all the listeners.
Definition Handler.hpp:352
SimpleHandler() noexcept=default
Creates the new handler.
void operator-=(std::size_t id)
Removes a listener by the id.
Definition Handler.hpp:381
void operator()(ArgTypes... args) noexcept
Calls the listeners on the current thread and passes the args to them.
Definition Handler.hpp:254
void handle(ArgTypes... args) noexcept
Calls the listeners on the current thread and passes the args to them.
Definition Handler.hpp:229
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