dial_appengine.go 682 B

12345678910111213141516171819202122232425262728293031
  1. // Copyright 2016 Google LLC.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build appengine
  5. package grpc
  6. import (
  7. "context"
  8. "net"
  9. "time"
  10. "google.golang.org/appengine"
  11. "google.golang.org/appengine/socket"
  12. "google.golang.org/grpc"
  13. )
  14. func init() {
  15. // NOTE: dev_appserver doesn't currently support SSL.
  16. // When it does, this code can be removed.
  17. if appengine.IsDevAppServer() {
  18. return
  19. }
  20. appengineDialerHook = func(ctx context.Context) grpc.DialOption {
  21. return grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
  22. return socket.DialTimeout(ctx, "tcp", addr, timeout)
  23. })
  24. }
  25. }