DNS resolver (#1300)

* initial dns resolver impl

* add srv lookup

* more srv

* change from string to Update

* added port handling

* a complete draft for dns resovler except the polling mechanism

* added sleep to infrequently poll the DNS server

* commented out test case since they are not portable

* remove duplicate declaration/definition in grpclb

* change namespace for grpclb structures

* goimports gofmt

* fix sorting issue

* implement sort.Interface

* different sort implementation for different go version

* add missing files

* fix missing comments

* handle err

* fix comments: unexport dnsResolver and dnsWatcher, add chan to exit Next(), add freq to control polling frequency

* enhance target string handling, add static IPWatcher, add mock test

* debug travis

* disable real address resolver test, since travis return 3 resolved IPs, 2 of them are duplicates

* shorten test time by reduce sleep time in TestIPWatcher, since it doesn't really do the DNS round trip

* resolve data race

* resolve data race using waitgroup

* reimplement setHostPort, compileUpdate, unexport ipWatcher

* delete sort related stuff, fix close bug for Next(), fix compileUpdate bug(change to map[Update]bool, plus fix minor review comments

* fix minor test case

* minor change to Next()

* use net.DefaultResolver with context as input

* add different build rules for lookupHost and lookupSRV

* minor fix

* go1.6 shall fail, but 1.7, 1.8 should pass

* go1.6 is expected to pass

* all go version should pass, added pre17 and 17 for replaceNetFunc to handle context problem

* rename test helper file name. should fix build problem

* goimports

* fix 1.7 context problem

* reformat dns_resolver_test structures

* change Next() behavior to have equal stalling interval between each lookup. Restructure dns_resolver_test.

* gofmt

* update go17_test.go, go18_test.go to reuse code. dns_resolver_test: check result and behavior correctness separately.

* update Next() logic
8 files changed
tree: 7a2c6fcb665c76e074eae0d197a1907a14f53e53
  1. .github/
  2. benchmark/
  3. codes/
  4. credentials/
  5. Documentation/
  6. examples/
  7. grpclb/
  8. grpclog/
  9. health/
  10. internal/
  11. interop/
  12. keepalive/
  13. metadata/
  14. naming/
  15. peer/
  16. reflection/
  17. stats/
  18. status/
  19. stress/
  20. tap/
  21. test/
  22. testdata/
  23. transport/
  24. .travis.yml
  25. AUTHORS
  26. backoff.go
  27. backoff_test.go
  28. balancer.go
  29. balancer_test.go
  30. call.go
  31. call_test.go
  32. clientconn.go
  33. clientconn_test.go
  34. codec.go
  35. codec_benchmark_test.go
  36. codec_test.go
  37. codegen.sh
  38. CONTRIBUTING.md
  39. coverage.sh
  40. doc.go
  41. go16.go
  42. go17.go
  43. grpclb.go
  44. interceptor.go
  45. LICENSE
  46. Makefile
  47. proxy.go
  48. proxy_test.go
  49. README.md
  50. rpc_util.go
  51. rpc_util_test.go
  52. server.go
  53. server_test.go
  54. stream.go
  55. trace.go
README.md

gRPC-Go

Build Status GoDoc

The Go implementation of gRPC: A high performance, open source, general RPC framework that puts mobile and HTTP/2 first. For more information see the gRPC Quick Start: Go guide.

Installation

To install this package, you need to install Go and setup your Go workspace on your computer. The simplest way to install the library is to run:

$ go get google.golang.org/grpc

Prerequisites

This requires Go 1.6 or later.

Constraints

The grpc package should only depend on standard Go packages and a small number of exceptions. If your contribution introduces new dependencies which are NOT in the list, you need a discussion with gRPC-Go authors and consultants.

Documentation

See API documentation for package and API descriptions and find examples in the examples directory.

Performance

See the current benchmarks for some of the languages supported in this dashboard.

Status

General Availability Google Cloud Platform Launch Stages.

FAQ

Compiling error, undefined: grpc.SupportPackageIsVersion

Please update proto package, gRPC package and rebuild the proto files:

  • go get -u github.com/golang/protobuf/{proto,protoc-gen-go}
  • go get -u google.golang.org/grpc
  • protoc --go_out=plugins=grpc:. *.proto