コード例 #1
0
ファイル: main.go プロジェクト: khj0651/loggregator
func MakeProvider(adapter storeadapter.StoreAdapter, storeKeyPrefix string, outgoingPort uint32, logger *gosteno.Logger) serveraddressprovider.ServerAddressProvider {
	loggregatorServerAddressList := servicediscovery.NewServerAddressList(adapter, storeKeyPrefix, logger)
	loggregatorServerAddressList.DiscoverAddresses()
	go loggregatorServerAddressList.Run(EtcdQueryInterval)

	return serveraddressprovider.NewDynamicServerAddressProvider(loggregatorServerAddressList, outgoingPort)
}
コード例 #2
0
ファイル: main.go プロジェクト: rakutentech/loggregator
func makeProxy(adapter storeadapter.StoreAdapter, config *config.Config, logger *gosteno.Logger, messageGenerator marshaller.MessageGenerator, translator dopplerproxy.RequestTranslator, listenerConstructor channel_group_connector.ListenerConstructor, cookieDomain string) *dopplerproxy.Proxy {
	logAuthorizer := authorization.NewLogAccessAuthorizer(*disableAccessControl, config.ApiHost, config.SkipCertVerify)

	uaaClient := uaa_client.NewUaaClient(config.UaaHost, config.UaaClientId, config.UaaClientSecret, config.SkipCertVerify)
	adminAuthorizer := authorization.NewAdminAccessAuthorizer(*disableAccessControl, &uaaClient)

	loggregatorServerAddressList := servicediscovery.NewServerAddressList(adapter, "/healthstatus/doppler", logger)
	provider := serveraddressprovider.NewDynamicServerAddressProvider(loggregatorServerAddressList, config.DopplerPort, EtcdQueryInterval)
	provider.Start()

	cgc := channel_group_connector.NewChannelGroupConnector(provider, listenerConstructor, messageGenerator, logger)

	return dopplerproxy.NewDopplerProxy(logAuthorizer, adminAuthorizer, cgc, translator, cookieDomain, logger)
}
コード例 #3
0
var _ = Describe("ServerAddressProvider", func() {
	Describe("Start", func() {
		var fakeStoreAdapter *fakestoreadapter.FakeStoreAdapter

		BeforeEach(func() {
			fakeStoreAdapter = fakestoreadapter.New()
		})

		It("discovers loggregator addresses upfront, before starting the run loop", func() {
			addressList := &fakeServerAddressList{
				addressesToReturn: [][]string{
					[]string{"1.2.3.4"},
				},
			}
			provider := serveraddressprovider.NewDynamicServerAddressProvider(addressList, uint32(3456))

			provider.Start()

			Expect(provider.ServerAddresses()).To(ConsistOf("1.2.3.4:3456"))
		})

		It("periodically gets loggregator addresses (with port) from the store", func() {
			addressList := &fakeServerAddressList{
				addressesToReturn: [][]string{
					[]string{},
					[]string{"1.2.3.4"},
				},
			}
			provider := serveraddressprovider.NewDynamicServerAddressProvider(addressList, uint32(3456))
コード例 #4
0
var _ = Describe("ServerAddressProvider", func() {
	Describe("Start", func() {
		var fakeStoreAdapter *fakestoreadapter.FakeStoreAdapter

		BeforeEach(func() {
			fakeStoreAdapter = fakestoreadapter.New()
		})

		It("discovers loggregator addresses upfront, before starting the run loop", func() {
			addressList := &fakeServerAddressList{
				addressesToReturn: [][]string{
					[]string{"1.2.3.4"},
				},
			}
			provider := serveraddressprovider.NewDynamicServerAddressProvider(addressList, uint32(3456), 1*time.Millisecond)

			provider.Start()

			Expect(provider.ServerAddresses()).To(ConsistOf("1.2.3.4:3456"))
		})

		It("periodically gets loggregator addresses (with port) from the store", func() {
			addressList := &fakeServerAddressList{
				addressesToReturn: [][]string{
					[]string{},
					[]string{"1.2.3.4"},
				},
			}
			provider := serveraddressprovider.NewDynamicServerAddressProvider(addressList, uint32(3456), 1*time.Millisecond)
コード例 #5
0
package serveraddressprovider_test

import (
	"time"
	"trafficcontroller/serveraddressprovider"

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

var _ = Describe("ServerAddressProvider", func() {
	It("adds the configured port to the list's addresses", func() {
		list := fakeServerAddressList{addresses: []string{"1.2.3.4", "1.2.3.5"}}

		provider := serveraddressprovider.NewDynamicServerAddressProvider(list, uint32(7))

		Expect(provider.ServerAddresses()).To(Equal([]string{"1.2.3.4:7", "1.2.3.5:7"}))
	})
})

type fakeServerAddressList struct {
	addresses []string
}

func (fake fakeServerAddressList) Run(time.Duration) {}
func (fake fakeServerAddressList) Stop()             {}

func (fake fakeServerAddressList) GetAddresses() []string {
	return fake.addresses
}