Example #1
0
func hubMaintainer(logger lager.Logger, desiredHub, actualHub events.Hub) ifrit.RunFunc {
	return func(signals <-chan os.Signal, ready chan<- struct{}) error {
		logger := logger.Session("hub-maintainer")
		close(ready)
		logger.Info("started")
		defer logger.Info("finished")

		<-signals
		err := desiredHub.Close()
		if err != nil {
			logger.Error("error-closing-desired-hub", err)
		}
		err = actualHub.Close()
		if err != nil {
			logger.Error("error-closing-actual-hub", err)
		}
		return nil
	}
}
Example #2
0
package events_test

import (
	"strconv"

	"code.cloudfoundry.org/bbs/events"
	"code.cloudfoundry.org/bbs/events/eventfakes"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Hub", func() {
	var (
		hub events.Hub
	)

	BeforeEach(func() {
		hub = events.NewHub()
	})

	Describe("RegisterCallback", func() {
		Context("when registering the callback", func() {
			var eventSource events.EventSource
			var counts chan int

			BeforeEach(func() {
				var err error
				eventSource, err = hub.Subscribe()
				Expect(err).NotTo(HaveOccurred())
Example #3
0
	"code.cloudfoundry.org/bbs/models"
	"code.cloudfoundry.org/bbs/models/test/model_helpers"
	"code.cloudfoundry.org/lager"
	"code.cloudfoundry.org/lager/lagertest"
	"github.com/vito/go-sse/sse"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Event Handlers", func() {
	var (
		logger     lager.Logger
		desiredHub events.Hub
		actualHub  events.Hub

		handler         *handlers.EventHandler
		eventStreamDone chan struct{}
		server          *httptest.Server
	)

	BeforeEach(func() {
		logger = lagertest.NewTestLogger("test")
		desiredHub = events.NewHub()
		actualHub = events.NewHub()
		handler = handlers.NewEventHandler(desiredHub, actualHub)

		eventStreamDone = make(chan struct{})
	})

	AfterEach(func() {