GoPxL SDK

- Home
- Files
- Namespace

GoTransaction.h
Go to the documentation of this file.
1
9 #ifndef GO_PXL_SDK_TRANSACTION_H
10 #define GO_PXL_SDK_TRANSACTION_H
11
12 #include <GoPxLSdk/GoRequest.h>
13 #include <GoPxLSdk/GoResponse.h>
14
15 class GoTransactionTests;
16
17 namespace GoPxLSdk
18 {
19 constexpr k64u DEFAULT_TRANSACTION_TIMEOUT_MSEC = 3 * 1000; // 3,000 milliseconds = 3 seconds.
20
21 class GoRestClient;
22
23 class GoPxLSdkClass GoTransaction
24 {
25 public:
32 GoTransaction() = default;
33
43 GoTransaction(const GoRequest& request);
44
54 void CheckResponse(k64u timeoutInMilliseconds = DEFAULT_TRANSACTION_TIMEOUT_MSEC);
55
66 const GoRequestResponse& GetResponse(k64u timeoutInMilliseconds = DEFAULT_TRANSACTION_TIMEOUT_MSEC);
67
75 const GoRequest& GetRequest();
76
84 std::shared_future<GoRequestResponse>& GetResponseFuture();
85
86 protected:
94 void OnResponse(const std::shared_ptr<GoRequestResponse>& response);
95
103 void OnError(const std::exception& e);
104
105 private:
106 GoRequest request;
107 std::shared_ptr<std::promise<GoRequestResponse>> promise;
108 std::shared_future<GoRequestResponse> futureResponse;
109
110 friend class GoRestClient;
111 friend class ::GoTransactionTests;
112 };
113
114 }
115
116 #endif
GoPxLSdkClass
#define GoPxLSdkClass
Definition: Def.h:35
GoPxLSdk::DEFAULT_TRANSACTION_TIMEOUT_MSEC
constexpr k64u DEFAULT_TRANSACTION_TIMEOUT_MSEC
Definition: GoTransaction.h:19
GoResponse.h
GoPxLSdk::GoRequest
Definition: GoRequest.h:21
GoPxLSdk::GoRestClient
Definition: GoRestClient.h:36
GoPxLSdk::GoRequestResponse
Represents a response to requests such as Read/Update.
Definition: GoResponse.h:101
GoPxLSdk::GoTransaction
Definition: GoTransaction.h:23
GoRequest.h
GoPxLSdk
Definition: Def.h:46