Skip to content

Commit

Permalink
Display stream publishers in queue management page
Browse files Browse the repository at this point in the history
If the queue is a stream. WIP, currently all the stream publishers
are listed, a new publishers per stream endpoint is required.

References #3389

(cherry picked from commit 0038573)
  • Loading branch information
acogoluegnes authored and mergify-bot committed Sep 14, 2021
1 parent be2d8a4 commit 9778d97
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 7 deletions.
20 changes: 16 additions & 4 deletions deps/rabbitmq_management/priv/www/js/dispatcher.js
Expand Up @@ -98,10 +98,22 @@ dispatcher_add(function(sammy) {
});

sammy.get('#/queues/:vhost/:name', function() {
var path = '/queues/' + esc(this.params['vhost']) + '/' + esc(this.params['name']);
render({'queue': {path: path,
options: {ranges:['lengths-q', 'msg-rates-q', 'data-rates-q']}},
'bindings': path + '/bindings'}, 'queue', '#/queues');
var vhost = this.params['vhost'];
var queue = this.params['name'];
var path = '/queues/' + esc(vhost) + '/' + esc(queue);
var requests = {'queue': {path: path,
options: {ranges:['lengths-q', 'msg-rates-q', 'data-rates-q']}},
'bindings': path + '/bindings'};
// we add extra requests that can be added by code plugged on the extension point
for (var i = 0; i < QUEUE_EXTRA_CONTENT_REQUESTS.length; i++) {
var extra = QUEUE_EXTRA_CONTENT_REQUESTS[i](vhost, queue);
for (key in extra) {
if(extra.hasOwnProperty(key)){
requests[key] = "/stream/publishers";
}
}
}
render(requests, 'queue', '#/queues');
});
sammy.put('#/queues', function() {
if (sync_put(this, '/queues/:vhost/:name'))
Expand Down
3 changes: 3 additions & 0 deletions deps/rabbitmq_management/priv/www/js/global.js
Expand Up @@ -168,6 +168,9 @@ var COLUMNS;

var RENDER_CALLBACKS = {};

const QUEUE_EXTRA_CONTENT = [];
const QUEUE_EXTRA_CONTENT_REQUESTS = [];

// All help ? popups
var HELP = {
'delivery-limit':
Expand Down
20 changes: 18 additions & 2 deletions deps/rabbitmq_management/priv/www/js/main.js
Expand Up @@ -480,7 +480,9 @@ function with_update(fun) {
if(outstanding_reqs.length > 0){
return false;
}
with_reqs(apply_state(current_reqs), [], function(json) {
var model = [];
model['extra_content'] = []; // magic key for extension point
with_reqs(apply_state(current_reqs), model, function(json) {
var html = format(current_template, json);
fun(html);
update_status('ok');
Expand Down Expand Up @@ -1116,7 +1118,13 @@ function with_reqs(reqs, acc, fun) {
if (keys(reqs).length > 0) {
var key = keys(reqs)[0];
with_req('GET', reqs[key], null, function(resp) {
acc[key] = JSON.parse(resp.responseText);
if (key.startsWith("extra_")) {
var extraContent = acc["extra_content"];
extraContent[key] = JSON.parse(resp.responseText);
acc["extra_content"] = extraContent;
} else {
acc[key] = JSON.parse(resp.responseText);
}
var remainder = {};
for (var k in reqs) {
if (k != key) remainder[k] = reqs[k];
Expand Down Expand Up @@ -1152,6 +1160,14 @@ function format(template, json) {
}
}

function maybe_format_extra_queue_content(queue, extraContent) {
var content = '';
for (var i = 0; i < QUEUE_EXTRA_CONTENT.length; i++) {
content += QUEUE_EXTRA_CONTENT[i](queue, extraContent);
}
return content;
}

function update_status(status) {
var text;
if (status == 'ok')
Expand Down
3 changes: 3 additions & 0 deletions deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs
Expand Up @@ -267,6 +267,9 @@
<% } %>

<% if(!disable_stats) { %>
<%= maybe_format_extra_queue_content(queue, extra_content) %>
<% } %>

<% if(!disable_stats) { %>
<div class="section-hidden">
Expand Down
16 changes: 15 additions & 1 deletion deps/rabbitmq_stream_management/priv/www/js/stream.js
Expand Up @@ -61,4 +61,18 @@ CONSUMER_OWNER_FORMATTERS.push({
}
});

CONSUMER_OWNER_FORMATTERS.sort(CONSUMER_OWNER_FORMATTERS_COMPARATOR);
CONSUMER_OWNER_FORMATTERS.sort(CONSUMER_OWNER_FORMATTERS_COMPARATOR);

QUEUE_EXTRA_CONTENT_REQUESTS.push(function(vhost, queue) {
return {'extra_stream_publishers' : '/stream/publishers'};
});

QUEUE_EXTRA_CONTENT.push(function(queue, extraContent) {
if (is_stream(queue)) {
return '<div class="section"><h2>Stream publishers</h2><div class="hider updatable">' +
format('streamPublishersList', {'publishers': extraContent['extra_stream_publishers']}) +
'</div></div>';
} else {
return '';
}
});

0 comments on commit 9778d97

Please sign in to comment.