Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing backend.{name}.* variables #285

Merged
merged 1 commit into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions __generator__/predefined.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ backend.socket.tcpi_total_retrans:
on: [FETCH]
get: INTEGER

backend.%any%.connections_open:
reference: "https://www.fastly.com/documentation/reference/vcl/variables/backend-connection/backend-connections-open/"
on: [RECV, HASH, HIT, MISS, PASS, FETCH, ERROR, DELIVER, LOG]
get: INTEGER

backend.%any%.connections_used:
reference: "https://www.fastly.com/documentation/reference/vcl/variables/backend-connection/backend-connections-used/"
on: [RECV, HASH, HIT, MISS, PASS, FETCH, ERROR, DELIVER, LOG]
get: INTEGER

backend.%any%.healthy:
reference: "https://developer.fastly.com/reference/vcl/variables/backend-connection/backend-healthy/"
on: [RECV, HASH, HIT, MISS, PASS, FETCH, ERROR, DELIVER, LOG]
get: INTEGER

bereq.between_bytes_timeout:
reference: "https://developer.fastly.com/reference/vcl/variables/backend-connection/bereq-between-bytes-timeout/"
on: [PASS, MISS]
Expand Down
34 changes: 34 additions & 0 deletions context/predefined.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ Will be updated when we find or implement a way to get accurate values.
| backend.socket.tcpi_snd_mss | 0 |
| backend.socket.tcpi_snd_ssthresh | 0 |
| backend.socket.tcpi_total_retrans | 0 |
| backend.{name}.connections_open | 0 |
| backend.{name}.connections_used | 0 |
| backend.{name}.healthy | true |
| beresp.backend.alternate_ips | (empty string) |
| beresp.backend.ip | 0 |
| beresp.backend.requests | 1 |
Expand Down
13 changes: 13 additions & 0 deletions interpreter/variable/all.go
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,19 @@ func (v *AllScopeVariables) getFromRegex(name string) value.Value {
Value: val,
}
}

if match := backendConnectionsOpenRegex.FindStringSubmatch(name); match != nil {
return &value.Integer{}
}

if match := backendConnectionsUsedRegex.FindStringSubmatch(name); match != nil {
return &value.Integer{}
}

if match := backendHealthyRegex.FindStringSubmatch(name); match != nil {
return &value.Boolean{Value: true}
}

return nil
}

Expand Down
3 changes: 3 additions & 0 deletions interpreter/variable/variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ var (
objectHttpHeaderRegex = regexp.MustCompile(`^obj\.http\.(.+)`)
rateCounterRegex = regexp.MustCompile(`ratecounter\.([^\.]+)\.(.+)`)
regexMatchedRegex = regexp.MustCompile(`re\.group\.([0-9]+)`)
backendConnectionsOpenRegex = regexp.MustCompile(`backend\.([^\.]+)\.connections_open`)
backendConnectionsUsedRegex = regexp.MustCompile(`backend\.([^\.]+)\.connections_used`)
backendHealthyRegex = regexp.MustCompile(`backend\.([^\.]+)\.healthy`)
)

func doAssign(left value.Value, operator string, right value.Value) error {
Expand Down
Loading