Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Merge pull request #5409 from rabbitmq/mergify/bp/v3.11.x/pr-…
…5236" Two reasons: 1. It was too early to backport. 2. There are at least two pull requests to backport first to avoid conflicts. This reverts commit 871f1ff, reversing changes made to adaf46b.
- Loading branch information
Showing
9 changed files
with
275 additions
and
70 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
-include("vhost_v1.hrl"). | ||
-include("vhost_v2.hrl"). | ||
|
||
-define(is_vhost(V), | ||
(?is_vhost_v2(V))). | ||
(?is_vhost_v2(V) orelse | ||
?is_vhost_v1(V))). |
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
-define(is_vhost_v1(V), is_record(V, vhost, 3)). | ||
|
||
-define(vhost_v1_field_name(V), element(2, V)). | ||
-define(vhost_v1_field_limits(V), element(3, V)). |
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,106 @@ | ||
%% This Source Code Form is subject to the terms of the Mozilla Public | ||
%% License, v. 2.0. If a copy of the MPL was not distributed with this | ||
%% file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
%% | ||
%% Copyright (c) 2018-2022 VMware, Inc. or its affiliates. All rights reserved. | ||
%% | ||
|
||
-module(vhost_v1). | ||
|
||
-include("vhost.hrl"). | ||
|
||
-export([new/2, | ||
new/3, | ||
upgrade/1, | ||
upgrade_to/2, | ||
fields/0, | ||
fields/1, | ||
info_keys/0, | ||
field_name/0, | ||
record_version_to_use/0, | ||
pattern_match_all/0, | ||
get_name/1, | ||
get_limits/1, | ||
get_metadata/1, | ||
get_description/1, | ||
get_tags/1, | ||
set_limits/2 | ||
]). | ||
|
||
-define(record_version, ?MODULE). | ||
|
||
%% Represents a vhost. | ||
%% | ||
%% Historically this record had 2 arguments although the 2nd | ||
%% was never used (`dummy`, always undefined). This is because | ||
%% single field records were/are illegal in OTP. | ||
%% | ||
%% As of 3.6.x, the second argument is vhost limits, | ||
%% which is actually used and has the same default. | ||
%% Nonetheless, this required a migration, see rabbit_upgrade_functions. | ||
|
||
-record(vhost, { | ||
%% name as a binary | ||
virtual_host :: vhost:name() | '_', | ||
%% proplist of limits configured, if any | ||
limits :: list() | '_'}). | ||
|
||
-type vhost() :: vhost_v1(). | ||
-type vhost_v1() :: #vhost{ | ||
virtual_host :: vhost:name(), | ||
limits :: list() | ||
}. | ||
|
||
-export_type([vhost/0, | ||
vhost_v1/0, | ||
vhost_pattern/0, | ||
vhost_v1_pattern/0]). | ||
|
||
|
||
-spec new(vhost:name(), list()) -> vhost(). | ||
new(Name, Limits) -> | ||
#vhost{virtual_host = Name, limits = Limits}. | ||
|
||
-spec new(vhost:name(), list(), map()) -> vhost(). | ||
new(Name, Limits, _Metadata) -> | ||
#vhost{virtual_host = Name, limits = Limits}. | ||
|
||
|
||
-spec record_version_to_use() -> vhost_v1. | ||
record_version_to_use() -> | ||
?record_version. | ||
|
||
-spec upgrade(vhost()) -> vhost(). | ||
upgrade(#vhost{} = VHost) -> VHost. | ||
|
||
-spec upgrade_to(vhost_v1, vhost()) -> vhost(). | ||
upgrade_to(?record_version, #vhost{} = VHost) -> | ||
VHost. | ||
|
||
fields() -> fields(?record_version). | ||
|
||
fields(?record_version) -> record_info(fields, vhost). | ||
|
||
field_name() -> #vhost.virtual_host. | ||
|
||
info_keys() -> [name, tracing, cluster_state]. | ||
|
||
-type vhost_pattern() :: vhost_v1_pattern(). | ||
-type vhost_v1_pattern() :: #vhost{ | ||
virtual_host :: vhost:name() | '_', | ||
limits :: '_' | ||
}. | ||
|
||
-spec pattern_match_all() -> vhost_pattern(). | ||
|
||
pattern_match_all() -> #vhost{_ = '_'}. | ||
|
||
get_name(#vhost{virtual_host = Value}) -> Value. | ||
get_limits(#vhost{limits = Value}) -> Value. | ||
|
||
get_metadata(_VHost) -> undefined. | ||
get_description(_VHost) -> undefined. | ||
get_tags(_VHost) -> undefined. | ||
|
||
set_limits(VHost, Value) -> | ||
VHost#vhost{limits = Value}. |
This file contains 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.