2020-07-26 17:09:05 +08:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
2020-08-08 16:40:10 +08:00
|
|
|
"github.com/tal-tech/go-zero/core/discov"
|
2020-08-14 15:08:06 +08:00
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
2020-07-26 17:09:05 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2020-07-30 22:56:39 +08:00
|
|
|
sub, err := discov.NewSubscriber([]string{"etcd.discovery:2379"}, "028F2C35852D", discov.Exclusive())
|
2020-08-14 15:08:06 +08:00
|
|
|
logx.Must(err)
|
2020-07-30 22:56:39 +08:00
|
|
|
|
2020-07-26 17:09:05 +08:00
|
|
|
ticker := time.NewTicker(time.Second * 3)
|
|
|
|
defer ticker.Stop()
|
|
|
|
|
|
|
|
for {
|
|
|
|
select {
|
|
|
|
case <-ticker.C:
|
|
|
|
fmt.Println("values:", sub.Values())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|