]>
Commit | Line | Data |
---|---|---|
11fdf7f2 | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 TL |
3 | #pragma once |
4 | ||
5 | #include <string> | |
6 | #include <memory> | |
7 | #include <stdexcept> | |
8 | #include "include/buffer_fwd.h" | |
9f95a23c | 9 | #include "include/common_fwd.h" |
eafe8130 | 10 | #include "common/async/yield_context.h" |
11fdf7f2 | 11 | |
eafe8130 | 12 | // TODO the env should be used as a template parameter to differentiate the source that triggers the pushes |
11fdf7f2 TL |
13 | class RGWDataSyncEnv; |
14 | class RGWCoroutine; | |
15 | class RGWHTTPArgs; | |
16 | struct rgw_pubsub_event; | |
eafe8130 | 17 | struct rgw_pubsub_s3_record; |
11fdf7f2 TL |
18 | |
19 | // endpoint base class all endpoint - types should derive from it | |
20 | class RGWPubSubEndpoint { | |
21 | public: | |
22 | RGWPubSubEndpoint() = default; | |
23 | // endpoint should not be copied | |
24 | RGWPubSubEndpoint(const RGWPubSubEndpoint&) = delete; | |
25 | const RGWPubSubEndpoint& operator=(const RGWPubSubEndpoint&) = delete; | |
26 | ||
27 | typedef std::unique_ptr<RGWPubSubEndpoint> Ptr; | |
28 | ||
29 | // factory method for the actual notification endpoint | |
30 | // derived class specific arguments are passed in http args format | |
31 | // may throw a configuration_error if creation fails | |
eafe8130 | 32 | static Ptr create(const std::string& endpoint, const std::string& topic, const RGWHTTPArgs& args, CephContext *cct=nullptr); |
11fdf7f2 | 33 | |
eafe8130 TL |
34 | // this method is used in order to send notification (Ceph specific) and wait for completion |
35 | // in async manner via a coroutine when invoked in the data sync environment | |
11fdf7f2 TL |
36 | virtual RGWCoroutine* send_to_completion_async(const rgw_pubsub_event& event, RGWDataSyncEnv* env) = 0; |
37 | ||
eafe8130 TL |
38 | // this method is used in order to send notification (S3 compliant) and wait for completion |
39 | // in async manner via a coroutine when invoked in the data sync environment | |
40 | virtual RGWCoroutine* send_to_completion_async(const rgw_pubsub_s3_record& record, RGWDataSyncEnv* env) = 0; | |
41 | ||
42 | // this method is used in order to send notification (S3 compliant) and wait for completion | |
43 | // in async manner via a coroutine when invoked in the frontend environment | |
44 | virtual int send_to_completion_async(CephContext* cct, const rgw_pubsub_s3_record& record, optional_yield y) = 0; | |
45 | ||
11fdf7f2 TL |
46 | // present as string |
47 | virtual std::string to_str() const { return ""; } | |
48 | ||
49 | virtual ~RGWPubSubEndpoint() = default; | |
50 | ||
51 | // exception object for configuration error | |
52 | struct configuration_error : public std::logic_error { | |
53 | configuration_error(const std::string& what_arg) : | |
54 | std::logic_error("pubsub endpoint configuration error: " + what_arg) {} | |
55 | }; | |
56 | }; | |
57 |