Beispiel #1
0
func (r router) Start(logger *gosteno.Logger) {
	dataChan := r.agentListener.Start()
	for {
		dataToProxy := <-dataChan
		appId, err := appid.FromLogMessage(dataToProxy)
		if err != nil {
			logger.Warn(err.Error())
		} else {
			lc := r.lookupLoggregatorClientForAppId(appId)
			lc.Send(dataToProxy)
		}
	}
}
Beispiel #2
0
func (r Router) Start(logger *gosteno.Logger) {
	go r.agentListener.Start()
	for dataToProxy := range r.dataChan {
		appId, err := appid.FromProtobufferMessage(dataToProxy)
		if err != nil {
			logger.Warn(err.Error())
		} else {
			server := r.hasher.GetLoggregatorServerForAppId(appId)
			lc := r.loggregatorClients[server]
			r.Component.Logger.Debugf("Incoming Router: AppId is %v. Using server: %v", appId, server)
			lc.Send(dataToProxy)
		}
	}
}
Beispiel #3
0
func initializeComponent(config metronConfig, instrumentables []instrumentation.Instrumentable, logger *gosteno.Logger) cfcomponent.Component {
	if len(config.NatsHosts) == 0 {
		logger.Warn("Startup: Did not receive a NATS host - not going to register component")
		cfcomponent.DefaultYagnatsClientProvider = func(logger *gosteno.Logger, c *cfcomponent.Config) (yagnats.NATSConn, error) {
			return fakeyagnats.Connect(), nil
		}
	}

	component, err := cfcomponent.NewComponent(logger, "MetronAgent", config.Index, &metronHealthMonitor{}, config.VarzPort, []string{config.VarzUser, config.VarzPass}, instrumentables)
	if err != nil {
		panic(err)
	}

	return component
}