Skip to content

Commit

Permalink
Update examples: use grpc.NewClient() instead of grpc.Dial()
Browse files Browse the repository at this point in the history
  • Loading branch information
Renat authored and Renat committed Oct 5, 2024
1 parent 9277388 commit 10b9ea1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions examples/example_grpc_ip_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ package examples
import (
"context"
"fmt"
"google.golang.org/grpc/credentials/insecure"
"log"
"net"
"os"
"strings"
"time"

"google.golang.org/grpc/credentials/insecure"

"github.com/redis/go-redis/v9"
"go.etcd.io/etcd/client/v3"
clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/peer"
Expand Down Expand Up @@ -104,7 +105,7 @@ func Example_ipGRPCLimiter() {
defer s.GracefulStop()

// Set up a client connection to the server.
conn, err := grpc.Dial(fmt.Sprintf("localhost%s", port), grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(fmt.Sprintf("localhost%s", port), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down
7 changes: 4 additions & 3 deletions examples/example_grpc_simple_limiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ package examples
import (
"context"
"fmt"
"google.golang.org/grpc/credentials/insecure"
"log"
"net"
"os"
"strings"
"time"

clientv3 "go.etcd.io/etcd/client/v3"
"google.golang.org/grpc/credentials/insecure"

"github.com/redis/go-redis/v9"
"go.etcd.io/etcd/client/v3"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
Expand Down Expand Up @@ -79,7 +80,7 @@ func Example_simpleGRPCLimiter() {
defer s.GracefulStop()

// Set up a client connection to the server.
conn, err := grpc.Dial(fmt.Sprintf("localhost%s", port), grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(fmt.Sprintf("localhost%s", port), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down

0 comments on commit 10b9ea1

Please sign in to comment.