Fix provision tool connect error handling (#879)
Signed-off-by: Dušan Borovčanin <dusan.borovcanin@mainflux.com>
This commit is contained in:
parent
93d939ea52
commit
23b421bdc5
|
@ -88,7 +88,7 @@ func (c *Client) publish(r chan *runResults) {
|
||||||
|
|
||||||
for i := 0; i < c.MsgCount; i++ {
|
for i := 0; i < c.MsgCount; i++ {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(mut *sync.Mutex, wg *sync.WaitGroup, t *[]*float64, i int, m message) {
|
go func(mut *sync.Mutex, wg *sync.WaitGroup, i int, m message) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
m.Sent = time.Now()
|
m.Sent = time.Now()
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ func (c *Client) publish(r chan *runResults) {
|
||||||
if !c.Quiet && i > 0 && i%100 == 0 {
|
if !c.Quiet && i > 0 && i%100 == 0 {
|
||||||
log.Printf("Client %v published %v messages and keeps publishing...\n", c.ID, i)
|
log.Printf("Client %v published %v messages and keeps publishing...\n", c.ID, i)
|
||||||
}
|
}
|
||||||
}(&mu, &wg, ×, i, m)
|
}(&mu, &wg, i, m)
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ func Provision(conf Config) {
|
||||||
|
|
||||||
cid, err := s.CreateChannel(sdk.Channel{Name: fmt.Sprintf("%s-channel-%d", conf.Prefix, i)}, token)
|
cid, err := s.CreateChannel(sdk.Channel{Name: fmt.Sprintf("%s-channel-%d", conf.Prefix, i)}, token)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf(err.Error())
|
log.Fatalf("Failed to create the channel: %s", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
channels[i] = &cid
|
channels[i] = &cid
|
||||||
|
@ -215,13 +215,18 @@ func Provision(conf Config) {
|
||||||
fmt.Printf("# List of channels that things can publish to\n" +
|
fmt.Printf("# List of channels that things can publish to\n" +
|
||||||
"# each channel is connected to each thing from things list\n")
|
"# each channel is connected to each thing from things list\n")
|
||||||
for i := 0; i < conf.Num; i++ {
|
for i := 0; i < conf.Num; i++ {
|
||||||
for j := 0; j < conf.Num; j++ {
|
// Creating a new routine for each connect
|
||||||
|
// might be heavy on the network.
|
||||||
|
go func(wg *sync.WaitGroup, i int) {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(wg *sync.WaitGroup, i, j int) {
|
defer wg.Done()
|
||||||
defer wg.Done()
|
|
||||||
s.ConnectThing(things[j].ID, *channels[i], token)
|
for j := 0; j < conf.Num; j++ {
|
||||||
}(&wg, i, j)
|
if err := s.ConnectThing(things[j].ID, *channels[i], token); err != nil {
|
||||||
}
|
log.Fatalf("Failed to connect thing %s to channel %s: %s", things[j].ID, *channels[i], err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}(&wg, i)
|
||||||
fmt.Printf("[[channels]]\nchannel_id = \"%s\"\n\n", *channels[i])
|
fmt.Printf("[[channels]]\nchannel_id = \"%s\"\n\n", *channels[i])
|
||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
|
|
Loading…
Reference in New Issue