Skip to content

Instantly share code, notes, and snippets.

@poy
Created September 1, 2016 18:06
Show Gist options
  • Select an option

  • Save poy/b9977368d4fd5f9ad81c5c481e1cb5a0 to your computer and use it in GitHub Desktop.

Select an option

Save poy/b9977368d4fd5f9ad81c5c481e1cb5a0 to your computer and use it in GitHub Desktop.
package main
import (
"doppler/dopplerservice"
"errors"
"log"
"os"
"strings"
"github.com/cloudfoundry/gosteno"
"github.com/cloudfoundry/gunk/workpool"
"github.com/cloudfoundry/storeadapter/etcdstoreadapter"
)
func main() {
etcds := os.Getenv("ETCDS")
if etcds == "" {
panic(errors.New("Must have ETCDS env variable set in format: scheme://ip:port"))
}
addrs := strings.Split(etcds, ",")
log.Printf("Etcd addresses are: %v", addrs)
options := &etcdstoreadapter.ETCDOptions{ClusterUrls: addrs}
pool, err := workpool.NewWorkPool(10)
if err != nil {
panic(err)
}
adapter, err := etcdstoreadapter.New(options, pool)
if err != nil {
panic(err)
}
finder := dopplerservice.NewFinder(adapter, 3457, []string{"udp"}, "", gosteno.NewLogger("test"))
finder.Start()
c := 0
for {
e := finder.Next()
c++
if len(e.UDPDopplers) == 0 {
log.Printf("%d loops\n", c)
log.Printf("******* Got event without UDP dopplers: %#v *******\n", e)
c = 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment