Skip to content

Commit

Permalink
Remove old unused methods
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksontj committed Jul 12, 2018
1 parent 7f69bdf commit 0043951
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 57 deletions.
27 changes: 0 additions & 27 deletions promclient/label.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package promclient

import (
"fmt"

"github.com/jacksontj/promxy/promhttputil"
"github.com/prometheus/common/model"
)
Expand All @@ -15,31 +13,6 @@ type LabelResult struct {
Error string `json:"error,omitempty"`
}

func (l *LabelResult) Merge(o *LabelResult) error {
if l.Status == "" {
l.Status = o.Status
l.Data = o.Data
return nil
}
// TODO: need to know all the types and have logic -- pick the worst of the bunch
if l.Status != o.Status {
return fmt.Errorf("mismatch status")
}

labels := make(map[model.LabelValue]struct{})
for _, item := range l.Data {
labels[item] = struct{}{}
}

for _, item := range o.Data {
if _, ok := labels[item]; !ok {
l.Data = append(l.Data, item)
labels[item] = struct{}{}
}
}
return nil
}

func MergeLabelValues(a, b []model.LabelValue) []model.LabelValue {
labels := make(map[model.LabelValue]struct{})
for _, item := range a {
Expand Down
30 changes: 0 additions & 30 deletions promclient/series.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package promclient

import (
"fmt"

"github.com/jacksontj/promxy/promhttputil"
"github.com/prometheus/common/model"
)
Expand All @@ -14,31 +12,3 @@ type SeriesResult struct {
ErrorType promhttputil.ErrorType `json:"errorType,omitempty"`
Error string `json:"error,omitempty"`
}

func (s *SeriesResult) Merge(o *SeriesResult) error {
if s.Status == "" {
s.Status = o.Status
s.Data = o.Data
return nil
}
// TODO: need to know all the types and have logic -- pick the worst of the bunch
if s.Status != o.Status {
return fmt.Errorf("mismatch status")
}

sigs := make(map[model.Fingerprint]struct{})
for _, res := range s.Data {
sigs[res.Fingerprint()] = struct{}{}
}

// TODO; dedupe etc.
for _, result := range o.Data {
// calculate sig
sig := result.Fingerprint()
if _, ok := sigs[sig]; !ok {
s.Data = append(s.Data, result)
sigs[sig] = struct{}{}
}
}
return nil
}

0 comments on commit 0043951

Please sign in to comment.