-
Notifications
You must be signed in to change notification settings - Fork 376
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tell/ear interface for CLI access to vmod objects
Runtime modification of vmod object properties has been a long standing item on our wishlist. For example, #3652 is about a use case to change a custom director property, which is not covered by the director health state. Another simple example is to instruct a vmod object to emit log messages for tracing only when needed. This commit implements a basic interface for CLI access to vmod objects: VMOD objects now can have ears, and the CLI gets a command to tell messages to ears. vmod ears --------- VMOD object classes gain a special method type $Ear, which is almost identical to $Method, except that only one ear is supported per class, and only the specific signature $Ear STRANDS earname(STRANDS) is supported. The ear receives input via the single STRANDS arguments and can either return NULL for error, or a response as a STRANDS. For the error case, the ear can write details to ctx->msg. cli tell command ---------------- The tell command takes an optional vcl name, object name and message to send. Individual message arguments are passed as constituents of the STRANDS argument to the ear. demo ---- A new test case demos the functionality: The debug.obj class has gained an ear which just returns the instance name followed by the original message: varnish> help tell 200 tell [<vcl>.]<object> <msg> ... Tell <msg> to <object> from the given <vcl> or the active vcl varnish> tell obj0 is there anybody out there? 200 obj0: is there anybody out there? varnish> tell whoisit hello? 300 No object named whoisit found varnish> tell obj0 fail 300 You asked me to fail
- Loading branch information
Showing
11 changed files
with
278 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
varnishtest "Test vmod ears / vcl tell" | ||
|
||
varnish v1 -vcl+backend { | ||
import debug; | ||
|
||
backend proforma none; | ||
|
||
sub vcl_init { | ||
new obj0 = debug.obj(); | ||
new obj1 = debug.obj("only_argument"); | ||
new oo0 = debug.obj_opt(); | ||
} | ||
} -start | ||
|
||
# vcl2 not found | ||
varnish v1 -clierr "300" "tell vcl2.obj0 a b c" | ||
# No object named objX found | ||
varnish v1 -clierr "300" "tell objX a b c" | ||
# Object oo0 has no ear | ||
varnish v1 -clierr "300" "tell oo0 a b c" | ||
# Too few parameters | ||
varnish v1 -clierr "104" "tell obj0" | ||
|
||
varnish v1 -cliexpect "obj0: a b c" "tell obj0 a b c" | ||
varnish v1 -cliexpect "obj0: a b c" "tell vcl1.obj0 a b c" | ||
varnish v1 -cliexpect "obj1: a b c" "tell obj1 a b c" |
Oops, something went wrong.