Skip to content

Commit

Permalink
*: remove deprecated features
Browse files Browse the repository at this point in the history
  • Loading branch information
mreiferson committed Aug 11, 2015
1 parent a305368 commit 925b0a0
Show file tree
Hide file tree
Showing 23 changed files with 110 additions and 578 deletions.
5 changes: 0 additions & 5 deletions apps/nsq_stat/nsq_stat.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ var (
showVersion = flag.Bool("version", false, "print version")
topic = flag.String("topic", "", "NSQ topic")
channel = flag.String("channel", "", "NSQ channel")
statusEvery = flag.Duration("status-every", -1, "(deprecated) duration of time between polling/printing output")
interval = flag.Duration("interval", 2*time.Second, "duration of time between polling/printing output")
countNum = numValue{}
nsqdHTTPAddrs = app.StringArray{}
Expand Down Expand Up @@ -145,10 +144,6 @@ func main() {
}

intvl := *interval
if *statusEvery != -1 {
log.Printf("--status-every is deprecated, use --interval")
intvl = *statusEvery
}
if int64(intvl) <= 0 {
log.Fatal("--interval should be positive")
}
Expand Down
2 changes: 0 additions & 2 deletions apps/nsq_tail/nsq_tail.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ var (
)

func init() {
// TODO: remove, deprecated
flag.Var(&consumerOpts, "reader-opt", "(deprecated) use --consumer-opt")
flag.Var(&consumerOpts, "consumer-opt", "option to passthrough to nsq.Consumer (may be given multiple times, http://godoc.org/github.com/bitly/go-nsq#Config)")

flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
Expand Down
25 changes: 2 additions & 23 deletions apps/nsq_to_file/nsq_to_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,9 @@ var (
nsqdTCPAddrs = app.StringArray{}
lookupdHTTPAddrs = app.StringArray{}
topics = app.StringArray{}

// TODO: remove, deprecated
gzipCompression = flag.Int("gzip-compression", 3, "(deprecated) use --gzip-level, gzip compression level (1 = BestSpeed, 2 = BestCompression, 3 = DefaultCompression)")
)

func init() {
// TODO: remove, deprecated
flag.Var(&consumerOpts, "reader-opt", "(deprecated) use --consumer-opt")
flag.Var(&consumerOpts, "consumer-opt", "option to passthrough to nsq.Consumer (may be given multiple times, http://godoc.org/github.com/bitly/go-nsq#Config)")

flag.Var(&nsqdTCPAddrs, "nsqd-tcp-address", "nsqd TCP address (may be given multiple times)")
Expand Down Expand Up @@ -312,13 +307,12 @@ func (f *FileLogger) updateFile() {
}

func NewFileLogger(gzipEnabled bool, compressionLevel int, filenameFormat, topic string) (*FileLogger, error) {
// TODO: remove, deprecated, for compat <GZIPREV>
filenameFormat = strings.Replace(filenameFormat, "<GZIPREV>", "<REV>", -1)
if gzipEnabled || *rotateSize > 0 || *rotateInterval > 0 {
if strings.Index(filenameFormat, "<REV>") == -1 {
return nil, errors.New("missing <REV> in --filename-format when gzip or rotation enabled")
}
} else { // remove <REV> as we don't need it
} else {
// remove <REV> as we don't need it
filenameFormat = strings.Replace(filenameFormat, "<REV>", "", -1)
}

Expand Down Expand Up @@ -490,21 +484,6 @@ func main() {
log.Fatalf("invalid --gzip-level value (%d), should be 1-9", *gzipLevel)
}

// TODO: remove, deprecated
if hasArg("gzip-compression") {
log.Printf("WARNING: --gzip-compression is deprecated in favor of --gzip-level")
switch *gzipCompression {
case 1:
*gzipLevel = gzip.BestSpeed
case 2:
*gzipLevel = gzip.BestCompression
case 3:
*gzipLevel = gzip.DefaultCompression
default:
log.Fatalf("invalid --gzip-compression value (%d), should be 1,2,3", *gzipCompression)
}
}

discoverer := newTopicDiscoverer()

signal.Notify(discoverer.hupChan, syscall.SIGHUP)
Expand Down
37 changes: 1 addition & 36 deletions apps/nsq_to_http/nsq_to_http.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ var (
maxInFlight = flag.Int("max-in-flight", 200, "max number of messages to allow in flight")

numPublishers = flag.Int("n", 100, "number of concurrent publishers")
mode = flag.String("mode", "hostpool", "the upstream request mode options: multicast, round-robin, hostpool (default), epsilon-greedy")
mode = flag.String("mode", "hostpool", "the upstream request mode options: round-robin, hostpool (default), epsilon-greedy")
sample = flag.Float64("sample", 1.0, "% of messages to publish (float b/w 0 -> 1)")
httpTimeout = flag.Duration("http-timeout", 20*time.Second, "timeout for HTTP connect/read/write (each)")
statusEvery = flag.Int("status-every", 250, "the # of requests between logging status (per handler), 0 disables")
Expand All @@ -51,17 +51,9 @@ var (
postAddrs = app.StringArray{}
nsqdTCPAddrs = app.StringArray{}
lookupdHTTPAddrs = app.StringArray{}

// TODO: remove, deprecated
roundRobin = flag.Bool("round-robin", false, "(deprecated) use --mode=round-robin, enable round robin mode")
maxBackoffDuration = flag.Duration("max-backoff-duration", 120*time.Second, "(deprecated) use --consumer-opt=max_backoff_duration,X")
throttleFraction = flag.Float64("throttle-fraction", 1.0, "(deprecated) use --sample=X, publish only a fraction of messages")
httpTimeoutMs = flag.Int("http-timeout-ms", 20000, "(deprecated) use --http-timeout=X, timeout for HTTP connect/read/write (each)")
)

func init() {
// TODO: remove, deprecated
flag.Var(&consumerOpts, "reader-opt", "(deprecated) use --consumer-opt")
flag.Var(&consumerOpts, "consumer-opt", "option to passthrough to nsq.Consumer (may be given multiple times, http://godoc.org/github.com/bitly/go-nsq#Config)")

flag.Var(&postAddrs, "post", "HTTP address to make a POST request to. data will be in the body (may be given multiple times)")
Expand Down Expand Up @@ -217,37 +209,16 @@ func main() {
}

switch *mode {
case "multicast":
log.Printf("WARNING: multicast mode is deprecated in favor of using separate nsq_to_http on different channels (and will be dropped in a future release)")
selectedMode = ModeAll
case "round-robin":
selectedMode = ModeRoundRobin
case "hostpool", "epsilon-greedy":
selectedMode = ModeHostPool
}

// TODO: remove, deprecated
if hasArg("--round-robin") {
log.Printf("WARNING: --round-robin is deprecated in favor of --mode=round-robin")
selectedMode = ModeRoundRobin
}

// TODO: remove, deprecated
if hasArg("throttle-fraction") {
log.Printf("WARNING: --throttle-fraction is deprecatedin favor of --sample=X")
*sample = *throttleFraction
}

if *sample > 1.0 || *sample < 0.0 {
log.Fatal("ERROR: --sample must be between 0.0 and 1.0")
}

// TODO: remove, deprecated
if hasArg("http-timeout-ms") {
log.Printf("WARNING: --http-timeout-ms is deprecated in favor of --http-timeout=X")
*httpTimeout = time.Duration(*httpTimeoutMs) * time.Millisecond
}

termChan := make(chan os.Signal, 1)
signal.Notify(termChan, syscall.SIGINT, syscall.SIGTERM)

Expand All @@ -267,12 +238,6 @@ func main() {
}
cfg.MaxInFlight = *maxInFlight

// TODO: remove, deprecated
if hasArg("max-backoff-duration") {
log.Printf("WARNING: --max-backoff-duration is deprecated in favor of --consumer-opt=max_backoff_duration,X")
cfg.MaxBackoffDuration = *maxBackoffDuration
}

consumer, err := nsq.NewConsumer(*topic, *channel, cfg)
if err != nil {
log.Fatal(err)
Expand Down
11 changes: 0 additions & 11 deletions apps/nsq_to_nsq/nsq_to_nsq.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,9 @@ var (

requireJSONField = flag.String("require-json-field", "", "for JSON messages: only pass messages that contain this field")
requireJSONValue = flag.String("require-json-value", "", "for JSON messages: only pass messages in which the required field has this value")

// TODO: remove, deprecated
maxBackoffDuration = flag.Duration("max-backoff-duration", 120*time.Second, "(deprecated) use --consumer-opt=max_backoff_duration,X")
)

func init() {
// TODO: remove, deprecated
flag.Var(&consumerOpts, "reader-opt", "(deprecated) use --consumer-opt")
flag.Var(&consumerOpts, "consumer-opt", "option to passthrough to nsq.Consumer (may be given multiple times, see http://godoc.org/github.com/bitly/go-nsq#Config)")
flag.Var(&producerOpts, "producer-opt", "option to passthrough to nsq.Producer (may be given multiple times, see http://godoc.org/github.com/bitly/go-nsq#Config)")

Expand Down Expand Up @@ -332,12 +327,6 @@ func main() {
}
cCfg.MaxInFlight = *maxInFlight

// TODO: remove, deprecated
if hasArg("max-backoff-duration") {
log.Printf("WARNING: --max-backoff-duration is deprecated in favor of --consumer-opt=max_backoff_duration,X")
cCfg.MaxBackoffDuration = *maxBackoffDuration
}

pCfg := nsq.NewConfig()
pCfg.UserAgent = defaultUA

Expand Down
5 changes: 0 additions & 5 deletions apps/nsqadmin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ var (
showVersion = flagSet.Bool("version", false, "print version string")

httpAddress = flagSet.String("http-address", "0.0.0.0:4171", "<addr>:<port> to listen on for HTTP clients")
templateDir = flagSet.String("template-dir", "", "path to templates directory")

graphiteURL = flagSet.String("graphite-url", "", "graphite HTTP address")
proxyGraphite = flagSet.Bool("proxy-graphite", false, "proxy HTTP requests to graphite")
Expand Down Expand Up @@ -51,10 +50,6 @@ func main() {
return
}

if *templateDir != "" {
log.Printf("WARNING: --template-dir is deprecated and will be removed in the next release (templates are now compiled into the binary)")
}

exitChan := make(chan int)
signalChan := make(chan os.Signal, 1)
go func() {
Expand Down
7 changes: 2 additions & 5 deletions apps/nsqd/nsqd.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (t *tlsVersionOption) String() string {
return strconv.FormatInt(int64(*t), 10)
}

func nsqFlagset() *flag.FlagSet {
func nsqdFlagset() *flag.FlagSet {
flagSet := flag.NewFlagSet("nsqd", flag.ExitOnError)

// basic options
Expand Down Expand Up @@ -105,8 +105,6 @@ func nsqFlagset() *flag.FlagSet {
flagSet.Duration("max-msg-timeout", 15*time.Minute, "maximum duration before a message will timeout")
flagSet.Int64("max-msg-size", 1024768, "maximum size of a single message in bytes")
flagSet.Duration("max-req-timeout", 1*time.Hour, "maximum requeuing timeout for a message")
// remove, deprecated
flagSet.Int64("max-message-size", 1024768, "(deprecated use --max-msg-size) maximum size of a single message in bytes")
flagSet.Int64("max-body-size", 5*1024768, "maximum size of a single command body")

// client overridable configuration options
Expand Down Expand Up @@ -175,8 +173,7 @@ func (cfg config) Validate() {
}

func main() {

flagSet := nsqFlagset()
flagSet := nsqdFlagset()
flagSet.Parse(os.Args[1:])

rand.Seed(time.Now().UTC().UnixNano())
Expand Down
2 changes: 1 addition & 1 deletion apps/nsqd/nsqd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
)

func TestConfigFlagParsing(t *testing.T) {
flagSet := nsqFlagset()
flagSet := nsqdFlagset()
flagSet.Parse([]string{})

var cfg config
Expand Down
3 changes: 1 addition & 2 deletions bench/bench_channels/bench_channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ func subWorker(n int, tcpAddr string,
conn.Write(nsq.MagicV2)
rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
ci := make(map[string]interface{})
ci["short_id"] = "test"
ci["long_id"] = "test"
ci["client_id"] = "test"
cmd, _ := nsq.Identify(ci)
cmd.WriteTo(rw)
nsq.Subscribe(topic, channel).WriteTo(rw)
Expand Down
3 changes: 1 addition & 2 deletions bench/bench_reader/bench_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ func subWorker(td time.Duration, workers int, tcpAddr string, topic string, chan
conn.Write(nsq.MagicV2)
rw := bufio.NewReadWriter(bufio.NewReader(conn), bufio.NewWriter(conn))
ci := make(map[string]interface{})
ci["short_id"] = "test"
ci["long_id"] = "test"
ci["client_id"] = "test"
cmd, _ := nsq.Identify(ci)
cmd.WriteTo(rw)
nsq.Subscribe(topic, channel).WriteTo(rw)
Expand Down
16 changes: 8 additions & 8 deletions internal/clusterinfo/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (c *ClusterInfo) GetVersion(addr string) (semver.Version, error) {
var resp struct {
Version string `json:'version'`
}
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
if err != nil {
c.logf("ERROR: %s - %s", endpoint, err)
return semver.Version{}, err
Expand Down Expand Up @@ -69,7 +69,7 @@ func (c *ClusterInfo) GetLookupdTopics(lookupdHTTPAddrs []string) ([]string, err
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()
if err != nil {
Expand Down Expand Up @@ -109,7 +109,7 @@ func (c *ClusterInfo) GetLookupdTopicChannels(topic string, lookupdHTTPAddrs []s
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()
if err != nil {
Expand Down Expand Up @@ -152,7 +152,7 @@ func (c *ClusterInfo) GetLookupdProducers(lookupdHTTPAddrs []string) ([]*Produce
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()
if err != nil {
Expand Down Expand Up @@ -211,7 +211,7 @@ func (c *ClusterInfo) GetLookupdTopicProducers(topic string, lookupdHTTPAddrs []
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()
if err != nil {
Expand Down Expand Up @@ -255,7 +255,7 @@ func (c *ClusterInfo) GetNSQDTopics(nsqdHTTPAddrs []string) ([]string, error) {
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()
if err != nil {
Expand Down Expand Up @@ -299,7 +299,7 @@ func (c *ClusterInfo) GetNSQDTopicProducers(topic string, nsqdHTTPAddrs []string
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()
if err != nil {
Expand Down Expand Up @@ -348,7 +348,7 @@ func (c *ClusterInfo) GetNSQDStats(nsqdHTTPAddrs []string, selectedTopic string)
defer wg.Done()

var resp respType
err := http_api.NegotiateV1(endpoint, &resp)
err := http_api.GETV1(endpoint, &resp)
lock.Lock()
defer lock.Unlock()

Expand Down
12 changes: 0 additions & 12 deletions internal/clusterinfo/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"sort"
"strings"
"time"

"github.com/bitly/nsq/internal/quantile"
Expand Down Expand Up @@ -186,7 +185,6 @@ func (c *ChannelStats) Add(a *ChannelStats) {
type ClientStats struct {
Node string `json:"node"`
RemoteAddress string `json:"remote_address"`
Name string `json:"name"` // TODO: deprecated, remove in 1.0
Version string `json:"version"`
ClientID string `json:"client_id"`
Hostname string `json:"hostname"`
Expand Down Expand Up @@ -221,16 +219,6 @@ func (s *ClientStats) UnmarshalJSON(b []byte) (err error) {
}
*s = ClientStats(ss)
s.ConnectedDuration = time.Now().Truncate(time.Second).Sub(time.Unix(s.ConnectTs, 0))

if s.ClientID == "" {
// TODO: deprecated, remove in 1.0
remoteAddressParts := strings.Split(s.RemoteAddress, ":")
port := remoteAddressParts[len(remoteAddressParts)-1]
if len(remoteAddressParts) < 2 {
port = "NA"
}
s.ClientID = fmt.Sprintf("%s:%s", s.Name, port)
}
return
}

Expand Down
Loading

0 comments on commit 925b0a0

Please sign in to comment.