Skip to content

Commit

Permalink
The info command now prints connection related information when used …
Browse files Browse the repository at this point in the history
…with the --consumers options.

Example:

  :
  └── test-topic (exchange, type 'topic', [AD])
        ├── test-q-test-topic-0 (queue, key='test-q-test-topic-0', running, [])
        │   └── __rabtap-consumer-9873af4b (consumer user='guest', chan='172.17.0.1:42068 -> 172.17.0.2:5672 (1)')
        │       └── '172.17.0.1:42068 -> 172.17.0.2:5672' (connection client='https://github.com/streadway/amqp', host='172.17.0.2:5672', peer='172.17.0.1:42068')
        :
  • Loading branch information
jandelgado committed Apr 28, 2018
1 parent 0024bd5 commit d90a54b
Show file tree
Hide file tree
Showing 16 changed files with 594 additions and 213 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Changelog

## [unreleased]

### Added
* `--consumers` option of the `info` command now prints also information on
the connection.

### Changed
* minor changes to output of `info` command (i.e. some values now are quoted)



2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ Options:
--api APIURI connect to given API server. If APIURI is omitted,
the environment variable RABTAP_APIURI will be used.
-b, --bindingkey KEY binding key to use in bind queue command.
--consumers include consumers in output of info command.
--consumers include consumers and connections in output of info command.
-d, --durable create durable exchange/queue.
-h, --help print this help.
-j, --json print/save/publish message metadata and body to a
Expand Down
32 changes: 22 additions & 10 deletions cmd/main/broker_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import "github.com/jandelgado/rabtap/pkg"

// BrokerInfo collects information of an RabbitMQ broker
type BrokerInfo struct {
Overview rabtap.RabbitOverview
Exchanges []rabtap.RabbitExchange
Queues []rabtap.RabbitQueue
Bindings []rabtap.RabbitBinding
Consumers []rabtap.RabbitConsumer
Overview rabtap.RabbitOverview
Exchanges []rabtap.RabbitExchange
Queues []rabtap.RabbitQueue
Bindings []rabtap.RabbitBinding
Connections []rabtap.RabbitConnection
Consumers []rabtap.RabbitConsumer
// Channels []rabtap.RabbitChannel // not yet used.
}

// NewBrokerInfo obtains infos on broker using the provided client object
Expand All @@ -20,30 +22,40 @@ func NewBrokerInfo(client *rabtap.RabbitHTTPClient) (BrokerInfo, error) {
var bi BrokerInfo

// collect infos from rabtap.RabbitMQ API
bi.Overview, err = client.GetOverview()
bi.Overview, err = client.Overview()
if err != nil {
return bi, err
}

bi.Exchanges, err = client.GetExchanges()
bi.Exchanges, err = client.Exchanges()
if err != nil {
return bi, err
}

bi.Bindings, err = client.GetBindings()
bi.Bindings, err = client.Bindings()
if err != nil {
return bi, err
}

bi.Queues, err = client.GetQueues()
bi.Queues, err = client.Queues()
if err != nil {
return bi, err
}

bi.Consumers, err = client.GetConsumers()
bi.Connections, err = client.Connections()
if err != nil {
return bi, err
}

bi.Consumers, err = client.Consumers()
if err != nil {
return bi, err
}

// bi.Channels, err = client.Channels()
// if err != nil {
// return bi, err
// }

return bi, nil
}

0 comments on commit d90a54b

Please sign in to comment.