Skip to content

Commit

Permalink
Merge pull request #4 from inovex/improve_mqtt_client_id
Browse files Browse the repository at this point in the history
make it easier to identify MQTT client IDs and topic name
  • Loading branch information
arnisoph committed Jul 25, 2017
2 parents caa41b5 + 244f39e commit 493ad5a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ var (
tearDownInProgress = false
randomSource = rand.New(rand.NewSource(time.Now().UnixNano()))

subscriberClientIdTemplate = "test-client-s-%d-%d"
publisherClientIdTemplate = "test-client-p-%d-%d"
topicNameTemplate = "internal/monitoring/endToEndXx-%d-%d"
subscriberClientIdTemplate = "mqtt-stresser-sub-%s-worker%d-%d"
publisherClientIdTemplate = "mqtt-stresser-pub-%s-worker%d-%d"
topicNameTemplate = "internal/mqtt-stresser/%s/worker%d-%d"

opTimeout = 5 * time.Second

Expand Down
11 changes: 8 additions & 3 deletions worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ func (w *Worker) Run() {
cid := w.WorkerId
t := randomSource.Int31()

topicName := fmt.Sprintf(topicNameTemplate, w.WorkerId, t)
subscriberClientId := fmt.Sprintf(subscriberClientIdTemplate, w.WorkerId, t)
publisherClientId := fmt.Sprintf(publisherClientIdTemplate, w.WorkerId, t)
hostname, err := os.Hostname()
if err != nil {
panic(err)
}

topicName := fmt.Sprintf(topicNameTemplate, hostname, w.WorkerId, t)
subscriberClientId := fmt.Sprintf(subscriberClientIdTemplate, hostname, w.WorkerId, t,)
publisherClientId := fmt.Sprintf(publisherClientIdTemplate, hostname, w.WorkerId, t)

verboseLogger.Printf("[%d] topic=%s subscriberClientId=%s publisherClientId=%s\n", cid, topicName, subscriberClientId, publisherClientId)

Expand Down

0 comments on commit 493ad5a

Please sign in to comment.