Skip to content

Commit d39f4c0

Browse files
committed
Fix naming conventions, test messages, and add more comments
1 parent 78d1f01 commit d39f4c0

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
package policies
22

3-
// UpstreamSettingsProcessor defines an interface for an UpstreamSettingsPolicy to implement the process function.
3+
// UpstreamSettingsProcessor defines an interface for an UpstreamSettingsPolicy processor'
4+
// to implement the process function.
45
type UpstreamSettingsProcessor interface {
56
Process(policies []Policy) UpstreamSettings
67
}
78

89
// UpstreamSettings contains settings from UpstreamSettingsPolicy.
910
type UpstreamSettings struct {
10-
ZoneSize string
11-
KeepAliveTime string
12-
KeepAliveTimeout string
11+
// ZoneSize is the zone size setting.
12+
ZoneSize string
13+
// KeepAliveTime is the keep-alive time setting.
14+
KeepAliveTime string
15+
// KeepAliveTimeout is the keep-alive timeout setting.
16+
KeepAliveTimeout string
17+
// KeepAliveConnections is the keep-alive connections setting.
1318
KeepAliveConnections int32
14-
KeepAliveRequests int32
19+
// KeepAliveRequests is the keep-alive requests setting.
20+
KeepAliveRequests int32
1521
}

internal/mode/static/nginx/config/policies/upstreamsettings/processor_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func TestProcess(t *testing.T) {
4747
},
4848
},
4949
{
50-
name: "zoneSize set",
50+
name: "zone size set",
5151
policies: []policies.Policy{
5252
&ngfAPI.UpstreamSettingsPolicy{
5353
ObjectMeta: metav1.ObjectMeta{
@@ -64,7 +64,7 @@ func TestProcess(t *testing.T) {
6464
},
6565
},
6666
{
67-
name: "keepAlive Connections set",
67+
name: "keep alive connections set",
6868
policies: []policies.Policy{
6969
&ngfAPI.UpstreamSettingsPolicy{
7070
ObjectMeta: metav1.ObjectMeta{
@@ -83,7 +83,7 @@ func TestProcess(t *testing.T) {
8383
},
8484
},
8585
{
86-
name: "keepAlive Requests set",
86+
name: "keep alive requests set",
8787
policies: []policies.Policy{
8888
&ngfAPI.UpstreamSettingsPolicy{
8989
ObjectMeta: metav1.ObjectMeta{
@@ -102,7 +102,7 @@ func TestProcess(t *testing.T) {
102102
},
103103
},
104104
{
105-
name: "keepAlive Time set",
105+
name: "keep alive time set",
106106
policies: []policies.Policy{
107107
&ngfAPI.UpstreamSettingsPolicy{
108108
ObjectMeta: metav1.ObjectMeta{
@@ -121,7 +121,7 @@ func TestProcess(t *testing.T) {
121121
},
122122
},
123123
{
124-
name: "keepAlive Timeout set",
124+
name: "keep alive timeout set",
125125
policies: []policies.Policy{
126126
&ngfAPI.UpstreamSettingsPolicy{
127127
ObjectMeta: metav1.ObjectMeta{

internal/mode/static/nginx/config/upstreams.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ func (g GeneratorImpl) createStreamUpstream(up dataplane.Upstream) stream.Upstre
123123

124124
func (g GeneratorImpl) createUpstreams(
125125
upstreams []dataplane.Upstream,
126-
generator policies.UpstreamSettingsProcessor,
126+
processor policies.UpstreamSettingsProcessor,
127127
) []http.Upstream {
128128
// capacity is the number of upstreams + 1 for the invalid backend ref upstream
129129
ups := make([]http.Upstream, 0, len(upstreams)+1)
130130

131131
for _, u := range upstreams {
132-
ups = append(ups, g.createUpstream(u, generator))
132+
ups = append(ups, g.createUpstream(u, processor))
133133
}
134134

135135
ups = append(ups, createInvalidBackendRefUpstream())
@@ -139,9 +139,9 @@ func (g GeneratorImpl) createUpstreams(
139139

140140
func (g GeneratorImpl) createUpstream(
141141
up dataplane.Upstream,
142-
generator policies.UpstreamSettingsProcessor,
142+
processor policies.UpstreamSettingsProcessor,
143143
) http.Upstream {
144-
upstreamPolicySettings := generator.Process(up.Policies)
144+
upstreamPolicySettings := processor.Process(up.Policies)
145145

146146
zoneSize := ossZoneSize
147147
if g.plus {

0 commit comments

Comments
 (0)