func New(host string, config *Config, logger *gosteno.Logger) *Loggregator { cfcomponent.Logger = logger keepAliveInterval := 30 * time.Second listener, incomingLogChan := agentlistener.NewAgentListener(fmt.Sprintf("%s:%d", host, config.IncomingPort), logger) unmarshaller, 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) appStoreCache := cache.NewAppServiceCache() appStoreWatcher, newAppServiceChan, deletedAppServiceChan := store.NewAppServiceStoreWatcher(storeAdapter, appStoreCache) appStore := store.NewAppServiceStore(storeAdapter, appStoreWatcher) return &Loggregator{ Logger: logger, listener: listener, unmarshaller: unmarshaller, sinkManager: sinkManager, messageChan: messageChan, appStoreInputChan: appStoreInputChan, appStore: appStore, messageRouter: sinkserver.NewMessageRouter(sinkManager, logger), websocketServer: websocketserver.New(fmt.Sprintf("%s:%d", host, config.OutgoingPort), sinkManager, keepAliveInterval, config.WSMessageBufferSize, logger), newAppServiceChan: newAppServiceChan, deletedAppServiceChan: deletedAppServiceChan, appStoreWatcher: appStoreWatcher, storeAdapter: storeAdapter, } }
func NewAppServiceStore(adapter storeadapter.StoreAdapter, in <-chan domain.AppServices) *AppServiceStore { return &AppServiceStore{ adapter: adapter, incomingChan: in, cache: cache.NewAppServiceCache(), } }
func NewAppServiceStoreWatcher(adapter storeadapter.StoreAdapter) (*AppServiceStoreWatcher, <-chan domain.AppService, <-chan domain.AppService) { outAddChan := make(chan domain.AppService) outRemoveChan := make(chan domain.AppService) return &AppServiceStoreWatcher{ adapter: adapter, outAddChan: outAddChan, outRemoveChan: outRemoveChan, cache: cache.NewAppServiceCache(), }, outAddChan, outRemoveChan }
. "loggregator/store" "loggregator/store/cache" ) var _ = Describe("AppServiceStoreIntegration", func() { var ( incomingChan chan domain.AppServices outAddChan <-chan domain.AppService outRemoveChan <-chan domain.AppService ) BeforeEach(func() { adapter := etcdRunner.Adapter() incomingChan = make(chan domain.AppServices) c := cache.NewAppServiceCache() var watcher *AppServiceStoreWatcher watcher, outAddChan, outRemoveChan = NewAppServiceStoreWatcher(adapter, c) go watcher.Run() store := NewAppServiceStore(adapter, watcher) go store.Run(incomingChan) }) It("should receive, store, and republish AppServices", func(done Done) { appServices := domain.AppServices{AppId: "12345", Urls: []string{"syslog://foo"}} incomingChan <- appServices Expect(<-outAddChan).To(Equal(domain.AppService{ AppId: "12345", Url: "syslog://foo", }))
func NewAppServiceStore(adapter storeadapter.StoreAdapter) *AppServiceStore { return &AppServiceStore{ adapter: adapter, cache: cache.NewAppServiceCache(), } }