Ejemplo n.º 1
0
func (watcher *Watcher) emitMessages(logger lager.Logger, messagesToEmit routing_table.MessagesToEmit) {
	if watcher.emitter != nil {
		logger.Debug("emitting-messages", lager.Data{"messages": messagesToEmit})
		watcher.emitter.Emit(messagesToEmit)
		routesRegistered.Add(messagesToEmit.RouteRegistrationCount())
		routesUnregistered.Add(messagesToEmit.RouteUnregistrationCount())
	}
}
				Host: "1.1.1.1",
				Port: 61004,
				App:  "log-guid-3",
				URIs: []string{"host3.example.com"},
			},
		}
	})

	Describe("RouteRegistrationCount", func() {
		Context("when there are registration messages", func() {
			BeforeEach(func() {
				messagesToEmit.RegistrationMessages = messages1
			})

			It("adds the number of hostnames in each route message", func() {
				Expect(messagesToEmit.RouteRegistrationCount()).To(BeEquivalentTo(5))
			})
		})

		Context("when registration messages is nil", func() {
			BeforeEach(func() {
				messagesToEmit.RegistrationMessages = nil
				messagesToEmit.UnregistrationMessages = messages1
			})

			It("adds the number of hostnames in each route message", func() {
				Expect(messagesToEmit.RouteRegistrationCount()).To(BeEquivalentTo(0))
			})
		})
	})