Exemple #1
0
func Register(c *VcapComponent, mbusClient *yagnats.Client) {
	mbusClient.Subscribe("vcap.component.discover", func(msg *yagnats.Message) {
		Component.Uptime = Component.Start.Elapsed()
		b, e := json.Marshal(Component)
		if e != nil {
			log.Warnf(e.Error())
			return
		}

		mbusClient.Publish(msg.ReplyTo, b)
	})

	b, e := json.Marshal(Component)
	if e != nil {
		log.Fatal(e.Error())
		panic("Component's information should be correct")
	}

	mbusClient.Publish("vcap.component.announce", b)

	log.Infof("Component %s registered successfully", Component.Type)
}
	"bytes"
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net"
	"net/http"
	"strings"
	"time"
)

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

	var natsRunner *natsrunner.NATSRunner
	var config *cfg.Config

	var mbusClient *yagnats.Client
	var registry *rregistry.RouteRegistry
	var varz vvarz.Varz
	var router *Router

	BeforeEach(func() {
		natsPort := test_util.NextAvailPort()
		natsRunner = natsrunner.NewNATSRunner(int(natsPort))
		natsRunner.Start()

		proxyPort := test_util.NextAvailPort()
		statusPort := test_util.NextAvailPort()

		config = test_util.SpecConfig(natsPort, statusPort, proxyPort)

		mbusClient = natsRunner.MessageBus.(*yagnats.Client)
	"os"
	"syscall"

	"github.com/cloudfoundry/yagnats"
	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"

	. "github.com/MatthiasWinzeler/route-registrar/config"
	"github.com/MatthiasWinzeler/route-registrar/healthchecker/fakes"
	. "github.com/MatthiasWinzeler/route-registrar/registrar"
	"github.com/pivotal-golang/lager"
	"github.com/pivotal-golang/lager/lagertest"
)

var config Config
var testSpyClient *yagnats.Client

var _ = Describe("Registrar.RegisterRoutes", func() {
	var logger lager.Logger
	messageBusServer := MessageBusServer{
		"127.0.0.1:4222",
		"nats",
		"nats",
	}

	healthCheckerConfig := HealthCheckerConf{
		Name:     "a_useful_health_checker",
		Interval: 1,
	}

	config = Config{