@@ -13,42 +13,6 @@ sub vcl_init {
1313 tinykvm.init_self_requests("/tmp/tinykvm.sock" );
1414 #tinykvm.init_self_requests("", "http://127.0.0.1:8080");
1515
16- # Create new programs inline in VCL
17- tinykvm.configure("counter" ,
18- """{
19- " group" : " test",
20- " uri": " file:///home/gonzo/github/kvm_demo/c/counter",
21- "shared_memory" : 2 ,
22- "concurrency" : 4 ,
23- "ephemeral" : false
24- }""");
25- tinykvm.configure(" v8",
26- """ {
27- "uri" : "file:///home/gonzo/github/EmbedV8/v8-cmake/build/v8" ,
28- "concurrency" : 8 ,
29- "req_mem_limit_after_reset" : 64
30- }""");
31- tinykvm.main_arguments(" v8", """
32- function fibonacci(n) {
33- return n < 1 ? 0
34- : n <= 2 ? 1
35- : fibonacci(n - 1 ) + fibonacci(n - 2 )
36- }
37-
38- print("Version: " + version())
39- fibonacci(20 )
40- """);
41-
42- tinykvm.configure(" go",
43- """ {
44- "uri" : "file:///home/gonzo/github/kvm_demo/go/example/example" ,
45- "max_memory" : 2048 ,
46- "remapping" : ["0xC000000000" , 256 ],
47- "concurrency" : 4 ,
48- "storage" : true
49- }""");
50- #tinykvm.start(" counter");
51-
5216 # Add concurrency to important programs
5317 tinykvm.configure("avif" ,
5418 """{
@@ -67,25 +31,17 @@ sub vcl_recv {
6731 tinykvm.invalidate_programs();
6832 return (synth(200 ));
6933 }
70- else if (req.url == " /stats") {
34+ else if (req.url == "/" || req.url == "/ stats" ) {
7135 return (synth(803 ));
7236 }
7337 else if (req.url == "/scounter" ) {
7438 return (synth(801 ));
7539 }
76- else if (req.url == " /sv8") {
77- return (synth(804));
78- }
7940 else if (req.url == "/chain" || req.url == "/avif/image" || req.url ~ "/cat/" ) {
8041 return (hash );
8142 }
8243 return (pass );
8344}
84- sub vcl_synth {
85- if (resp.status == 401) {
86- set resp.http.WWW-Authenticate = """ Basic realm= "Access to section" """;
87- }
88- }
8945
9046sub vcl_backend_fetch {
9147 #tinykvm.to_string("collector", bereq.url);
@@ -302,11 +258,6 @@ sub vcl_backend_fetch {
302258 set bereq.backend = tinykvm.program("llama" ,
303259 bereq.http.X-Prompt , "" );
304260 }
305- else if (bereq.url == "/v8" ) {
306- #tinykvm.invalidate_programs("v8");
307- set bereq.backend = tinykvm.program("v8" , bereq.url );
308- return (fetch );
309- }
310261 else if (bereq.url == "/watermark" ) {
311262 //tinykvm.invalidate_program("watermark");
312263 set bereq.backend = tinykvm.program("watermark" );
@@ -324,8 +275,8 @@ sub vcl_backend_fetch {
324275 set bereq.backend = tinykvm.program("avif" );
325276 }
326277 else {
327- # All unknown URLs to demo static site
328- set bereq.backend = tinykvm.program("demo" , bereq.url );
278+ tinykvm.chain( "fetch" , "https://http.cat/404" );
279+ set bereq.backend = tinykvm.program("avif" );
329280 }
330281}
331282
@@ -346,9 +297,6 @@ sub vcl_synth {
346297 set resp.body = tinykvm.stats();
347298 set resp.status = 200 ;
348299 return (deliver );
349- } else if (resp.status == 804 ) {
350- tinykvm.synth(200 , "v8" , req.url );
351- return (deliver );
352300 }
353301 tinykvm.synth(resp.status , "fetch" , "/cat/" + resp.status );
354302 return (deliver );
0 commit comments