Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libvmod-weightadjust
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
libvmod-weightadjust
Commits
33c7cf9a
Commit
33c7cf9a
authored
Sep 28, 2017
by
Nils Goroll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Automatic rename of libvmod-example to libvmod-weightadjust.
parent
a17fb592
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
85 deletions
+37
-85
CHANGES.rst
CHANGES.rst
+3
-3
README.rst
README.rst
+9
-9
configure.ac
configure.ac
+3
-3
rename-vmod-script
rename-vmod-script
+0
-48
Makefile.am
src/Makefile.am
+10
-10
test01.vtc
src/tests/test01.vtc
+7
-7
vmod_weightadjust.c
src/vmod_weightadjust.c
+2
-2
vmod_weightadjust.vcc
src/vmod_weightadjust.vcc
+3
-3
No files found.
CHANGES.rst
View file @
33c7cf9a
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.
libvmod-
example
0.1 (1970-01-01)
libvmod-
weightadjust
0.1 (1970-01-01)
--------------------------------
* Add list items with changes done.
...
...
README.rst
View file @
33c7cf9a
============
vmod-
example
vmod-
weightadjust
============
SYNOPSIS
========
import
example
;
import
weightadjust
;
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.
...
...
@@ -28,10 +28,10 @@ Return value
STRING
Description
Returns "Hello, " prepended to S
Example
Weightadjust
::
set resp.http.hello =
example
.hello("World");
set resp.http.hello =
weightadjust
.hello("World");
INSTALLATION
============
...
...
@@ -87,11 +87,11 @@ USAGE
In your VCL you could then use this vmod along the following lines::
import
example
;
import
weightadjust
;
sub vcl_deliver {
# This sets resp.http.hello to "Hello, World"
set resp.http.hello =
example
.hello("World");
set resp.http.hello =
weightadjust
.hello("World");
}
COMMON PROBLEMS
...
...
@@ -111,10 +111,10 @@ COMMON PROBLEMS
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
git clone libvmod-
example
libvmod-$name
git clone libvmod-
weightadjust
libvmod-$name
cd libvmod-$name
./rename-vmod-script $name
...
...
configure.ac
View file @
33c7cf9a
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_CONFIG_MACRO_DIR([m4])
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])
AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests])
...
...
@@ -29,7 +29,7 @@ AC_ARG_WITH([rst2man],
m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see README.rst]))
VARNISH_PREREQ([5.2])
VARNISH_VMODS([
example
])
VARNISH_VMODS([
weightadjust
])
VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
AC_SUBST(VMOD_TESTS)
...
...
rename-vmod-script
deleted
100755 → 0
View file @
a17fb592
#!/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
src/Makefile.am
View file @
33c7cf9a
AM_CFLAGS
=
$(VARNISHAPI_CFLAGS)
-Wall
-Werror
AM_LDFLAGS
=
$(VARNISHAPI_LIBS)
$(VMOD_LDFLAGS)
vmod_LTLIBRARIES
=
libvmod_
example
.la
vmod_LTLIBRARIES
=
libvmod_
weightadjust
.la
libvmod_
example
_la_SOURCES
=
\
vmod_
example
.c
libvmod_
weightadjust
_la_SOURCES
=
\
vmod_
weightadjust
.c
nodist_libvmod_
example
_la_SOURCES
=
\
vcc_
example
_if.c
\
vcc_
example
_if.h
nodist_libvmod_
weightadjust
_la_SOURCES
=
\
vcc_
weightadjust
_if.c
\
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
=
\
PATH
=
"
$(VMOD_TEST_PATH)
"
\
LD_LIBRARY_PATH
=
"
$(VARNISH_LIBRARY_PATH)
"
TEST_EXTENSIONS
=
.vtc
VTC_LOG_COMPILER
=
varnishtest
-v
AM_VTC_LOG_FLAGS
=
-Dvmod_
example
=
"
$(VMOD_EXAMPLE
)
"
AM_VTC_LOG_FLAGS
=
-Dvmod_
weightadjust
=
"
$(VMOD_WEIGHTADJUST
)
"
TESTS
=
@VMOD_TESTS@
EXTRA_DIST
=
\
vmod_
example
.vcc
\
vmod_
weightadjust
.vcc
\
$(VMOD_TESTS)
src/tests/test01.vtc
View file @
33c7cf9a
varnishtest "Test
example
vmod"
varnishtest "Test
weightadjust
vmod"
server s1 {
rxreq
...
...
@@ -7,28 +7,28 @@ server s1 {
varnish v1 -vcl+backend {
import std;
import ${vmod_
example
};
import ${vmod_
weightadjust
};
sub vcl_init {
std.log(
example
.info());
std.log(
weightadjust
.info());
}
sub vcl_deliver {
set resp.http.hello =
example
.hello("World");
set resp.http.info =
example
.info();
set resp.http.hello =
weightadjust
.hello("World");
set resp.http.info =
weightadjust
.info();
}
} -start
logexpect l1 -v v1 -g raw -d 1 {
expect 0 0 CLI {^Rd vcl.load}
expect 0 = VCL_Log {^vmod_
example
loaded at }
expect 0 = VCL_Log {^vmod_
weightadjust
loaded at }
} -start
client c1 {
txreq -url "/"
rxresp
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
...
...
src/vmod_
example
.c
→
src/vmod_
weightadjust
.c
View file @
33c7cf9a
...
...
@@ -8,7 +8,7 @@
#include "vcl.h"
#include "vtim.h"
#include "vcc_
example
_if.h"
#include "vcc_
weightadjust
_if.h"
const
size_t
infosz
=
64
;
char
*
info
;
...
...
@@ -52,7 +52,7 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
}
AN
(
event
);
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
);
}
...
...
src/vmod_
example
.vcc
→
src/vmod_
weightadjust
.vcc
View file @
33c7cf9a
...
...
@@ -4,18 +4,18 @@
# (vmodtool requires this format.)
#
$Module
example 3 Example
VMOD
$Module
weightadjust 3 Weightadjust
VMOD
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.
It can span multiple lines and is written in RST format.
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/
$Event event_function
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment