Skip to content

Commit

Permalink
Reorganize some lines
Browse files Browse the repository at this point in the history
  • Loading branch information
rtorrero committed Mar 6, 2024
1 parent ac6d75a commit 7ef9ae5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions internal/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,16 @@ func GetAgentID(fileSystem afero.Fs) (string, error) {
// Start the Agent. This will start the discovery ticker and the heartbeat ticker
func (a *Agent) Start(ctx context.Context) error {
gathererRegistry := gatherers.NewRegistry(gatherers.StandardGatherers())
g, groupCtx := errgroup.WithContext(ctx)

c := factsengine.NewFactsEngine(a.config.AgentID, a.config.FactsServiceURL, *gathererRegistry)
log.Info("Starting fact gathering service...")
if err := c.Subscribe(); err != nil {
return err
}
g.Go(func() error {

g, groupCtx := errgroup.WithContext(ctx)

g.Go(func() error {
if err := c.Listen(groupCtx); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions internal/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ func (suite *AgentTestSuite) TestAgentFailsWithInvalidFactsServiceURL() {
DiscoveriesPeriodsConfig: &discovery.DiscoveriesPeriodConfig{},
CollectorConfig: &collector.Config{},
},
FactsServiceURL: "amqp://trento:trento@somehost:1234/somevhost",
FactsServiceURL: "amqp://trento:trento@localhost:12345/somevhost",
PluginsFolder: "/usr/etc/trento/plugins/",
}

agent, _ := agent.NewAgent(config)
ctx := context.Background()
err := agent.Start(ctx)

suite.ErrorContains(err, "dial tcp: lookup somehost: no such host")
suite.ErrorContains(err, "connect: connection refused")
}

0 comments on commit 7ef9ae5

Please sign in to comment.