From 05755114c6cb9a983bf903a2b1e4ea9c3cce09a1 Mon Sep 17 00:00:00 2001 From: Jose Luis Lucas Date: Thu, 29 Nov 2018 15:16:10 +0100 Subject: [PATCH] Tune publisher behaviour --- gossip/publisher/publisher.go | 7 +++---- tests/gossip/run_gossip.sh | 7 ++++--- tests/gossip/test_service.go | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/gossip/publisher/publisher.go b/gossip/publisher/publisher.go index 7b6d5dd37..a6ff06fb3 100644 --- a/gossip/publisher/publisher.go +++ b/gossip/publisher/publisher.go @@ -50,7 +50,7 @@ func NewPublisher(conf *Config) *Publisher { } } -func (p Publisher) Process(b *protocol.BatchSnapshots) { +func (p *Publisher) Process(b *protocol.BatchSnapshots) { body, err := json.Marshal(&b) if err != nil { log.Debug("\nPublisher: Error marshalling: %s", err.Error()) @@ -59,16 +59,15 @@ func (p Publisher) Process(b *protocol.BatchSnapshots) { req := fasthttp.AcquireRequest() // TODO: Implement send to different endpoints - req.SetRequestURI(p.Config.SendTo[0]) + req.SetRequestURI(p.Config.SendTo[0] + "/publish") req.Header.SetMethodBytes([]byte("POST")) req.Header.Add("Content-Type", "application/json") req.SetBody(body) - res := fasthttp.AcquireResponse() err = p.Config.Client.Do(req, res) if err != nil { - log.Debug("\nPublisher: Error sending request to publishers: %s", err.Error()) + log.Info("\nPublisher: Error sending request to publishers: %s", err.Error()) return } diff --git a/tests/gossip/run_gossip.sh b/tests/gossip/run_gossip.sh index da12057ca..2937c5af0 100644 --- a/tests/gossip/run_gossip.sh +++ b/tests/gossip/run_gossip.sh @@ -12,6 +12,7 @@ # limitations under the License. master="127.0.0.1:9100" +publisher="http://127.0.0.1:8888" qed="http://127.0.0.1:8080" echo Create id_ed25519 key echo -e 'y\n' | ssh-keygen -t rsa -N '' -f /var/tmp/id_ed25519 @@ -21,19 +22,19 @@ sleep 1s for i in `seq 1 $1`; do - xterm -hold -e "go run $GOPATH/src/github.com/bbva/qed/main.go agent auditor -k key -l silent --bind 127.0.0.1:910$i --join $master --endpoints $qed --node auditor$i" & + xterm -hold -e "go run $GOPATH/src/github.com/bbva/qed/main.go agent auditor -k key -l info --bind 127.0.0.1:910$i --join $master --endpoints $qed --node auditor$i" & pids+=($!) done for i in `seq 1 $2`; do - xterm -hold -e "go run $GOPATH/src/github.com/bbva/qed/main.go agent monitor -k key -l silent --bind 127.0.0.1:920$i --join $master --endpoints $qed --node monitor$i" & + xterm -hold -e "go run $GOPATH/src/github.com/bbva/qed/main.go agent monitor -k key -l info --bind 127.0.0.1:920$i --join $master --endpoints $qed --node monitor$i" & pids+=($!) done for i in `seq 1 $3`; do - xterm -hold -e "go run $GOPATH/src/github.com/bbva/qed/main.go agent publisher -k key -l silent --bind 127.0.0.1:930$i --join $master --endpoints $qed --node publisher$i" & + xterm -hold -e "go run $GOPATH/src/github.com/bbva/qed/main.go agent publisher -k key -l info --bind 127.0.0.1:930$i --join $master --endpoints $publisher --node publisher$i" & pids+=($!) done diff --git a/tests/gossip/test_service.go b/tests/gossip/test_service.go index 053a469d4..24aeb8f3c 100644 --- a/tests/gossip/test_service.go +++ b/tests/gossip/test_service.go @@ -107,7 +107,8 @@ func (s *stats) Get(nodeType string, id int) int { func (s *stats) Print() { s.Lock() defer s.Unlock() - b, err := json.MarshalIndent(s.batch, "", " ") + b, err := json.Marshal(s.batch) + //b, err := json.MarshalIndent(s.batch, "", " ") if err == nil { fmt.Println(string(b)) }