Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions pgdog/src/admin/show_listeners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ impl Command for ShowListeners {

let mut messages = vec![
RowDescription::new(&[
Field::text("database"),
Field::text("user"),
Field::numeric("shard"),
Field::text("channel"),
Field::numeric("listeners"),
Field::numeric("received"),
Expand All @@ -30,10 +33,13 @@ impl Command for ShowListeners {
.message()?,
];

for (channel, stats) in channels {
for (key, stats) in channels {
let mut data_row = DataRow::new();
data_row
.add(channel.as_str())
.add(key.pool.database.as_str())
.add(key.pool.user.as_str())
.add(key.pool.shard as i64)
.add(key.channel.as_str())
.add(stats.listeners as i64)
.add(stats.recv as i64)
.add(stats.dropped as i64);
Expand Down Expand Up @@ -67,6 +73,17 @@ mod tests {
.map(|field| field.name.as_str())
.collect();

assert_eq!(columns, ["channel", "listeners", "received", "dropped"]);
assert_eq!(
columns,
[
"database",
"user",
"shard",
"channel",
"listeners",
"received",
"dropped"
]
);
}
}
4 changes: 3 additions & 1 deletion pgdog/src/backend/pool/shard/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,9 @@ impl Shard {
// This is useful if we promoted a primary
// from a replica.
let primary = self.lb.primary().cloned();
let pub_sub = primary.as_ref().map(PubSubListener::new);
let pub_sub = primary
.as_ref()
.map(|primary| PubSubListener::new(primary, self.identifier(), self.number()));

// Launch the new listener first!
if let Some(ref pub_sub) = pub_sub {
Expand Down
Loading
Loading