Add check_leader command to lavinmqctl #1691
annieblomgren
started this conversation in
Ideas
Replies: 1 comment
-
|
just an idea from Claude, Erik, Håkan and I :) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
This adds a
check_leadercommand tolavinmqctlthat quickly displays which node is the current cluster leader.Motivation
The existing
cluster_statuscommand showsthis_node,version, andfollowers, but there's no dedicated way to quickly check which node is the leader. In scripting and monitoring scenarios, a lightweight single-purpose command is more convenient than parsing the full cluster status output.Since
lavinmqctlalways communicates with the leader node (followers either return 503 on the internal socket or proxy HTTP requests to the leader), thenamefield from/api/nodesreliably identifies the leader.Usage
$ lavinmqctl check_leader leader: MacBook-Pro-4.local $ lavinmqctl check_leader --format=json {"leader":"MacBook-Pro-4.local"}Implementation
The command calls the existing
/api/nodesAPI endpoint, extracts the first node'snamefield, and outputs it. It follows the same pattern asstatusandcluster_status— no new API endpoints or dependencies are needed.Files changed:
src/lavinmqctl/cli.cr— command registration, dispatch, and implementationspec/lavinmqctl_spec.cr— testBranch:
add-leader-commandUse cases
LEADER=$(lavinmqctl check_leader --format=json | jq -r .leader)for use in automationBeta Was this translation helpful? Give feedback.
All reactions