create register agent in agent

This commit is contained in:
2026-04-13 16:37:54 +03:00
parent 8a3ffa98ab
commit 648c2d0a99
8 changed files with 154 additions and 6 deletions
+10 -3
View File
@@ -1,16 +1,19 @@
package app
import (
"context"
standartlog "log"
"github.com/docker/docker/client"
"github.com/lorsanstand/HomeOps-Hub/internal/agent/rpc"
"github.com/lorsanstand/HomeOps-Hub/internal/agent/service/agent_service"
"github.com/lorsanstand/HomeOps-Hub/internal/agent/service/collector"
"github.com/lorsanstand/HomeOps-Hub/internal/agent/service/docker_service"
"github.com/lorsanstand/HomeOps-Hub/internal/agent/utils/config_yaml"
log2 "github.com/lorsanstand/HomeOps-Hub/internal/shared/log"
"github.com/rs/zerolog"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)
type App struct {
@@ -20,6 +23,7 @@ type App struct {
}
func NewApp() *App {
cfg, err := config_yaml.NewConfig()
if err != nil {
standartlog.Fatalf("failed get config: %v", err)
@@ -31,7 +35,9 @@ func NewApp() *App {
}
func (a *App) Run() {
GRPCConn, err := grpc.NewClient(a.cfg.GetGRPCAddress())
ctx := context.Background()
GRPCConn, err := grpc.NewClient(a.cfg.GetGRPCAddress(), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
a.log.Error().Err(err).Msg("failed to get hub connections")
return
@@ -50,7 +56,8 @@ func (a *App) Run() {
DockerService = docker_service.NewDockerService(DockerClient, a.log)
}
Collector := collector.NewCollector(DockerService, a.log)
collect := collector.NewCollector(DockerService, a.log)
Collector.GatherInfoSystem()
agent := agent_service.NewAgentService(collect, conn, "", a.cfg, a.log)
agent.RegisterAgentConn(ctx)
}