diff --git a/examples/apigateway/main.go b/examples/apigateway/main.go index bedb368da..bba617818 100644 --- a/examples/apigateway/main.go +++ b/examples/apigateway/main.go @@ -84,18 +84,19 @@ func main() { tags = []string{} passingOnly = true endpoints = addsvc.Endpoints{} + instancer = consulsd.NewInstancer(client, logger, "addsvc", tags, passingOnly) ) { factory := addsvcFactory(addsvc.MakeSumEndpoint, tracer, logger) - subscriber := consulsd.NewSubscriber(client, factory, logger, "addsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) + endpointer := sd.NewEndpointer(instancer, factory, logger) + balancer := lb.NewRoundRobin(endpointer) retry := lb.Retry(*retryMax, *retryTimeout, balancer) endpoints.SumEndpoint = retry } { factory := addsvcFactory(addsvc.MakeConcatEndpoint, tracer, logger) - subscriber := consulsd.NewSubscriber(client, factory, logger, "addsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) + endpointer := sd.NewEndpointer(instancer, factory, logger) + balancer := lb.NewRoundRobin(endpointer) retry := lb.Retry(*retryMax, *retryTimeout, balancer) endpoints.ConcatEndpoint = retry } @@ -120,18 +121,19 @@ func main() { passingOnly = true uppercase endpoint.Endpoint count endpoint.Endpoint + instancer = consulsd.NewInstancer(client, logger, "stringsvc", tags, passingOnly) ) { factory := stringsvcFactory(ctx, "GET", "/uppercase") - subscriber := consulsd.NewSubscriber(client, factory, logger, "stringsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) + endpointer := sd.NewEndpointer(instancer, factory, logger) + balancer := lb.NewRoundRobin(endpointer) retry := lb.Retry(*retryMax, *retryTimeout, balancer) uppercase = retry } { factory := stringsvcFactory(ctx, "GET", "/count") - subscriber := consulsd.NewSubscriber(client, factory, logger, "stringsvc", tags, passingOnly) - balancer := lb.NewRoundRobin(subscriber) + endpointer := sd.NewEndpointer(instancer, factory, logger) + balancer := lb.NewRoundRobin(endpointer) retry := lb.Retry(*retryMax, *retryTimeout, balancer) count = retry } diff --git a/examples/stringsvc3/proxying.go b/examples/stringsvc3/proxying.go index 8d67d3858..8b1013f31 100644 --- a/examples/stringsvc3/proxying.go +++ b/examples/stringsvc3/proxying.go @@ -40,7 +40,7 @@ func proxyingMiddleware(ctx context.Context, instances string, logger log.Logger // discovery system. var ( instanceList = split(instances) - subscriber sd.FixedSubscriber + endpointer sd.FixedEndpointer ) logger.Log("proxy_to", fmt.Sprint(instanceList)) for _, instance := range instanceList { @@ -48,12 +48,12 @@ func proxyingMiddleware(ctx context.Context, instances string, logger log.Logger e = makeUppercaseProxy(ctx, instance) e = circuitbreaker.Gobreaker(gobreaker.NewCircuitBreaker(gobreaker.Settings{}))(e) e = ratelimit.NewTokenBucketLimiter(jujuratelimit.NewBucketWithRate(float64(qps), int64(qps)))(e) - subscriber = append(subscriber, e) + endpointer = append(endpointer, e) } // Now, build a single, retrying, load-balancing endpoint out of all of // those individual endpoints. - balancer := lb.NewRoundRobin(subscriber) + balancer := lb.NewRoundRobin(endpointer) retry := lb.Retry(maxAttempts, maxTime, balancer) // And finally, return the ServiceMiddleware, implemented by proxymw.