コード例 #1
0
ファイル: init_test.go プロジェクト: nkuacac/loggregator
func init() {
	dataReadChannel = make(chan *logmessage.Message)

	logger := loggertesthelper.Logger()

	newAppServiceChan := make(chan domain.AppService)
	deletedAppServiceChan := make(chan domain.AppService)

	emptyBlacklist := blacklist.New(nil)
	sinkManager, _ = sinkmanager.NewSinkManager(1024, false, emptyBlacklist, logger)
	go sinkManager.Start(newAppServiceChan, deletedAppServiceChan)

	TestMessageRouter = sinkserver.NewMessageRouter(sinkManager, logger)
	go TestMessageRouter.Start(dataReadChannel)

	apiEndpoint := "localhost:" + SERVER_PORT
	TestWebsocketServer = websocket.NewWebsocketServer(apiEndpoint, sinkManager, 10*time.Second, 100, loggertesthelper.Logger())
	go TestWebsocketServer.Start()

	timeoutApiEndpoint := "localhost:" + FAST_TIMEOUT_SERVER_PORT
	FastTimeoutTestWebsocketServer := websocket.NewWebsocketServer(timeoutApiEndpoint, sinkManager, 10*time.Millisecond, 100, loggertesthelper.Logger())
	go FastTimeoutTestWebsocketServer.Start()

	blackListDataReadChannel = make(chan *logmessage.Message)
	localhostBlacklist := blacklist.New([]iprange.IPRange{iprange.IPRange{Start: "127.0.0.0", End: "127.0.0.2"}})
	blacklistSinkManager, _ := sinkmanager.NewSinkManager(1024, false, localhostBlacklist, logger)
	go blacklistSinkManager.Start(newAppServiceChan, deletedAppServiceChan)

	blacklistTestMessageRouter := sinkserver.NewMessageRouter(blacklistSinkManager, logger)
	go blacklistTestMessageRouter.Start(blackListDataReadChannel)

	blacklistApiEndpoint := "localhost:" + BLACKLIST_SERVER_PORT
	blackListTestWebsocketServer = websocket.NewWebsocketServer(blacklistApiEndpoint, blacklistSinkManager, 10*time.Second, 100, loggertesthelper.Logger())
	go blackListTestWebsocketServer.Start()

	time.Sleep(2 * time.Millisecond)
}
コード例 #2
0
ファイル: loggregator.go プロジェクト: nkuacac/loggregator
func New(host string, config *Config, logger *gosteno.Logger) *Loggregator {
	keepAliveInterval := 30 * time.Second
	listener, incomingLogChan := agentlistener.NewAgentListener(fmt.Sprintf("%s:%d", host, config.IncomingPort), logger)
	u, messageChan := unmarshaller.NewLogMessageUnmarshaller(config.SharedSecret, incomingLogChan)
	blacklist := blacklist.New(config.BlackListIps)
	sinkManager, appStoreInputChan := sinkmanager.NewSinkManager(config.MaxRetainedLogMessages, config.SkipCertVerify, blacklist, logger)
	workerPool := workerpool.NewWorkerPool(config.EtcdMaxConcurrentRequests)

	storeAdapter := etcdstoreadapter.NewETCDStoreAdapter(config.EtcdUrls, workerPool)
	appStore := store.NewAppServiceStore(storeAdapter)
	return &Loggregator{
		errChan:           make(chan error),
		listener:          listener,
		u:                 u,
		sinkManager:       sinkManager,
		messageChan:       messageChan,
		appStoreInputChan: appStoreInputChan,
		appStore:          appStore,
		messageRouter:     sinkserver.NewMessageRouter(sinkManager, logger),
		websocketServer:   websocket.NewWebsocketServer(fmt.Sprintf("%s:%d", host, config.OutgoingPort), sinkManager, keepAliveInterval, config.WSMessageBufferSize, logger),
		storeAdapter:      storeAdapter,
	}
}