Skip to content

Commit

Permalink
Make receiver names consistent
Browse files Browse the repository at this point in the history
Fixes lint output.
  • Loading branch information
cespare committed Feb 26, 2015
1 parent a44b475 commit cab1a6a
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
4 changes: 2 additions & 2 deletions apps/nsq_to_file/nsq_to_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ func newTopicDiscoverer() *TopicDiscoverer {
}
}

func (l *FileLogger) HandleMessage(m *nsq.Message) error {
func (f *FileLogger) HandleMessage(m *nsq.Message) error {
m.DisableAutoResponse()
l.logChan <- m
f.logChan <- m
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions nsqlookupd/nsqlookupd.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ func NewNSQLookupd(opts *nsqlookupdOptions) *NSQLookupd {
return n
}

func (n *NSQLookupd) logf(f string, args ...interface{}) {
if n.opts.Logger == nil {
func (l *NSQLookupd) logf(f string, args ...interface{}) {
if l.opts.Logger == nil {
return
}
n.opts.Logger.Output(2, fmt.Sprintf(f, args...))
l.opts.Logger.Output(2, fmt.Sprintf(f, args...))
}

func (l *NSQLookupd) Main() {
Expand Down
48 changes: 23 additions & 25 deletions util/percentile.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,38 +188,36 @@ func (e *E2eProcessingLatencyAggregate) Less(i, j int) bool {
return e.Percentiles[i]["percentile"] > e.Percentiles[j]["percentile"]
}

func (A *E2eProcessingLatencyAggregate) Add(B *E2eProcessingLatencyAggregate, N int) *E2eProcessingLatencyAggregate {
if A == nil {
a := *B
A = &a
func (e *E2eProcessingLatencyAggregate) Add(e2 *E2eProcessingLatencyAggregate, N int) *E2eProcessingLatencyAggregate {
if e == nil {
*e = *e2
} else {
ap := A.Percentiles
bp := B.Percentiles
A.Count += B.Count
for _, value := range bp {
indexA := -1
for i, v := range ap {
p := e.Percentiles
e.Count += e2.Count
for _, value := range e2.Percentiles {
i := -1
for j, v := range p {
if value["quantile"] == v["quantile"] {
indexA = i
i = j
break
}
}
if indexA == -1 {
indexA = len(ap)
A.Percentiles = append(ap, make(map[string]float64))
ap = A.Percentiles
ap[indexA]["quantile"] = value["quantile"]
if i == -1 {
i = len(p)
e.Percentiles = append(p, make(map[string]float64))
p = e.Percentiles
p[i]["quantile"] = value["quantile"]
}
ap[indexA]["max"] = math.Max(value["max"], ap[indexA]["max"])
ap[indexA]["min"] = math.Min(value["max"], ap[indexA]["max"])
p[i]["max"] = math.Max(value["max"], p[i]["max"])
p[i]["min"] = math.Min(value["max"], p[i]["max"])

ap[indexA]["count"] += value["count"]
delta := value["average"] - ap[indexA]["average"]
R := delta * value["count"] / ap[indexA]["count"]
ap[indexA]["average"] = ap[indexA]["average"] + R
p[i]["count"] += value["count"]
delta := value["average"] - p[i]["average"]
R := delta * value["count"] / p[i]["count"]
p[i]["average"] = p[i]["average"] + R
}
}
sort.Sort(A)
A.Addr = "*"
return A
sort.Sort(e)
e.Addr = "*"
return e
}

0 comments on commit cab1a6a

Please sign in to comment.