Skip to content

Commit

Permalink
refactor: rename function
Browse files Browse the repository at this point in the history
  • Loading branch information
bassosimone committed Apr 15, 2024
1 parent 7576fc7 commit 8120c06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions internal/enginenetx/statspolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (p *statsPolicy) LookupTactics(ctx context.Context, domain string, port str
// known-to-work cached tactics have become obsolete.

// give priority to what we know from stats
for _, t := range statsPolicyPostProcessTactics(p.Stats.LookupTactics(domain, port)) {
for _, t := range statsPolicyFilterStatsTactics(p.Stats.LookupTactics(domain, port)) {
maybeEmitTactic(t)
}

Expand All @@ -78,7 +78,8 @@ func (p *statsPolicy) LookupTactics(ctx context.Context, domain string, port str
return out
}

func statsPolicyPostProcessTactics(tactics []*statsTactic, good bool) (out []*httpsDialerTactic) {
// statsPolicyFilterStatsTactics filters the tactics generated by consulting the stats.
func statsPolicyFilterStatsTactics(tactics []*statsTactic, good bool) (out []*httpsDialerTactic) {
// when good is false, it means p.Stats.LookupTactics failed
if !good {
return
Expand Down
6 changes: 3 additions & 3 deletions internal/enginenetx/statspolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ func (p *mocksPolicy) LookupTactics(ctx context.Context, domain string, port str
return p.MockLookupTactics(ctx, domain, port)
}

func TestStatsPolicyPostProcessTactics(t *testing.T) {
func TestStatsPolicyFilterStatsTactics(t *testing.T) {
t.Run("we do nothing when good is false", func(t *testing.T) {
tactics := statsPolicyPostProcessTactics(nil, false)
tactics := statsPolicyFilterStatsTactics(nil, false)
if len(tactics) != 0 {
t.Fatal("expected zero-lenght return value")
}
Expand Down Expand Up @@ -390,7 +390,7 @@ func TestStatsPolicyPostProcessTactics(t *testing.T) {
},
}

got := statsPolicyPostProcessTactics(input, true)
got := statsPolicyFilterStatsTactics(input, true)

if len(got) != 1 {
t.Fatal("expected just one element")
Expand Down

0 comments on commit 8120c06

Please sign in to comment.