func (c *Config) Process() { var err error if c.Nats.Uri != "" { u, err := url.Parse(c.Nats.Uri) if err != nil { panic(err) } c.Nats.Host = u.Host if u.User != nil { c.Nats.User = u.User.Username() c.Nats.Pass, _ = u.User.Password() } } c.PublishStartMessageInterval = time.Duration(c.PublishStartMessageIntervalInSeconds) * time.Second c.PruneStaleDropletsInterval = time.Duration(c.PruneStaleDropletsIntervalInSeconds) * time.Second c.DropletStaleThreshold = time.Duration(c.DropletStaleThresholdInSeconds) * time.Second c.PublishActiveAppsInterval = time.Duration(c.PublishActiveAppsIntervalInSeconds) * time.Second c.Ip, err = vcap.LocalIP() if err != nil { panic(err) } }
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) } } }() }
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()) } } } }() }
func (c *Config) Process() { var err error c.PublishStartMessageInterval = time.Duration(c.PublishStartMessageIntervalInSeconds) * time.Second c.PruneStaleDropletsInterval = time.Duration(c.PruneStaleDropletsIntervalInSeconds) * time.Second c.DropletStaleThreshold = time.Duration(c.DropletStaleThresholdInSeconds) * time.Second c.PublishActiveAppsInterval = time.Duration(c.PublishActiveAppsIntervalInSeconds) * time.Second c.Ip, err = vcap.LocalIP() if err != nil { panic(err) } }
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) }