olp-cpp-sdk
1.22.0
|
Provides the ability to consume data from a stream layer in real time. More...
#include <StreamLayerClient.h>
Public Member Functions | |
StreamLayerClient (client::HRN catalog, std::string layer_id, client::OlpClientSettings settings) | |
Creates the StreamLayerClient instance. More... | |
StreamLayerClient (const StreamLayerClient &other)=delete | |
A copy constructor. | |
StreamLayerClient (StreamLayerClient &&other) noexcept | |
A default move constructor. | |
StreamLayerClient & | operator= (const StreamLayerClient &other)=delete |
A copy assignment operator. | |
StreamLayerClient & | operator= (StreamLayerClient &&other) noexcept |
A move assignment operator. | |
bool | CancelPendingRequests () |
Cancels all the active and pending requests. More... | |
client::CancellationToken | Subscribe (SubscribeRequest request, SubscribeResponseCallback callback) |
Enables message consumption for the specific stream layer. More... | |
client::CancellableFuture< SubscribeResponse > | Subscribe (SubscribeRequest request) |
Enables message consumption for the specific stream layer. More... | |
client::CancellationToken | Unsubscribe (UnsubscribeResponseCallback callback) |
Deletes the current subscription for the stream layer. More... | |
client::CancellableFuture< UnsubscribeResponse > | Unsubscribe () |
Deletes the current subscription for the stream layer. More... | |
client::CancellationToken | GetData (const model::Message &message, DataResponseCallback callback) |
Downloads the message data using the data handle from the given message metadata. More... | |
client::CancellableFuture< DataResponse > | GetData (const model::Message &message) |
Downloads message data using a data handle from the given message metadata. More... | |
client::CancellationToken | Poll (PollResponseCallback callback) |
Reads messages from a stream layer and commits successfully consumed messages before returning them to you. More... | |
client::CancellableFuture< PollResponse > | Poll () |
Reads messages from a stream layer and commits successfully consumed messages before returning them to you. More... | |
client::CancellationToken | Seek (SeekRequest request, SeekResponseCallback callback) |
Allows changing the data stream reading offset. More... | |
client::CancellableFuture< SeekResponse > | Seek (SeekRequest request) |
Allows changing the data stream reading offset. More... | |
Provides the ability to consume data from a stream layer in real time.
The client reads the data in the order it is added to the queue. Once the client reads the data, the data is no longer available to that client, but the data remains available to other clients.
Example of subscribing to and unsubscribing from a stream layer:
olp::dataservice::read::StreamLayerClient::StreamLayerClient | ( | client::HRN | catalog, |
std::string | layer_id, | ||
client::OlpClientSettings | settings | ||
) |
Creates the StreamLayerClient
instance.
catalog | The HRN of the catalog that the stream layer client uses for requests. |
layer_id | The ID of the layer that the client uses for requests. |
settings | The OlpClientSettings instance. |
bool olp::dataservice::read::StreamLayerClient::CancelPendingRequests | ( | ) |
Cancels all the active and pending requests.
client::CancellableFuture<DataResponse> olp::dataservice::read::StreamLayerClient::GetData | ( | const model::Message & | message | ) |
Downloads message data using a data handle from the given message metadata.
Users should use this method to download data only for messages that include a data handle and that have data size greater than 1 MB. Messages with data size less than 1 MB will have the data embedded.
message | The Message instance that was retrieved using the Poll method. |
CancellableFuture
that contains DataResult
or an error. You can also use CancellableFuture
to cancel this request. client::CancellationToken olp::dataservice::read::StreamLayerClient::GetData | ( | const model::Message & | message, |
DataResponseCallback | callback | ||
) |
Downloads the message data using the data handle from the given message metadata.
Users should use this method to download data only for messages that include a data handle and that have data size greater than 1 MB. Messages with data size less than 1 MB will have the data embedded.
message | The Message instance that was retrieved using the Poll method. |
callback | The DataResponseCallback object that is invoked when the get data request is completed. |
client::CancellableFuture<PollResponse> olp::dataservice::read::StreamLayerClient::Poll | ( | ) |
Reads messages from a stream layer and commits successfully consumed messages before returning them to you.
Only possible if subscribed successfully. If the payload is more than 1 MB, then it is not embedded into the metadata. To download the data, call GetData(Message)
.
CancellableFuture
that contains PollResponse
or an error. You can also use CancellableFuture
to cancel this request. client::CancellationToken olp::dataservice::read::StreamLayerClient::Poll | ( | PollResponseCallback | callback | ) |
Reads messages from a stream layer and commits successfully consumed messages before returning them to you.
Only possible if subscribed successfully. If the payload is more than 1 MB, then it is not embedded into the metadata. To download the data, call GetData(Message)
.
callback | The PollResponseCallback object that is invoked when the Poll request is completed. |
client::CancellableFuture<SeekResponse> olp::dataservice::read::StreamLayerClient::Seek | ( | SeekRequest | request | ) |
Allows changing the data stream reading offset.
If the commit is successful, the message consumption starts from the specified offset.
Only possible if subscribed successfully. Offsets shouldn't be empty.
request | The SeekRequest instance that contains a complete set of request parameters. |
CancellableFuture
that contains SeekResponse
or an error. You can also use CancellableFuture
to cancel this request. client::CancellationToken olp::dataservice::read::StreamLayerClient::Seek | ( | SeekRequest | request, |
SeekResponseCallback | callback | ||
) |
Allows changing the data stream reading offset.
If the commit is successful, the message consumption starts from the specified offset.
Only possible if subscribed successfully. Offsets shouldn't be empty.
request | The SeekRequest instance that contains a complete set of request parameters. |
callback | The SeekResponseCallback object that is invoked when the Seek request is completed. |
client::CancellableFuture<SubscribeResponse> olp::dataservice::read::StreamLayerClient::Subscribe | ( | SubscribeRequest | request | ) |
Enables message consumption for the specific stream layer.
request | The SubscribeRequest instance that contains a complete set of request parameters. |
CancellableFuture
that contains the SubscribeId
instance or an error. You can also use CancellableFuture
to cancel this request. client::CancellationToken olp::dataservice::read::StreamLayerClient::Subscribe | ( | SubscribeRequest | request, |
SubscribeResponseCallback | callback | ||
) |
Enables message consumption for the specific stream layer.
request | The SubscribeRequest instance that contains a complete set of request parameters. |
callback | The SubscribeResponseCallback object that is invoked when the subscription request is completed. |
client::CancellableFuture<UnsubscribeResponse> olp::dataservice::read::StreamLayerClient::Unsubscribe | ( | ) |
Deletes the current subscription for the stream layer.
CancellableFuture
that contains the SubscribeId
instance of the deleted subscription or an error. You can also use CancellableFuture
to cancel this request. client::CancellationToken olp::dataservice::read::StreamLayerClient::Unsubscribe | ( | UnsubscribeResponseCallback | callback | ) |
Deletes the current subscription for the stream layer.
callback | The UnsubscribeResponseCallback object that is invoked when the unsubscription request is completed. |