mirror of
https://github.com/graygnuorg/pound.git
synced 2026-10-28 11:35:07 +03:00
A "beacon" is a named boolean variable that can be inspected in conditionals. Beacons can be set and cleared at runtime via the pound control interface. They provide a mechanism for altering pound behavior without the need to reconfigure it. * src/Makefile.am: Add new source. * src/beacon.c: New file. * src/config.c (DeclareBeacon): New global statement. (Beacon): New conditional statement. * src/http.c (match_cond): Handle COND_BEACON. * src/pound-mode.el: Add new keywords. * src/pound.h (COND_BEACON): New condition code. (_service_cond): New field: "beacon". (pound_beacon_declare, pound_beacon_get) (pound_beacon_set, pound_beacon_serialize): New protos. * src/poundctl.c: New subcommand: "beacon". * src/poundctl.tmpl: New templates: "default.beacon" and "xml.beacon". * src/svc.c: New endpoint: "/beacon". * NEWS: Document changes. * doc/pound.8: Likewise. * doc/pound.texi: Likewise. * doc/poundctl.8: Likewise. * doc/poundctl.tmpl.5: Likewise. * tests/beacon.at: New test. * tests/Makefile.am: Add new file. * tests/testsuite.at: Include new test.
81 lines
1.4 KiB
Plaintext
81 lines
1.4 KiB
Plaintext
# This file is part of pound testsuite. -*- autotest -*-
|
|
# Copyright (C) 2026 Sergey Poznyakoff
|
|
#
|
|
# Pound is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# Pound is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with pound. If not, see <http://www.gnu.org/licenses/>.
|
|
AT_SETUP([Beacons])
|
|
AT_KEYWORDS([beacon poundctl])
|
|
AT_DATA([beacon.tmpl],
|
|
[{{define "default" -}}
|
|
{{range $name,$val = .beacons -}}
|
|
{{$name}} {{$val}}
|
|
{{end}}
|
|
{{- end -}}
|
|
])
|
|
PT_CHECK(
|
|
[DeclareBeacon "b1"
|
|
ListenHTTP
|
|
Service "one"
|
|
Beacon "b1"
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
Service "two"
|
|
Backend
|
|
Address
|
|
Port
|
|
End
|
|
End
|
|
End
|
|
],
|
|
[GET /echo/foo
|
|
end
|
|
|
|
200
|
|
x-backend-number: 1
|
|
end
|
|
|
|
run poundctl -f ./pound.cfg -t ./beacon.tmpl beacon
|
|
status 0
|
|
stdout
|
|
b1 false
|
|
end
|
|
end
|
|
|
|
run poundctl -f ./pound.cfg -t ./beacon.tmpl beacon -s b1
|
|
status 0
|
|
end
|
|
|
|
GET /echo/foo
|
|
end
|
|
|
|
200
|
|
x-backend-number: 0
|
|
end
|
|
|
|
run poundctl -f ./pound.cfg -t ./beacon.tmpl beacon -d b1
|
|
status 0
|
|
end
|
|
|
|
GET /echo/foo
|
|
end
|
|
|
|
200
|
|
x-backend-number: 1
|
|
end
|
|
|
|
])
|
|
AT_CLEANUP
|