-
Notifications
You must be signed in to change notification settings - Fork 4k
Add rabbit_queue_type behaviour #2052
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
7fa38c0
Add marker rabbit_queue_type behaviour
kjnilsson e5dff9f
Move queue declare into rabbit_queue_type
kjnilsson 8aa9d9f
Move queue delete into queue type implementation
kjnilsson 1e8500b
First cut stateful queue type
kjnilsson 7a7bf15
Queue type: dequeue/basic_get
kjnilsson 7d34763
Move info inside queue type abstraction
kjnilsson f0aaa63
Move policy change into queue type interface
kjnilsson 4a91b5d
Add purge to queue type
kjnilsson 5277cbb
Add recovery to the queue type interface
kjnilsson 3603048
Rename amqqueue quorum_nodes field
kjnilsson 2e3aaf4
Fix tests and handle classic API response
dcorbacho 277840b
Fix HA queue confirm bug
kjnilsson 4f6ebd8
Fix issue with events of deleted queues
kjnilsson e489655
be defensive around state_info
kjnilsson 550b980
fix basic.get reject bug
kjnilsson 5b6bcec
correct default value of amqqueue getter
kjnilsson 899beb3
wip
kjnilsson 1465bb6
wip
kjnilsson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,9 +57,9 @@ | |
| % policy_version | ||
| get_policy_version/1, | ||
| set_policy_version/2, | ||
| % quorum_nodes | ||
| get_quorum_nodes/1, | ||
| set_quorum_nodes/2, | ||
| % type_state | ||
| get_type_state/1, | ||
| set_type_state/2, | ||
| % recoverable_slaves | ||
| get_recoverable_slaves/1, | ||
| set_recoverable_slaves/2, | ||
|
|
@@ -118,8 +118,8 @@ | |
| slave_pids_pending_shutdown = [] :: [pid()] | '_', | ||
| vhost :: rabbit_types:vhost() | undefined | '_', %% secondary index | ||
| options = #{} :: map() | '_', | ||
| type = ?amqqueue_v1_type :: atom() | '_', | ||
| quorum_nodes = [] :: [node()] | '_' | ||
| type = ?amqqueue_v1_type :: module() | '_', | ||
| type_state = #{} :: map() | '_' | ||
| }). | ||
|
|
||
| -type amqqueue() :: amqqueue_v1:amqqueue_v1() | amqqueue_v2(). | ||
|
|
@@ -143,7 +143,7 @@ | |
| vhost :: rabbit_types:vhost() | undefined, | ||
| options :: map(), | ||
| type :: atom(), | ||
| quorum_nodes :: [node()] | ||
| type_state :: #{} | ||
| }. | ||
|
|
||
| -type ra_server_id() :: {Name :: atom(), Node :: node()}. | ||
|
|
@@ -170,7 +170,7 @@ | |
| vhost :: '_', | ||
| options :: '_', | ||
| type :: atom() | '_', | ||
| quorum_nodes :: '_' | ||
| type_state :: '_' | ||
| }. | ||
|
|
||
| -export_type([amqqueue/0, | ||
|
|
@@ -451,7 +451,7 @@ set_gm_pids(Queue, GMPids) -> | |
|
|
||
| -spec get_leader(amqqueue_v2()) -> node(). | ||
|
|
||
| get_leader(#amqqueue{type = quorum, pid = {_, Leader}}) -> Leader. | ||
| get_leader(#amqqueue{type = rabbit_quorum_queue, pid = {_, Leader}}) -> Leader. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the "PID" be an opaque type as well? Again, that "leader" thing is very quorum queues/Ra specific. |
||
|
|
||
| % operator_policy | ||
|
|
||
|
|
@@ -551,18 +551,18 @@ set_recoverable_slaves(#amqqueue{} = Queue, Slaves) -> | |
| set_recoverable_slaves(Queue, Slaves) -> | ||
| amqqueue_v1:set_recoverable_slaves(Queue, Slaves). | ||
|
|
||
| % quorum_nodes (new in v2) | ||
| % type_state (new in v2) | ||
|
|
||
| -spec get_quorum_nodes(amqqueue()) -> [node()]. | ||
| -spec get_type_state(amqqueue()) -> map(). | ||
| get_type_state(#amqqueue{type_state = TState}) -> | ||
| TState; | ||
| get_type_state(_) -> | ||
| #{}. | ||
|
|
||
| get_quorum_nodes(#amqqueue{quorum_nodes = Nodes}) -> Nodes; | ||
| get_quorum_nodes(_) -> []. | ||
|
|
||
| -spec set_quorum_nodes(amqqueue(), [node()]) -> amqqueue(). | ||
|
|
||
| set_quorum_nodes(#amqqueue{} = Queue, Nodes) -> | ||
| Queue#amqqueue{quorum_nodes = Nodes}; | ||
| set_quorum_nodes(Queue, _Nodes) -> | ||
| -spec set_type_state(amqqueue(), map()) -> amqqueue(). | ||
| set_type_state(#amqqueue{} = Queue, TState) -> | ||
| Queue#amqqueue{type_state = TState}; | ||
| set_type_state(Queue, _TState) -> | ||
| Queue. | ||
|
|
||
| % slave_pids | ||
|
|
@@ -660,7 +660,7 @@ is_classic(Queue) -> | |
| -spec is_quorum(amqqueue()) -> boolean(). | ||
|
|
||
| is_quorum(Queue) -> | ||
| get_type(Queue) =:= quorum. | ||
| get_type(Queue) =:= rabbit_quorum_queue. | ||
|
|
||
| fields() -> | ||
| case record_version_to_use() of | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To follow up on Diana's comments, we can probably replace those functions & associated macros by something more generic. @lukebakken did change the initial generic functions/macros to those specific more readable versions. @lukebakken: I think you linked an article about that kind of API but I don't rember the content, what was the reason behind this already?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My goal was to put all "knowledge" of how to determine if an
amqqueueis classic into this macro. This way, when the identification of a classic queue changes, we only have to change this macro and not all the places where it is used.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Tell Don't Ask"