]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_notify.h
buildsys: change download over to reef release
[ceph.git] / ceph / src / rgw / rgw_notify.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
4 #pragma once
5
6 #include <string>
7 #include "common/ceph_time.h"
8 #include "include/common_fwd.h"
9 #include "rgw_notify_event_type.h"
10 #include "common/async/yield_context.h"
11 #include "cls/2pc_queue/cls_2pc_queue_types.h"
12 #include "rgw_pubsub.h"
13
14 // forward declarations
15 namespace rgw::sal {
16 class RadosStore;
17 class RGWObject;
18 }
19
20 class RGWRados;
21 struct rgw_obj_key;
22
23 namespace rgw::notify {
24
25 // initialize the notification manager
26 // notification manager is dequeing the 2-phase-commit queues
27 // and send the notifications to the endpoints
28 bool init(CephContext* cct, rgw::sal::RadosStore* store, const DoutPrefixProvider *dpp);
29
30 // shutdown the notification manager
31 void shutdown();
32
33 // create persistent delivery queue for a topic (endpoint)
34 // this operation also add a topic name to the common (to all RGWs) list of all topics
35 int add_persistent_topic(const std::string& topic_name, optional_yield y);
36
37 // remove persistent delivery queue for a topic (endpoint)
38 // this operation also remove the topic name from the common (to all RGWs) list of all topics
39 int remove_persistent_topic(const std::string& topic_name, optional_yield y);
40
41 // struct holding reservation information
42 // populated in the publish_reserve call
43 // then used to commit or abort the reservation
44 struct reservation_t {
45 struct topic_t {
46 topic_t(const std::string& _configurationId, const rgw_pubsub_topic& _cfg,
47 cls_2pc_reservation::id_t _res_id) :
48 configurationId(_configurationId), cfg(_cfg), res_id(_res_id) {}
49
50 std::string configurationId;
51 rgw_pubsub_topic cfg;
52 // res_id is reset after topic is committed/aborted
53 cls_2pc_reservation::id_t res_id;
54 };
55
56 const DoutPrefixProvider* dpp;
57 std::vector<topic_t> topics;
58 rgw::sal::RadosStore* const store;
59 const req_state* const s;
60 size_t size;
61 RGWObjectCtx* obj_ctx;
62 rgw::sal::Object* const object;
63 rgw::sal::Object* const src_object; // may differ from object
64 rgw::sal::Bucket* const bucket;
65 const std::string* const object_name;
66 boost::optional<RGWObjTags&> tagset;
67 meta_map_t x_meta_map; // metadata cached by value
68 std::string user_id;
69 std::string user_tenant;
70 std::string req_id;
71 optional_yield yield;
72
73 /* ctor for rgw_op callers */
74 reservation_t(const DoutPrefixProvider* _dpp,
75 rgw::sal::RadosStore* _store,
76 req_state* _s,
77 rgw::sal::Object* _object,
78 rgw::sal::Object* _src_object,
79 const std::string* _object_name);
80
81 /* ctor for non-request caller (e.g., lifecycle) */
82 reservation_t(const DoutPrefixProvider* _dpp,
83 rgw::sal::RadosStore* _store,
84 RGWObjectCtx* _obj_ctx,
85 rgw::sal::Object* _object,
86 rgw::sal::Object* _src_object,
87 rgw::sal::Bucket* _bucket,
88 std::string& _user_id,
89 std::string& _user_tenant,
90 std::string& _req_id,
91 optional_yield y);
92
93 // dtor doing resource leak guarding
94 // aborting the reservation if not already committed or aborted
95 ~reservation_t();
96 };
97
98 // create a reservation on the 2-phase-commit queue
99 int publish_reserve(const DoutPrefixProvider *dpp,
100 EventType event_type,
101 reservation_t& reservation,
102 const RGWObjTags* req_tags);
103
104 // commit the reservation to the queue
105 int publish_commit(rgw::sal::Object* obj,
106 uint64_t size,
107 const ceph::real_time& mtime,
108 const std::string& etag,
109 const std::string& version,
110 EventType event_type,
111 reservation_t& reservation,
112 const DoutPrefixProvider *dpp);
113
114 // cancel the reservation
115 int publish_abort(const DoutPrefixProvider *dpp, reservation_t& reservation);
116
117 }
118