mirror of
https://github.com/weaveworks/scope.git
synced 2026-07-28 01:31:17 +00:00
Review feedback
This commit is contained in:
@@ -90,8 +90,8 @@ func main() {
|
||||
}
|
||||
log.Printf("publishing to: %s", strings.Join(targets, ", "))
|
||||
|
||||
factory := func(endpoint, hostname string) (string, xfer.Publisher, error) {
|
||||
id, publisher, err := xfer.NewHTTPPublisher(endpoint, hostname, *token, probeID, *insecure)
|
||||
factory := func(hostname, endpoint string) (string, xfer.Publisher, error) {
|
||||
id, publisher, err := xfer.NewHTTPPublisher(hostname, endpoint, *token, probeID, *insecure)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ func getHTTPTransport(hostname string, insecure bool) (*http.Transport, error) {
|
||||
}
|
||||
|
||||
// NewHTTPPublisher returns an HTTPPublisher ready for use.
|
||||
func NewHTTPPublisher(target, hostname, token, probeID string, insecure bool) (string, *HTTPPublisher, error) {
|
||||
func NewHTTPPublisher(hostname, target, token, probeID string, insecure bool) (string, *HTTPPublisher, error) {
|
||||
httpTransport, err := getHTTPTransport(hostname, insecure)
|
||||
if err != nil {
|
||||
return "", nil, err
|
||||
|
||||
@@ -72,7 +72,7 @@ func TestHTTPPublisher(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
_, p, err := xfer.NewHTTPPublisher(s.URL, u.Host, token, id, false)
|
||||
_, p, err := xfer.NewHTTPPublisher(u.Host, s.URL, token, id, false)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -14,13 +14,13 @@ import (
|
||||
// targets. See documentation of each method to understand the semantics.
|
||||
type MultiPublisher struct {
|
||||
mtx sync.Mutex
|
||||
factory func(endpoint, hostname string) (string, Publisher, error)
|
||||
factory func(hostname, endpoint string) (string, Publisher, error)
|
||||
sema semaphore
|
||||
list []tuple
|
||||
}
|
||||
|
||||
// NewMultiPublisher returns a new MultiPublisher ready for use.
|
||||
func NewMultiPublisher(factory func(endpoint, hostname string) (string, Publisher, error)) *MultiPublisher {
|
||||
func NewMultiPublisher(factory func(hostname, endpoint string) (string, Publisher, error)) *MultiPublisher {
|
||||
return &MultiPublisher{
|
||||
factory: factory,
|
||||
sema: newSemaphore(maxConcurrentGET),
|
||||
@@ -49,7 +49,7 @@ func (p *MultiPublisher) Set(target string, endpoints []string) {
|
||||
go func(endpoint string) {
|
||||
p.sema.p()
|
||||
defer p.sema.v()
|
||||
id, publisher, err := p.factory(endpoint, target)
|
||||
id, publisher, err := p.factory(target, endpoint)
|
||||
c <- tuple{publisher, target, endpoint, id, err}
|
||||
}(endpoint)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ func TestMultiPublisher(t *testing.T) {
|
||||
|
||||
sum := func() int { return a1.count + a2.count + b2.count + b3.count }
|
||||
|
||||
mp := xfer.NewMultiPublisher(func(endpoint, hostname string) (string, xfer.Publisher, error) {
|
||||
mp := xfer.NewMultiPublisher(func(hostname, endpoint string) (string, xfer.Publisher, error) {
|
||||
switch endpoint {
|
||||
case "a1":
|
||||
return "1", a1, nil
|
||||
|
||||
Reference in New Issue
Block a user