feat: base grpc system and base use

This commit is contained in:
2026-04-04 20:19:16 +03:00
parent b6d701c9e0
commit 4177c00e75
9 changed files with 388 additions and 5 deletions
+31
View File
@@ -1 +1,32 @@
package main
import (
"context"
"log"
"time"
"github.com/lorsanstand/HomeOps-Hub/api/gen/homeops"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/types/known/emptypb"
)
func main() {
conn, err := grpc.Dial("127.0.0.1:6756", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatalf("dial: %v", err)
}
defer conn.Close()
client := homeops.NewHubClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
resp, err := client.Ping(ctx, &emptypb.Empty{})
if err != nil {
log.Fatalf("dial: %v", err)
}
defer cancel()
log.Printf("pong: %+v", resp.Pong)
}