QEverCloud  6.1.0
Unofficial Evernote Cloud API for Qt
DurableService.h
Go to the documentation of this file.
1 
8 #ifndef QEVERCLOUD_DURABLE_SERVICE_H
9 #define QEVERCLOUD_DURABLE_SERVICE_H
10 
11 #include "AsyncResult.h"
12 #include "Export.h"
13 #include "RequestContext.h"
14 
15 #include <QDateTime>
16 #include <QVariant>
17 
18 #include <functional>
19 #include <memory>
20 #include <utility>
21 
22 namespace qevercloud {
23 
25 
27 {
28  virtual bool shouldRetry(
29  const EverCloudExceptionDataPtr & exceptionData) = 0;
30 };
31 
32 using IRetryPolicyPtr = std::shared_ptr<IRetryPolicy>;
33 
35 
36 QT_FORWARD_DECLARE_CLASS(DurableServicePrivate)
37 
39 {
40 public:
41  using SyncResult = std::pair<QVariant,EverCloudExceptionDataPtr>;
44 
46  {
47  const char * m_name;
48  QString m_description;
50 
51  SyncRequest(const char * name, QString description,
52  SyncServiceCall && call) :
53  m_name(name),
54  m_description(std::move(description)),
55  m_call(std::move(call))
56  {}
57  };
58 
60  {
61  const char * m_name;
62  QString m_description;
64 
65  AsyncRequest(const char * name, QString description,
66  AsyncServiceCall && call) :
67  m_name(name),
68  m_description(std::move(description)),
69  m_call(std::move(call))
70  {}
71  };
72 
73 public:
75  SyncRequest && syncRequest, IRequestContextPtr ctx) = 0;
76 
78  AsyncRequest && asyncRequest, IRequestContextPtr ctx) = 0;
79 };
80 
81 using IDurableServicePtr = std::shared_ptr<IDurableService>;
82 
84 
86 
88 
90  IRetryPolicyPtr = {},
91  IRequestContextPtr = {});
92 
93 } // namespace qevercloud
94 
95 #endif // QEVERCLOUD_DURABLE_SERVICE_H
qevercloud::IDurableService::SyncResult
std::pair< QVariant, EverCloudExceptionDataPtr > SyncResult
Definition: DurableService.h:41
Export.h
qevercloud::IRetryPolicy::shouldRetry
virtual bool shouldRetry(const EverCloudExceptionDataPtr &exceptionData)=0
qevercloud::IDurableService
Definition: DurableService.h:39
qevercloud::IDurableService::SyncRequest::SyncRequest
SyncRequest(const char *name, QString description, SyncServiceCall &&call)
Definition: DurableService.h:51
qevercloud::IDurableService::SyncRequest
Definition: DurableService.h:46
qevercloud::IDurableService::AsyncRequest::AsyncRequest
AsyncRequest(const char *name, QString description, AsyncServiceCall &&call)
Definition: DurableService.h:65
qevercloud::IDurableService::SyncServiceCall
std::function< SyncResult(IRequestContextPtr)> SyncServiceCall
Definition: DurableService.h:42
qevercloud
Definition: AsyncResult.h:21
qevercloud::AsyncResult
Returned by asynchonous versions of functions.
Definition: AsyncResult.h:54
qevercloud::IDurableService::AsyncRequest::m_description
QString m_description
Definition: DurableService.h:62
qevercloud::IDurableService::AsyncRequest::m_call
AsyncServiceCall m_call
Definition: DurableService.h:63
qevercloud::IDurableService::AsyncRequest
Definition: DurableService.h:60
qevercloud::IDurableServicePtr
std::shared_ptr< IDurableService > IDurableServicePtr
Definition: DurableService.h:81
qevercloud::newRetryPolicy
QEVERCLOUD_EXPORT IRetryPolicyPtr newRetryPolicy()
qevercloud::IDurableService::AsyncServiceCall
std::function< AsyncResult *(IRequestContextPtr)> AsyncServiceCall
Definition: DurableService.h:43
qevercloud::IDurableService::SyncRequest::m_name
const char * m_name
Definition: DurableService.h:47
qevercloud::nullRetryPolicy
QEVERCLOUD_EXPORT IRetryPolicyPtr nullRetryPolicy()
qevercloud::IDurableService::SyncRequest::m_description
QString m_description
Definition: DurableService.h:48
qevercloud::IRetryPolicy
Definition: DurableService.h:27
RequestContext.h
qevercloud::IDurableService::AsyncRequest::m_name
const char * m_name
Definition: DurableService.h:61
qevercloud::IDurableService::executeSyncRequest
virtual SyncResult executeSyncRequest(SyncRequest &&syncRequest, IRequestContextPtr ctx)=0
qevercloud::IDurableService::executeAsyncRequest
virtual AsyncResult * executeAsyncRequest(AsyncRequest &&asyncRequest, IRequestContextPtr ctx)=0
qevercloud::IRequestContextPtr
std::shared_ptr< IRequestContext > IRequestContextPtr
Definition: RequestContext.h:81
QEVERCLOUD_EXPORT
#define QEVERCLOUD_EXPORT
Definition: Export.h:19
qevercloud::EverCloudExceptionDataPtr
std::shared_ptr< EverCloudExceptionData > EverCloudExceptionDataPtr
Definition: EverCloudException.h:149
qevercloud::IDurableService::SyncRequest::m_call
SyncServiceCall m_call
Definition: DurableService.h:49
qevercloud::IRetryPolicyPtr
std::shared_ptr< IRetryPolicy > IRetryPolicyPtr
Definition: DurableService.h:32
qevercloud::newDurableService
QEVERCLOUD_EXPORT IDurableServicePtr newDurableService(IRetryPolicyPtr={}, IRequestContextPtr={})
AsyncResult.h