Skip to content

Commit 65518ed

Browse files
authored
Merge pull request #285 from richardmarshall/backend-name-healthy
Add missing backend.{name}.* variables
2 parents e8871e5 + 08577c8 commit 65518ed

File tree

5 files changed

+68
-0
lines changed

5 files changed

+68
-0
lines changed

__generator__/predefined.yml

+15
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,21 @@ backend.socket.tcpi_total_retrans:
182182
on: [FETCH]
183183
get: INTEGER
184184

185+
backend.%any%.connections_open:
186+
reference: "https://www.fastly.com/documentation/reference/vcl/variables/backend-connection/backend-connections-open/"
187+
on: [RECV, HASH, HIT, MISS, PASS, FETCH, ERROR, DELIVER, LOG]
188+
get: INTEGER
189+
190+
backend.%any%.connections_used:
191+
reference: "https://www.fastly.com/documentation/reference/vcl/variables/backend-connection/backend-connections-used/"
192+
on: [RECV, HASH, HIT, MISS, PASS, FETCH, ERROR, DELIVER, LOG]
193+
get: INTEGER
194+
195+
backend.%any%.healthy:
196+
reference: "https://developer.fastly.com/reference/vcl/variables/backend-connection/backend-healthy/"
197+
on: [RECV, HASH, HIT, MISS, PASS, FETCH, ERROR, DELIVER, LOG]
198+
get: INTEGER
199+
185200
bereq.between_bytes_timeout:
186201
reference: "https://developer.fastly.com/reference/vcl/variables/backend-connection/bereq-between-bytes-timeout/"
187202
on: [PASS, MISS]

context/predefined.go

+34
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/variables.md

+3
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ Will be updated when we find or implement a way to get accurate values.
9797
| backend.socket.tcpi_snd_mss | 0 |
9898
| backend.socket.tcpi_snd_ssthresh | 0 |
9999
| backend.socket.tcpi_total_retrans | 0 |
100+
| backend.{name}.connections_open | 0 |
101+
| backend.{name}.connections_used | 0 |
102+
| backend.{name}.healthy | true |
100103
| beresp.backend.alternate_ips | (empty string) |
101104
| beresp.backend.ip | 0 |
102105
| beresp.backend.requests | 1 |

interpreter/variable/all.go

+13
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,19 @@ func (v *AllScopeVariables) getFromRegex(name string) value.Value {
663663
Value: val,
664664
}
665665
}
666+
667+
if match := backendConnectionsOpenRegex.FindStringSubmatch(name); match != nil {
668+
return &value.Integer{}
669+
}
670+
671+
if match := backendConnectionsUsedRegex.FindStringSubmatch(name); match != nil {
672+
return &value.Integer{}
673+
}
674+
675+
if match := backendHealthyRegex.FindStringSubmatch(name); match != nil {
676+
return &value.Boolean{Value: true}
677+
}
678+
666679
return nil
667680
}
668681

interpreter/variable/variable.go

+3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ var (
2323
objectHttpHeaderRegex = regexp.MustCompile(`^obj\.http\.(.+)`)
2424
rateCounterRegex = regexp.MustCompile(`ratecounter\.([^\.]+)\.(.+)`)
2525
regexMatchedRegex = regexp.MustCompile(`re\.group\.([0-9]+)`)
26+
backendConnectionsOpenRegex = regexp.MustCompile(`backend\.([^\.]+)\.connections_open`)
27+
backendConnectionsUsedRegex = regexp.MustCompile(`backend\.([^\.]+)\.connections_used`)
28+
backendHealthyRegex = regexp.MustCompile(`backend\.([^\.]+)\.healthy`)
2629
)
2730

2831
func doAssign(left value.Value, operator string, right value.Value) error {

0 commit comments

Comments
 (0)