Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nsqadmin: refactoring #323

Merged
merged 18 commits into from
Aug 7, 2015
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.godeps
build
./build
apps/nsqlookupd/nsqlookupd
apps/nsqd/nsqd
apps/nsqadmin/nsqadmin
Expand All @@ -13,6 +13,7 @@ apps/nsq_to_http/nsq_to_http
apps/nsq_tail/nsq_tail
apps/nsq_stat/nsq_stat
apps/to_nsq/to_nsq
nsqadmin/static/build
dist
_site
_posts
Expand Down
2 changes: 1 addition & 1 deletion Godeps
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
github.com/BurntSushi/toml 2dff11163ee667d51dcc066660925a92ce138deb
github.com/bitly/go-hostpool 58b95b10d6ca26723a7f46017b348653b825a8d6
github.com/bitly/go-nsq 4271cd1529a78175e327570894988cc2cb21228f # v1.0.5-alpha
github.com/bitly/go-simplejson fc395a5db941cf38922b1ccbc083640cd76fe4bc # v0.5.0-alpha
github.com/bitly/go-simplejson 18db6e68d8fd9cbf2e8ebe4c81a78b96fd9bf05a
github.com/bmizerany/perks/quantile 6cb9d9d729303ee2628580d9aec5db968da3a607
github.com/mreiferson/go-options 2cf7eb1fdd83e2bb3375fef6fdadb04c3ad564da
github.com/mreiferson/go-snappystream 028eae7ab5c4c9e2d1cb4c4ca1e53259bbe7e504 # v0.2.3
Expand Down
11 changes: 6 additions & 5 deletions apps/nsq_stat/nsq_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
"time"

"github.com/bitly/nsq/internal/app"
"github.com/bitly/nsq/internal/lookupd"
"github.com/bitly/nsq/internal/clusterinfo"
"github.com/bitly/nsq/internal/version"
)

Expand Down Expand Up @@ -57,24 +57,25 @@ func init() {

func statLoop(interval time.Duration, topic string, channel string,
nsqdTCPAddrs []string, lookupdHTTPAddrs []string) {
var o *lookupd.ChannelStats
ci := clusterinfo.New(nil)
var o *clusterinfo.ChannelStats
for i := 0; !countNum.isSet || countNum.value >= i; i++ {
var producers []string
var err error

log.SetOutput(ioutil.Discard)
if len(lookupdHTTPAddrs) != 0 {
producers, err = lookupd.GetLookupdTopicProducers(topic, lookupdHTTPAddrs)
producers, err = ci.GetLookupdTopicProducers(topic, lookupdHTTPAddrs)
} else {
producers, err = lookupd.GetNSQDTopicProducers(topic, nsqdHTTPAddrs)
producers, err = ci.GetNSQDTopicProducers(topic, nsqdHTTPAddrs)
}
log.SetOutput(os.Stdout)
if err != nil {
log.Fatalf("ERROR: failed to get topic producers - %s", err)
}

log.SetOutput(ioutil.Discard)
_, allChannelStats, err := lookupd.GetNSQDStats(producers, topic)
_, allChannelStats, err := ci.GetNSQDStats(producers, topic)
log.SetOutput(os.Stdout)
if err != nil {
log.Fatalf("ERROR: failed to get nsqd stats - %s", err)
Expand Down
6 changes: 3 additions & 3 deletions apps/nsq_to_file/nsq_to_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/bitly/go-nsq"
"github.com/bitly/nsq/internal/app"
"github.com/bitly/nsq/internal/lookupd"
"github.com/bitly/nsq/internal/clusterinfo"
"github.com/bitly/nsq/internal/version"
)

Expand Down Expand Up @@ -414,7 +414,7 @@ func (t *TopicDiscoverer) allowTopicName(pattern string, name string) bool {
}

func (t *TopicDiscoverer) syncTopics(addrs []string, pattern string) {
newTopics, err := lookupd.GetLookupdTopics(addrs)
newTopics, err := clusterinfo.New(nil).GetLookupdTopics(addrs)
if err != nil {
log.Printf("ERROR: could not retrieve topic list: %s", err)
}
Expand Down Expand Up @@ -516,7 +516,7 @@ func main() {
}
topicsFromNSQLookupd = true
var err error
topics, err = lookupd.GetLookupdTopics(lookupdHTTPAddrs)
topics, err = clusterinfo.New(nil).GetLookupdTopics(lookupdHTTPAddrs)
if err != nil {
log.Fatalf("ERROR: could not retrieve topic list: %s", err)
}
Expand Down
4 changes: 2 additions & 2 deletions apps/nsqadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ func main() {
}
}

opts := nsqadmin.NewNSQAdminOptions()
opts := nsqadmin.NewOptions()
options.Resolve(opts, flagSet, cfg)
nsqadmin := nsqadmin.NewNSQAdmin(opts)
nsqadmin := nsqadmin.New(opts)

nsqadmin.Main()
<-exitChan
Expand Down
Loading