]>
git.proxmox.com Git - ceph.git/blob - 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
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"
14 // forward declarations
23 namespace rgw::notify
{
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
);
30 // shutdown the notification manager
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
);
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
);
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
{
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
) {}
50 std::string configurationId
;
52 // res_id is reset after topic is committed/aborted
53 cls_2pc_reservation::id_t res_id
;
56 const DoutPrefixProvider
* dpp
;
57 std::vector
<topic_t
> topics
;
58 rgw::sal::RadosStore
* const store
;
59 const req_state
* const s
;
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
69 std::string user_tenant
;
73 /* ctor for rgw_op callers */
74 reservation_t(const DoutPrefixProvider
* _dpp
,
75 rgw::sal::RadosStore
* _store
,
77 rgw::sal::Object
* _object
,
78 rgw::sal::Object
* _src_object
,
79 const std::string
* _object_name
);
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
,
93 // dtor doing resource leak guarding
94 // aborting the reservation if not already committed or aborted
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
);
104 // commit the reservation to the queue
105 int publish_commit(rgw::sal::Object
* obj
,
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
);
114 // cancel the reservation
115 int publish_abort(const DoutPrefixProvider
*dpp
, reservation_t
& reservation
);