Пример #1
0
func (cache AppServiceCache) Remove(appService domain.AppService) {
	appCache := cache.appServicesByAppId[appService.AppId]
	delete(appCache, appService.Id())
	if len(appCache) == 0 {
		delete(cache.appServicesByAppId, appService.AppId)
	}
}
Пример #2
0
func (cache AppServiceCache) Exists(appService domain.AppService) bool {
	serviceExists := false
	appServices, appExists := cache.appServicesByAppId[appService.AppId]
	if appExists {
		_, serviceExists = appServices[appService.Id()]
	}
	return serviceExists
}
Пример #3
0
func (c *appServiceCache) Remove(appService domain.AppService) {
	c.Lock()
	defer c.Unlock()
	appCache := c.appServicesByAppId[appService.AppId]
	delete(appCache, appService.Id())
	if len(appCache) == 0 {
		delete(c.appServicesByAppId, appService.AppId)
	}
}
Пример #4
0
func (cache AppServiceCache) Add(appService domain.AppService) {
	appServicesById, ok := cache.appServicesByAppId[appService.AppId]
	if !ok {
		appServicesById = make(map[string]domain.AppService)
		cache.appServicesByAppId[appService.AppId] = appServicesById
	}

	appServicesById[appService.Id()] = appService
}
Пример #5
0
func (c *appServiceCache) Exists(appService domain.AppService) bool {
	c.RLock()
	defer c.RUnlock()
	serviceExists := false
	appServices, appExists := c.appServicesByAppId[appService.AppId]
	if appExists {
		_, serviceExists = appServices[appService.Id()]
	}
	return serviceExists
}
Пример #6
0
func (c *appServiceCache) Add(appService domain.AppService) {
	c.Lock()
	defer c.Unlock()
	appServicesById, ok := c.appServicesByAppId[appService.AppId]
	if !ok {
		appServicesById = make(map[string]domain.AppService)
		c.appServicesByAppId[appService.AppId] = appServicesById
	}

	appServicesById[appService.Id()] = appService
}
Пример #7
0
func buildNode(appService domain.AppService) storeadapter.StoreNode {
	return storeadapter.StoreNode{
		Key:   path.Join("/loggregator/services", appService.AppId, appService.Id()),
		Value: []byte(appService.Url),
	}
}
				})
			})
		})

		Context("When an existing service is updated", func() {
			It("should not notify the channel again", func() {
				adapter.SetMulti([]storeadapter.StoreNode{buildNode(app2Service1)})
				assertNoDataOnChannel(outAddChan)
				assertNoDataOnChannel(outRemoveChan)
			})
		})

		Context("when a service or app should be removed", func() {
			Context("when an existing app loses one of its services", func() {
				It("sends that service on the output remove channel", func(done Done) {
					adapter.Delete(path.Join("/loggregator/services", app1Service2.AppId, app1Service2.Id()))

					Expect(<-outRemoveChan).To(Equal(app1Service2))
					assertNoDataOnChannel(outAddChan)

					close(done)
				})
			})

			Context("when an existing app loses all of its services", func() {
				It("sends all of the app services on the outgoing remove channel", func(done Done) {
					adapter.Delete(path.Join("/loggregator/services", app1Service2.AppId))

					appServices := drainOutgoingChannel(outRemoveChan, 2)

					Expect(appServices).To(ContainElement(app1Service1))