Skip to content

Commit 2050ff0

Browse files
detailyangdenji
authored andcommitted
expose api ngx_http_upstream_check_upstream_down
1 parent 0a298d9 commit 2050ff0

4 files changed

+89
-0
lines changed

ngx_http_upstream_check_module.c

+20
Original file line numberDiff line numberDiff line change
@@ -947,6 +947,26 @@ ngx_http_upstream_check_peer_down(ngx_uint_t index) {
947947
return (peer[index].shm->down);
948948
}
949949

950+
ngx_uint_t
951+
ngx_http_upstream_check_upstream_down(ngx_str_t *upstream) {
952+
ngx_uint_t i;
953+
ngx_http_upstream_check_peer_t *peers;
954+
955+
if (check_peers_ctx == NULL) {
956+
return 0;
957+
}
958+
959+
peers = check_peers_ctx->peers.elts;
960+
for (i = 0; i < check_peers_ctx->peers.nelts; i++) {
961+
if (peers[i].upstream_name->len == upstream->len
962+
&& ngx_strncmp(peers[i].upstream_name->data, upstream->data, upstream->len) == 0)
963+
if (!peers[i].shm->down) {
964+
return 0;
965+
}
966+
}
967+
968+
return 1;
969+
}
950970

951971
/* TODO: this interface can count each peer's busyness */
952972
void

ngx_http_upstream_check_module.h

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ngx_uint_t ngx_http_upstream_check_add_peer(ngx_conf_t *cf,
1010
ngx_http_upstream_srv_conf_t *us, ngx_addr_t *peer);
1111

1212
ngx_uint_t ngx_http_upstream_check_peer_down(ngx_uint_t index);
13+
ngx_uint_t ngx_http_upstream_check_upstream_down(ngx_str_t *upstream);
1314

1415
void ngx_http_upstream_check_get_peer(ngx_uint_t index);
1516
void ngx_http_upstream_check_free_peer(ngx_uint_t index);

y/CHANGELOG.tpl.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{{ range .Versions }}
2+
<a name="{{ .Tag.Name }}"></a>
3+
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }}
4+
5+
> {{ datetime "2006-01-02" .Tag.Date }}
6+
7+
{{ range .CommitGroups -}}
8+
### {{ .Title }}
9+
10+
{{ range .Commits -}}
11+
* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
12+
{{ end }}
13+
{{ end -}}
14+
15+
{{- if .RevertCommits -}}
16+
### Reverts
17+
18+
{{ range .RevertCommits -}}
19+
* {{ .Revert.Header }}
20+
{{ end }}
21+
{{ end -}}
22+
23+
{{- if .MergeCommits -}}
24+
### Pull Requests
25+
26+
{{ range .MergeCommits -}}
27+
* {{ .Header }}
28+
{{ end }}
29+
{{ end -}}
30+
31+
{{- if .NoteGroups -}}
32+
{{ range .NoteGroups -}}
33+
### {{ .Title }}
34+
35+
{{ range .Notes }}
36+
{{ .Body }}
37+
{{ end }}
38+
{{ end -}}
39+
{{ end -}}
40+
{{ end -}}

y/config.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
style: github
2+
template: CHANGELOG.tpl.md
3+
info:
4+
title: CHANGELOG
5+
repository_url: https://github.com/nginx-modules/nginx_upstream_check_module
6+
options:
7+
commits:
8+
# filters:
9+
# Type:
10+
# - feat
11+
# - fix
12+
# - perf
13+
# - refactor
14+
commit_groups:
15+
# title_maps:
16+
# feat: Features
17+
# fix: Bug Fixes
18+
# perf: Performance Improvements
19+
# refactor: Code Refactoring
20+
header:
21+
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
22+
pattern_maps:
23+
- Type
24+
- Scope
25+
- Subject
26+
notes:
27+
keywords:
28+
- BREAKING CHANGE

0 commit comments

Comments
 (0)