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
22namespace qevercloud {
23
25
27{
28 virtual bool shouldRetry(
29 const EverCloudExceptionDataPtr & exceptionData) = 0;
30};
31
32using IRetryPolicyPtr = std::shared_ptr<IRetryPolicy>;
33
35
36QT_FORWARD_DECLARE_CLASS(DurableServicePrivate)
37
39{
40public:
41 using SyncResult = std::pair<QVariant,EverCloudExceptionDataPtr>;
44
46 {
47 const char * m_name;
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;
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
73public:
75 SyncRequest && syncRequest, IRequestContextPtr ctx) = 0;
76
78 AsyncRequest && asyncRequest, IRequestContextPtr ctx) = 0;
79};
80
81using IDurableServicePtr = std::shared_ptr<IDurableService>;
82
84
86
88
90 IRetryPolicyPtr = {},
92
93} // namespace qevercloud
94
95#endif // QEVERCLOUD_DURABLE_SERVICE_H
#define QEVERCLOUD_EXPORT
Definition: Export.h:19
Returned by asynchonous versions of functions.
Definition: AsyncResult.h:54
Definition: DurableService.h:39
std::function< AsyncResult *(IRequestContextPtr)> AsyncServiceCall
Definition: DurableService.h:43
virtual SyncResult executeSyncRequest(SyncRequest &&syncRequest, IRequestContextPtr ctx)=0
std::function< SyncResult(IRequestContextPtr)> SyncServiceCall
Definition: DurableService.h:42
virtual AsyncResult * executeAsyncRequest(AsyncRequest &&asyncRequest, IRequestContextPtr ctx)=0
std::pair< QVariant, EverCloudExceptionDataPtr > SyncResult
Definition: DurableService.h:41
Definition: AsyncResult.h:21
std::shared_ptr< EverCloudExceptionData > EverCloudExceptionDataPtr
Definition: EverCloudException.h:149
QEVERCLOUD_EXPORT IRetryPolicyPtr newRetryPolicy()
std::shared_ptr< IRetryPolicy > IRetryPolicyPtr
Definition: DurableService.h:32
QEVERCLOUD_EXPORT IRetryPolicyPtr nullRetryPolicy()
std::shared_ptr< IDurableService > IDurableServicePtr
Definition: DurableService.h:81
QEVERCLOUD_EXPORT IDurableServicePtr newDurableService(IRetryPolicyPtr={}, IRequestContextPtr={})
std::shared_ptr< IRequestContext > IRequestContextPtr
Definition: RequestContext.h:81
Definition: DurableService.h:60
AsyncRequest(const char *name, QString description, AsyncServiceCall &&call)
Definition: DurableService.h:65
const char * m_name
Definition: DurableService.h:61
AsyncServiceCall m_call
Definition: DurableService.h:63
QString m_description
Definition: DurableService.h:62
Definition: DurableService.h:46
SyncServiceCall m_call
Definition: DurableService.h:49
const char * m_name
Definition: DurableService.h:47
QString m_description
Definition: DurableService.h:48
SyncRequest(const char *name, QString description, SyncServiceCall &&call)
Definition: DurableService.h:51
Definition: DurableService.h:27
virtual bool shouldRetry(const EverCloudExceptionDataPtr &exceptionData)=0