Skip to content
This repository has been archived by the owner on Aug 31, 2022. It is now read-only.

Add reportType "once" in function publishRun of dialout_client.go #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 41 additions & 1 deletion dialout/dialout_client/dialout_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,54 @@ restart: //Remote server might go down, in that case we restart with next destin
}
cs.Close()
cs.w.Wait()
// Don't restart immediatly
// Don't restart immediately
time.Sleep(clientCfg.RetryInterval)
goto restart

case <-cs.stop:
log.V(1).Infof("%v exiting publishRun routine for destination %s", cs, dest)
return
}
case Once:
select {
default:
spbValues, err := cs.dc.Get(nil)
if err != nil {
log.V(2).Infof("Data read error %v for %v", err, cs)
}
var updates []*gpb.Update
var spbValue *spb.Value
for _, spbValue = range spbValues {
update := &gpb.Update{
Path: spbValue.GetPath(),
Val: spbValue.GetVal(),
}
updates = append(updates, update)
}
rs := &gpb.SubscribeResponse_Update{
Update: &gpb.Notification{
Timestamp: spbValue.GetTimestamp(),
Prefix: cs.prefix,
Update: updates,
},
}
response := &gpb.SubscribeResponse{Response: rs}

log.V(6).Infof("cs %s sending \n\t%v \n To %s", cs.name, response, dest)
err = pub.Send(response)
if err != nil {
log.V(1).Infof("Client %v pub Send error:%v, cs.conTryCnt %v", cs.name, err, cs.conTryCnt)
cs.Close()
// Retry
goto restart
}
log.V(6).Infof("cs %s to %s done", cs.name, dest)
cs.sendMsg++
c.sendMsg++
case <-cs.stop:
log.V(1).Infof("%v exiting publishRun routine for destination %s", cs, dest)
return
}
default:
log.V(1).Infof("Unsupported report type %s in %v ", cs.reportType, cs)
}
Expand Down