dial_appengine.go 703 B

1234567891011121314151617181920212223242526272829303132
  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. //go:build appengine
  5. // +build appengine
  6. package grpc
  7. import (
  8. "context"
  9. "net"
  10. "time"
  11. "google.golang.org/appengine"
  12. "google.golang.org/appengine/socket"
  13. "google.golang.org/grpc"
  14. )
  15. func init() {
  16. // NOTE: dev_appserver doesn't currently support SSL.
  17. // When it does, this code can be removed.
  18. if appengine.IsDevAppServer() {
  19. return
  20. }
  21. appengineDialerHook = func(ctx context.Context) grpc.DialOption {
  22. return grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) {
  23. return socket.DialTimeout(ctx, "tcp", addr, timeout)
  24. })
  25. }
  26. }