コード例 #1
0
ファイル: source.go プロジェクト: mo-gr/skipper
// creates a skipper.SettingsSource instance.
// expects an instance of the etcd client, a filter registry and a settings dispatcher.
func MakeSource(
	dc skipper.DataClient,
	mwr skipper.FilterRegistry,
	sd skipper.SettingsDispatcher) skipper.SettingsSource {

	// create initial empty settings:
	sd.Push() <- &settings{route.New()}

	s := &source{sd}
	go func() {
		for {
			data := <-dc.Receive()

			ss, err := processRaw(data, mwr)
			if err != nil {
				log.Println(err)
				continue
			}

			s.dispatcher.Push() <- ss
		}
	}()

	return s
}
コード例 #2
0
ファイル: etcd_test.go プロジェクト: hafizh/skipper
func waitForEtcd(dc skipper.DataClient, test func(skipper.RawData) bool) bool {
	for {
		select {
		case d := <-dc.Receive():
			if test(d) {
				return true
			}
		case <-time.After(15 * time.Millisecond):
			return false
		}
	}
}
コード例 #3
0
ファイル: source.go プロジェクト: hafizh/skipper
// creates a skipper.SettingsSource instance.
// expects an instance of the etcd client, a filter registry and a settings dispatcher.
func MakeSource(
	dc skipper.DataClient,
	mwr skipper.FilterRegistry,
	sd skipper.SettingsDispatcher) skipper.SettingsSource {

	s := &source{sd}
	go func() {
		for {
			data := <-dc.Receive()

			settings, err := processRaw(data, mwr)
			if err != nil {
				log.Println(err)
				continue
			}

			s.dispatcher.Push() <- settings
		}
	}()

	return s
}