feat: update conn in hub

This commit is contained in:
2026-04-05 15:48:23 +03:00
parent acbc100928
commit 306dcff31f
8 changed files with 100 additions and 73 deletions
+32
View File
@@ -0,0 +1,32 @@
package rpc
import (
"fmt"
pb "github.com/lorsanstand/HomeOps-Hub/api/gen/homeops"
"google.golang.org/grpc"
)
type Connection struct {
hub pb.HubClient
conn *grpc.ClientConn
}
func NewConnectAgent(address string) (*Connection, error) {
conn, err := grpc.NewClient(address)
if err != nil {
return nil, fmt.Errorf("failed connection hub: %v", err)
}
client := pb.NewHubClient(conn)
return &Connection{hub: client, conn: conn}, nil
}
func (c *Connection) Close() error {
return c.conn.Close()
}
func (c *Connection) Hub() pb.HubClient {
return c.hub
}