Skip to content

Commit

Permalink
Tune publisher behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
Jose Luis Lucas committed Nov 29, 2018
1 parent cc20259 commit 0575511
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions gossip/publisher/publisher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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
}

Expand Down
7 changes: 4 additions & 3 deletions tests/gossip/run_gossip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
3 changes: 2 additions & 1 deletion tests/gossip/test_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 0575511

Please sign in to comment.