From b5fe910cb85215c7f679d8e8a2d02a804f3e2c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cachuyko=E2=80=9D?= <“achuyko@algoritmiclab.ai”> Date: Sat, 24 Aug 2024 15:36:44 +0300 Subject: [PATCH] DDD :) :DDD --- cmd/grpc_client/main.go | 63 ----------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 cmd/grpc_client/main.go diff --git a/cmd/grpc_client/main.go b/cmd/grpc_client/main.go deleted file mode 100644 index 25719ea..0000000 --- a/cmd/grpc_client/main.go +++ /dev/null @@ -1,63 +0,0 @@ -package main - -import ( - "context" - "log" - "time" - - "github.com/fatih/color" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "github.com/Chuiko-GIT/chat/pkg/user_api" -) - -const ( - address = "localhost:50051" - userID = 1 -) - -func main() { - conn, err := grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials())) - if err != nil { - log.Fatalf("failed to connect to server: %v", err) - } - defer func() { - if err = conn.Close(); err != nil { - log.Println(err) - } - }() - - c := user_api.NewUserAPIClient(conn) - - ctx, cancel := context.WithTimeout(context.Background(), time.Second) - defer cancel() - - getUser, err := c.Get(ctx, &user_api.GetRequest{Id: userID}) - if err != nil { - log.Fatalf("failed to get user by id: %v", err) - } - - log.Printf(color.RedString("User get:\n"), color.GreenString("%+v", getUser.GetUser())) - - createUser, err := c.Create(ctx, &user_api.CreateRequest{}) - if err != nil { - log.Fatalf("failed to create user: %v", err) - } - - log.Printf(color.RedString("User create:\n"), color.GreenString("%+v", createUser.GetId())) - - updateUser, err := c.Update(ctx, &user_api.UpdateRequest{}) - if err != nil { - log.Fatalf("failed to update user: %v", err) - } - - log.Printf(color.RedString("User update:\n"), color.GreenString("%+v", updateUser.String())) - - deleteUser, err := c.Delete(ctx, &user_api.DeleteRequest{}) - if err != nil { - log.Fatalf("failed to delete user: %v", err) - } - - log.Printf(color.RedString("User delete:\n"), color.GreenString("%+v", deleteUser.String())) -}