Commit 33c7cf9a authored by Nils Goroll's avatar Nils Goroll

Automatic rename of libvmod-example to libvmod-weightadjust.

parent a17fb592
This is a running log of changes to libvmod-example. This is a running log of changes to libvmod-weightadjust.
libvmod-example 0.2 (unreleased) libvmod-weightadjust 0.2 (unreleased)
-------------------------------- --------------------------------
* The most recent release entry is at the top. * The most recent release entry is at the top.
libvmod-example 0.1 (1970-01-01) libvmod-weightadjust 0.1 (1970-01-01)
-------------------------------- --------------------------------
* Add list items with changes done. * Add list items with changes done.
......
============ ============
vmod-example vmod-weightadjust
============ ============
SYNOPSIS SYNOPSIS
======== ========
import example; import weightadjust;
DESCRIPTION DESCRIPTION
=========== ===========
Example Varnish vmod demonstrating how to write an out-of-tree Varnish vmod. Weightadjust Varnish vmod demonstrating how to write an out-of-tree Varnish vmod.
Implements the traditional Hello World as a vmod. Implements the traditional Hello World as a vmod.
...@@ -28,10 +28,10 @@ Return value ...@@ -28,10 +28,10 @@ Return value
STRING STRING
Description Description
Returns "Hello, " prepended to S Returns "Hello, " prepended to S
Example Weightadjust
:: ::
set resp.http.hello = example.hello("World"); set resp.http.hello = weightadjust.hello("World");
INSTALLATION INSTALLATION
============ ============
...@@ -87,11 +87,11 @@ USAGE ...@@ -87,11 +87,11 @@ USAGE
In your VCL you could then use this vmod along the following lines:: In your VCL you could then use this vmod along the following lines::
import example; import weightadjust;
sub vcl_deliver { sub vcl_deliver {
# This sets resp.http.hello to "Hello, World" # This sets resp.http.hello to "Hello, World"
set resp.http.hello = example.hello("World"); set resp.http.hello = weightadjust.hello("World");
} }
COMMON PROBLEMS COMMON PROBLEMS
...@@ -111,10 +111,10 @@ COMMON PROBLEMS ...@@ -111,10 +111,10 @@ COMMON PROBLEMS
START YOUR OWN VMOD START YOUR OWN VMOD
=================== ===================
The basic steps to start a new vmod from this example are:: The basic steps to start a new vmod from this weightadjust are::
name=myvmod name=myvmod
git clone libvmod-example libvmod-$name git clone libvmod-weightadjust libvmod-$name
cd libvmod-$name cd libvmod-$name
./rename-vmod-script $name ./rename-vmod-script $name
......
AC_PREREQ([2.68]) AC_PREREQ([2.68])
AC_INIT([libvmod-example], [0.1], [], [vmod-example]) AC_INIT([libvmod-weightadjust], [0.1], [], [vmod-weightadjust])
AC_COPYRIGHT([Public Domain]) AC_COPYRIGHT([Public Domain])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR(src/vmod_example.vcc) AC_CONFIG_SRCDIR(src/vmod_weightadjust.vcc)
AC_CONFIG_HEADER([config.h]) AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests]) AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests])
...@@ -29,7 +29,7 @@ AC_ARG_WITH([rst2man], ...@@ -29,7 +29,7 @@ AC_ARG_WITH([rst2man],
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst])) m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
VARNISH_PREREQ([5.2]) VARNISH_PREREQ([5.2])
VARNISH_VMODS([example]) VARNISH_VMODS([weightadjust])
VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)" VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
AC_SUBST(VMOD_TESTS) AC_SUBST(VMOD_TESTS)
......
#!/bin/bash
#
# Script to rename libvmod-example into libvmod-foo.
# (where "foo" is your new vmod name, of course.)
#
# Leaves the changes uncommitted in the working tree, so you get to fix any
# unintended changes.
#
# Author: Lasse Karstensen <lkarsten@varnish-software.com>, September 2014.
#
set -o errexit
NAME=$1
if [ -z "$NAME" ]; then
echo "Usage: $0 <new-vmod-name-without-libvmod-prefix>"
echo "Rename libvmod-example source tree."
echo "If the name is an acronym, you can use capital letters."
echo
exit -1
fi
SYM_NAME=${NAME,,*}
CAP_NAME=${NAME^?}
UPP_NAME=${NAME^^?}
if ! git diff-index --quiet HEAD --; then
echo "ERROR: Need a clean working tree. Run \"git stash\" first."
exit -2
fi
git mv src/vmod_example.c src/vmod_${SYM_NAME}.c
git mv src/vmod_example.vcc src/vmod_${SYM_NAME}.vcc
git grep -z -l example | xargs -0 sed -i -s -e "s/example/${SYM_NAME}/g"
git grep -z -l Example | xargs -0 sed -i -s -e "s/Example/${CAP_NAME}/g"
git grep -z -l EXAMPLE | xargs -0 sed -i -s -e "s/EXAMPLE/${UPP_NAME}/g"
git rm -f rename-vmod-script
# restore foreign files
git checkout -- m4/
cat <<EOF
All done.
For your cut&paste needs:
git commit -a -m "Automatic rename of libvmod-example to libvmod-${SYM_NAME}."
EOF
AM_CFLAGS = $(VARNISHAPI_CFLAGS) -Wall -Werror AM_CFLAGS = $(VARNISHAPI_CFLAGS) -Wall -Werror
AM_LDFLAGS = $(VARNISHAPI_LIBS) $(VMOD_LDFLAGS) AM_LDFLAGS = $(VARNISHAPI_LIBS) $(VMOD_LDFLAGS)
vmod_LTLIBRARIES = libvmod_example.la vmod_LTLIBRARIES = libvmod_weightadjust.la
libvmod_example_la_SOURCES = \ libvmod_weightadjust_la_SOURCES = \
vmod_example.c vmod_weightadjust.c
nodist_libvmod_example_la_SOURCES = \ nodist_libvmod_weightadjust_la_SOURCES = \
vcc_example_if.c \ vcc_weightadjust_if.c \
vcc_example_if.h vcc_weightadjust_if.h
dist_man_MANS = vmod_example.3 dist_man_MANS = vmod_weightadjust.3
@BUILD_VMOD_EXAMPLE@ @BUILD_VMOD_WEIGHTADJUST@
AM_TESTS_ENVIRONMENT = \ AM_TESTS_ENVIRONMENT = \
PATH="$(VMOD_TEST_PATH)" \ PATH="$(VMOD_TEST_PATH)" \
LD_LIBRARY_PATH="$(VARNISH_LIBRARY_PATH)" LD_LIBRARY_PATH="$(VARNISH_LIBRARY_PATH)"
TEST_EXTENSIONS = .vtc TEST_EXTENSIONS = .vtc
VTC_LOG_COMPILER = varnishtest -v VTC_LOG_COMPILER = varnishtest -v
AM_VTC_LOG_FLAGS = -Dvmod_example="$(VMOD_EXAMPLE)" AM_VTC_LOG_FLAGS = -Dvmod_weightadjust="$(VMOD_WEIGHTADJUST)"
TESTS = @VMOD_TESTS@ TESTS = @VMOD_TESTS@
EXTRA_DIST = \ EXTRA_DIST = \
vmod_example.vcc \ vmod_weightadjust.vcc \
$(VMOD_TESTS) $(VMOD_TESTS)
varnishtest "Test example vmod" varnishtest "Test weightadjust vmod"
server s1 { server s1 {
rxreq rxreq
...@@ -7,28 +7,28 @@ server s1 { ...@@ -7,28 +7,28 @@ server s1 {
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import std; import std;
import ${vmod_example}; import ${vmod_weightadjust};
sub vcl_init { sub vcl_init {
std.log(example.info()); std.log(weightadjust.info());
} }
sub vcl_deliver { sub vcl_deliver {
set resp.http.hello = example.hello("World"); set resp.http.hello = weightadjust.hello("World");
set resp.http.info = example.info(); set resp.http.info = weightadjust.info();
} }
} -start } -start
logexpect l1 -v v1 -g raw -d 1 { logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load} expect 0 0 CLI {^Rd vcl.load}
expect 0 = VCL_Log {^vmod_example loaded at } expect 0 = VCL_Log {^vmod_weightadjust loaded at }
} -start } -start
client c1 { client c1 {
txreq -url "/" txreq -url "/"
rxresp rxresp
expect resp.http.hello == "Hello, World" expect resp.http.hello == "Hello, World"
expect resp.http.info ~ "^vmod_example warmed at " expect resp.http.info ~ "^vmod_weightadjust warmed at "
} }
client c1 -run client c1 -run
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "vcl.h" #include "vcl.h"
#include "vtim.h" #include "vtim.h"
#include "vcc_example_if.h" #include "vcc_weightadjust_if.h"
const size_t infosz = 64; const size_t infosz = 64;
char *info; char *info;
...@@ -52,7 +52,7 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) ...@@ -52,7 +52,7 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
} }
AN(event); AN(event);
VTIM_format(VTIM_real(), ts); VTIM_format(VTIM_real(), ts);
snprintf(info, infosz, "vmod_example %s at %s", event, ts); snprintf(info, infosz, "vmod_weightadjust %s at %s", event, ts);
return (0); return (0);
} }
......
...@@ -4,18 +4,18 @@ ...@@ -4,18 +4,18 @@
# (vmodtool requires this format.) # (vmodtool requires this format.)
# #
$Module example 3 Example VMOD $Module weightadjust 3 Weightadjust VMOD
DESCRIPTION DESCRIPTION
=========== ===========
This is the embedded documentation for the example VMOD. It should This is the embedded documentation for the weightadjust VMOD. It should
mention what the vmod is intended to do. mention what the vmod is intended to do.
It can span multiple lines and is written in RST format. It can span multiple lines and is written in RST format.
You can even have links and lists in here: You can even have links and lists in here:
* https://github.com/varnish/libvmod-example/ * https://github.com/varnish/libvmod-weightadjust/
* https://www.varnish-cache.org/ * https://www.varnish-cache.org/
$Event event_function $Event event_function
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment