Example #1
0
func NewRouteRegistry(logger lager.Logger, c *config.Config, reporter reporter.RouteRegistryReporter) *RouteRegistry {
	r := &RouteRegistry{}
	r.logger = logger
	r.byUri = container.NewTrie()

	r.pruneStaleDropletsInterval = c.PruneStaleDropletsInterval
	r.dropletStaleThreshold = c.DropletStaleThreshold

	r.reporter = reporter
	return r
}
Example #2
0
import (
	"github.com/cloudfoundry/gorouter/route"

	"github.com/cloudfoundry/gorouter/registry/container"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

var _ = Describe("Trie", func() {

	var (
		r *container.Trie
	)

	BeforeEach(func() {
		r = container.NewTrie()
	})

	Describe(".Find", func() {
		It("works for the root node", func() {
			p := route.NewPool(42, "")
			r.Insert("/", p)
			node, ok := r.Find("/")
			Expect(node).To(Equal(p))
			Expect(ok).To(BeTrue())
		})

		It("finds an exact match to an existing key", func() {
			p := route.NewPool(42, "")
			r.Insert("/foo/bar", p)
			node, ok := r.Find("/foo/bar")