mirror of
https://github.com/lorsanstand/HomeOps-Hub.git
synced 2026-06-19 16:45:15 +03:00
refactor: change system logging
This commit is contained in:
@@ -5,26 +5,20 @@ import (
|
||||
|
||||
pb "github.com/lorsanstand/HomeOps-Hub/api/gen/homeops"
|
||||
"github.com/lorsanstand/HomeOps-Hub/shared/domain"
|
||||
"github.com/rs/zerolog"
|
||||
"google.golang.org/grpc"
|
||||
)
|
||||
|
||||
type Connection struct {
|
||||
hub pb.HubClient
|
||||
conn *grpc.ClientConn
|
||||
log zerolog.Logger
|
||||
}
|
||||
|
||||
func NewConnectAgent(conn *grpc.ClientConn, logger zerolog.Logger) *Connection {
|
||||
logger = logger.With().Str("component", "agent.rpc").Logger()
|
||||
|
||||
func NewConnectAgent(conn *grpc.ClientConn) *Connection {
|
||||
client := pb.NewHubClient(conn)
|
||||
|
||||
return &Connection{hub: client, conn: conn, log: logger}
|
||||
return &Connection{hub: client, conn: conn}
|
||||
}
|
||||
|
||||
func (c *Connection) Close() error {
|
||||
c.log.Warn().Msg("connection close")
|
||||
return c.conn.Close()
|
||||
}
|
||||
|
||||
@@ -34,6 +28,5 @@ func (c *Connection) Hub() pb.HubClient {
|
||||
|
||||
func (c *Connection) RegisterAgent(ctx context.Context, RegisterData domain.RegisterAgentRequest) (domain.RegisterAgentResponse, error) {
|
||||
ResponseData, err := c.Hub().RegisterAgent(ctx, new(domain.ToGRPCAgentRequest(RegisterData)))
|
||||
c.log.Info().Msg("register agent")
|
||||
return domain.ToDomainAgentResponse(ResponseData), err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user