Skip to content

Commit

Permalink
Replace grpc.Dial with grpc.NewClient
Browse files Browse the repository at this point in the history
  • Loading branch information
watal committed Apr 10, 2024
1 parent 1688e63 commit a253002
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 8 deletions.
5 changes: 4 additions & 1 deletion cmd/pola/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ func newRootCmd() *cobra.Command {
}

func persistentPreRunE(cmd *cobra.Command, args []string) error {
conn, err := grpc.Dial(net.JoinHostPort(cmd.Flag("host").Value.String(), cmd.Flag("port").Value.String()), grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
net.JoinHostPort(cmd.Flag("host").Value.String(), cmd.Flag("port").Value.String()),
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return fmt.Errorf("failed to dial polad connection: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/gobgp/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ func GetBgplsNlris(serverAddr string, serverPort string) ([]table.TedElem, error
gobgpAddress := serverAddr + ":" + serverPort

// Get connection
cc, err := grpc.Dial(gobgpAddress, grpc.WithTransportCredentials(insecure.NewCredentials()))
cc, err := grpc.NewClient(
gobgpAddress,
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
return nil, err
}
Expand Down
5 changes: 4 additions & 1 deletion tools/grpc/go/add_sr-policy/add_sr-policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import (

func main() {
flag.Parse()
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
"localhost:50051",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatalf("Can't connect: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion tools/grpc/go/add_sr-policy_no_ls/add_sr-policy_no_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import (

func main() {
flag.Parse()
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
"localhost:50051",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatalf("Can't connect: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion tools/grpc/go/del_session/del_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import (

func main() {
flag.Parse()
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
"localhost:50051",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion tools/grpc/go/show_session/show_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import (

func main() {
flag.Parse()
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
"localhost:50051",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion tools/grpc/go/show_sr-policy/show_sr-policy_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ import (

func main() {
flag.Parse()
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
"localhost:50051",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down
5 changes: 4 additions & 1 deletion tools/grpc/go/show_ted/show_ted.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import (

func main() {
flag.Parse()
conn, err := grpc.Dial("localhost:50051", grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(
"localhost:50051",
grpc.WithTransportCredentials(insecure.NewCredentials()),
)
if err != nil {
log.Fatalf("did not connect: %v", err)
}
Expand Down

0 comments on commit a253002

Please sign in to comment.