|
16 | 16 |
|
17 | 17 | -module(rabbit_stream_utils).
|
18 | 18 |
|
| 19 | +-feature(maybe_expr, enable). |
| 20 | + |
19 | 21 | %% API
|
20 | 22 | -export([enforce_correct_name/1,
|
21 | 23 | write_messages/5,
|
@@ -202,32 +204,20 @@ check_read_permitted(Resource, User, Context) ->
|
202 | 204 |
|
203 | 205 | check_super_stream_management_permitted(VirtualHost, SuperStream, Partitions, User) ->
|
204 | 206 | Exchange = e(VirtualHost, SuperStream),
|
205 |
| - %% exchange creation |
206 |
| - case check_configure_permitted(Exchange, User) of |
207 |
| - ok -> |
208 |
| - %% stream creations |
209 |
| - case check_streams_permissions(fun check_configure_permitted/2, |
210 |
| - VirtualHost, Partitions, |
211 |
| - User) of |
212 |
| - ok -> |
213 |
| - %% binding from exchange |
214 |
| - case check_read_permitted(Exchange, User, #{}) of |
215 |
| - ok -> |
216 |
| - %% binding to streams |
217 |
| - case check_streams_permissions(fun check_write_permitted/2, |
218 |
| - VirtualHost, Partitions, |
219 |
| - User) of |
220 |
| - ok -> |
221 |
| - ok; |
222 |
| - _ -> |
223 |
| - error |
224 |
| - end; |
225 |
| - _ -> |
226 |
| - error |
227 |
| - end; |
228 |
| - _ -> |
229 |
| - error |
230 |
| - end; |
| 207 | + maybe |
| 208 | + %% exchange creation |
| 209 | + ok ?= check_configure_permitted(Exchange, User), |
| 210 | + %% stream creations |
| 211 | + ok ?= check_streams_permissions(fun check_configure_permitted/2, |
| 212 | + VirtualHost, Partitions, |
| 213 | + User), |
| 214 | + %% binding from exchange |
| 215 | + ok ?= check_read_permitted(Exchange, User, #{}), |
| 216 | + %% binding to streams |
| 217 | + ok ?= check_streams_permissions(fun check_write_permitted/2, |
| 218 | + VirtualHost, Partitions, |
| 219 | + User) |
| 220 | + else |
231 | 221 | _ ->
|
232 | 222 | error
|
233 | 223 | end.
|
@@ -347,10 +337,7 @@ filtering_supported() ->
|
347 | 337 | rabbit_feature_flags:is_enabled(stream_filtering).
|
348 | 338 |
|
349 | 339 | q(VirtualHost, Name) ->
|
350 |
| - r(VirtualHost, Name, queue). |
| 340 | + rabbit_misc:r(VirtualHost, queue, Name). |
351 | 341 |
|
352 | 342 | e(VirtualHost, Name) ->
|
353 |
| - r(VirtualHost, Name, exchange). |
354 |
| - |
355 |
| -r(VirtualHost, Name, Kind) when Kind =:= exchange orelse Kind =:= queue -> |
356 |
| - #resource{virtual_host = VirtualHost, name = Name, kind = Kind}. |
| 343 | + rabbit_misc:r(VirtualHost, exchange, Name). |
0 commit comments