Esempio n. 1
0
func (r *Router) SendStartMessage() {
	host, err := vcap.LocalIP()
	if err != nil {
		panic(err)
	}
	d := vcap.RouterStart{vcap.GenerateUUID(), []string{host}}

	b, err := json.Marshal(d)
	if err != nil {
		panic(err)
	}

	// Send start message once at start
	r.natsClient.Publish("router.start", b)

	go func() {
		t := time.NewTicker(r.config.PublishStartMessageInterval)

		for {
			select {
			case <-t.C:
				r.natsClient.Publish("router.start", b)
			}
		}
	}()
}
Esempio n. 2
0
func (r *Router) SendStartMessage() {
	host, err := vcap.LocalIP()
	if err != nil {
		panic(err)
	}
	d := vcap.RouterStart{vcap.GenerateUUID(), []string{host}}

	b, err := json.Marshal(d)
	if err != nil {
		panic(err)
	}

	// Send start message once at start
	r.mbusClient.Publish("router.start", b)

	go func() {
		t := time.NewTicker(r.config.PublishStartMessageInterval)

		for {
			select {
			case <-t.C:
				log.Info("Sending start message")
				err := r.mbusClient.Publish("router.start", b)
				if err != nil {
					log.Errorf("Error publishing to router.start: %s", err.Error())
				}
			}
		}
	}()
}
Esempio n. 3
0
func (r *Router) greetMessage() ([]byte, error) {
	host, err := vcap.LocalIP()
	if err != nil {
		return nil, err
	}

	d := vcap.RouterStart{
		vcap.GenerateUUID(),
		[]string{host},
		r.config.StartResponseDelayIntervalInSeconds,
	}

	return json.Marshal(d)
}
Esempio n. 4
0
func (a *TestApp) Register() {
	rm := registerMessage{
		Host: "localhost",
		Port: a.port,
		Uris: a.urls,
		Tags: a.tags,
		Dea:  "dea",
		App:  "0",

		PrivateInstanceId: common.GenerateUUID(),
	}

	b, _ := json.Marshal(rm)
	a.mbusClient.Publish("router.register", b)
}