]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_pubsub_push.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rgw / rgw_pubsub_push.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3 #pragma once
4
5 #include <string>
6 #include <memory>
7 #include <stdexcept>
8 #include "include/buffer_fwd.h"
9 #include "include/common_fwd.h"
10 #include "common/async/yield_context.h"
11
12 // TODO the env should be used as a template parameter to differentiate the source that triggers the pushes
13 class RGWDataSyncEnv;
14 class RGWCoroutine;
15 class RGWHTTPArgs;
16 struct rgw_pubsub_event;
17 struct rgw_pubsub_s3_event;
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
32 static Ptr create(const std::string& endpoint, const std::string& topic, const RGWHTTPArgs& args, CephContext *cct=nullptr);
33
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
36 virtual RGWCoroutine* send_to_completion_async(const rgw_pubsub_event& event, RGWDataSyncEnv* env) = 0;
37
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_event& event, 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_event& event, optional_yield y) = 0;
45
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