Skip to content

Commit

Permalink
BREAKING CHANGE
Browse files Browse the repository at this point in the history
* Transitioned to PipyJS
* Dropped support of .cfg files in favour of JS scripts
* Reworked all filters (formerly called modules)
* Added builtin web UI
  • Loading branch information
pajama-coder committed May 26, 2021
1 parent d587658 commit 9c5f137
Show file tree
Hide file tree
Showing 335 changed files with 71,301 additions and 113,012 deletions.
105 changes: 69 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
cmake_minimum_required (VERSION 2.8)
project(pipy)

option(PIPY_GUI "include builtin GUI" OFF)

add_subdirectory(deps/yajl-2.1.0)

option(BUILD_shared "build a shared expat library" OFF)
Expand All @@ -13,7 +15,6 @@ set(CMAKE_CXX_FLAGS -std=c++11)

add_definitions(
-D_GNU_SOURCE
-DCONFIG_VERSION="2020-11-08"
-DPIPY_HOST="${CMAKE_HOST_SYSTEM} ${CMAKE_HOST_SYSTEM_PROCESSOR}"
)

Expand All @@ -24,60 +25,92 @@ include_directories(
"${CMAKE_BINARY_DIR}/deps/yajl-2.1.0/yajl-2.1.0/include"
"${CMAKE_BINARY_DIR}/deps/libexpat-R_2_2_6/expat/lib"
"${CMAKE_SOURCE_DIR}/deps/libexpat-R_2_2_6/expat/lib"
"${CMAKE_SOURCE_DIR}/deps/quickjs-2020-11-08"
)

add_executable(pipy
deps/quickjs-2020-11-08/cutils.c
deps/quickjs-2020-11-08/libregexp.c
deps/quickjs-2020-11-08/libunicode.c
deps/quickjs-2020-11-08/quickjs.c
src/config.cpp
src/api/algo.cpp
src/api/configuration.cpp
src/api/console.cpp
src/api/crypto.cpp
src/api/hessian.cpp
src/api/http.cpp
src/api/json.cpp
src/api/os.cpp
src/api/url.cpp
src/api/xml.cpp
src/context.cpp
src/crypto.cpp
src/data.cpp
src/event.cpp
src/filter.cpp
src/filters/connect.cpp
src/filters/demux.cpp
src/filters/dubbo.cpp
src/filters/dummy.cpp
src/filters/dump.cpp
src/filters/exec.cpp
src/filters/fork.cpp
src/filters/http.cpp
src/filters/link.cpp
src/filters/mux.cpp
src/filters/on-body.cpp
src/filters/on-event.cpp
src/filters/on-message.cpp
src/filters/on-start.cpp
src/filters/print.cpp
src/filters/replace-body.cpp
src/filters/replace-event.cpp
src/filters/replace-message.cpp
src/filters/replace-start.cpp
src/filters/tap.cpp
src/filters/use.cpp
src/filters/wait.cpp
src/fstream.cpp
src/graph.cpp
src/gui.cpp
src/inbound.cpp
src/js.cpp
src/listener.cpp
src/logging.cpp
src/main.cpp
src/match.cpp
src/metrics.cpp
src/message.cpp
src/module.cpp
src/modules/clone.cpp
src/modules/counter.cpp
src/modules/dubbo.cpp
src/modules/dummy.cpp
src/modules/erase.cpp
src/modules/filter.cpp
src/modules/hello.cpp
src/modules/hessian2.cpp
src/modules/http.cpp
src/modules/insert.cpp
src/modules/json.cpp
src/modules/message.cpp
src/modules/print.cpp
src/modules/prometheus.cpp
src/modules/proxy.cpp
src/modules/queue.cpp
src/modules/script.cpp
src/modules/serve-static.cpp
src/modules/tap.cpp
src/modules/timestamp.cpp
src/modules/xml.cpp
src/net.cpp
src/options.cpp
src/outbound.cpp
src/pipeline.cpp
src/pjs/builtin.cpp
src/pjs/expr.cpp
src/pjs/parser.cpp
src/pjs/types.cpp
src/session.cpp
src/tar.cpp
src/task.cpp
src/utils.cpp
src/worker.cpp
)

add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/deps/version.h
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/deps/version.h
COMMAND ${CMAKE_SOURCE_DIR}/generate_version_h.sh
ARGS ${CMAKE_BINARY_DIR}/deps/version.h
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

add_custom_target(GenVerH DEPENDS ${CMAKE_BINARY_DIR}/deps/version.h)
add_custom_target(GenVer DEPENDS ${CMAKE_BINARY_DIR}/deps/version.h)
add_dependencies(pipy yajl_s expat crypto ssl GenVer)

if(PIPY_GUI)
add_definitions(-DPIPY_USE_GUI)

add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/deps/gui.tar.h
COMMAND node
ARGS pack.js ${CMAKE_BINARY_DIR}/deps/gui.tar.h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/gui
DEPENDS gui/pack.js ${CMAKE_SOURCE_DIR}/gui/public/index.html
)

add_custom_target(GenGui DEPENDS ${CMAKE_BINARY_DIR}/deps/gui.tar.h)
add_dependencies(pipy GenGui)

add_dependencies(pipy yajl_s expat crypto ssl GenVerH)
endif()

target_link_libraries(pipy yajl_s expat crypto ssl -pthread)
target_link_libraries(pipy z yajl_s expat crypto ssl -pthread)
26 changes: 0 additions & 26 deletions LICENCE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Licenses of these open source projects are also included in this file.
* Flomesh Pipy
* Boost Asio 1.12.2
* OpenSSL 1.1.1g
* QuickJS 2020-11-08
* YAJL 2.1.0
* Expat 2.2.6

Expand Down Expand Up @@ -207,31 +206,6 @@ copied and put under another distribution licence
----------------------------------------------------------------
----------------------------------------------------------------

QuickJS 2020-11-08

Copyright Fabrice Bellard and Charlie Gordon.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

----------------------------------------------------------------
----------------------------------------------------------------

YAJL 2.1.0

Copyright (c) 2007-2014, Lloyd Hilaiel <me@lloyd.io>
Expand Down
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ Pipy is a tiny, high performance, highly stable, programmable proxy. Written
in C++, built on top of Asio asynchronous I/O library, Pipy is extremely
lightweight and fast, making it one of the best choices for service mesh sidecars.

With builtin JavaScript support, thanks to QuickJS, Pipy is highly
With builtin JavaScript support, thanks to PipyJS, Pipy is highly
customizable and also predictable in performance with no garbage collection
overhead seen in other scriptable counterparts.
overhead found in other scriptable counterparts.

At its core, Pipy has a modular design with many small reusable modules
that can be chained together to make a pipeline, through which network data
flow and get processed on the way. The way Pipy is designed makes it versatile
enough for not only sidecars but also other use cases involving intermediate
message processing between network nodes.
At its core, Pipy has a modular design with a set of fundamental filters
that can be chained together to make a pipeline, through which network data can
flow and get processed along the way. The way Pipy is designed makes it versatile
enough for not only service mesh sidecars but also other use cases involving
intermediate message processing between network nodes.

# Compatibility

Expand All @@ -34,6 +34,7 @@ Before building, the following tools are required to be installed first:

* Clang 5.0+
* CMake 3.0+
* Node.js v12+ (only required if the builtin web UI is turned on)

With the above tools installed, just run the build script to start building:

Expand Down Expand Up @@ -73,27 +74,26 @@ yum -y install http://repo.flomesh.cn/pipy/pipy-latest.el7_pl.x86_64.rpm
$ pipy --help
```

## List Modules and Parameters
## List Builtin Filters and Their Parameters

```
$ pipy --list-modules
$ pipy --help-modules
$ pipy --list-filters
$ pipy --help-filters
```

## Run on CLI

Let's take the echo server in `test/001-echo/` as an example. To start a single-worker
Pipy that auto-reloads when the configuration file changes:
Let's take the echo server in `test/001-echo/` as an example. To start a Pipy instance
that echos whatever the request has in its body, say

```
$ pipy test/001-echo/pipy.cfg --watch-config-file
$ pipy test/001-echo/pipy.js
```

To start two Pipy instances load balancing on the same port:
Or, while developing and debugging, one can start Pipy in web UI mode by using:

```
$ pipy test/001-echo/pipy.cfg --reuse-port &
$ pipy test/001-echo/pipy.cfg --reuse-port &
$ pipy test/ --gui-port=6060
```

## Run with Docker
Expand Down
12 changes: 8 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,21 @@ fi

CMAKE=
function __build_deps_check() {
if [ ! -z $(command -v cmake) ]; then
export CMAKE=cmake
elif [ ! -z $(command -v cmake3) ]; then
if [ ! -z $(command -v cmake3) ]; then
export CMAKE=cmake3
elif [ ! -z $(command -v cmake) ]; then
export CMAKE=cmake
fi
clang --version 2>&1 > /dev/null && clang++ --version 2>&1 > /dev/null && export __CLANG_EXIST=true
if [ "x"$CMAKE = "x" ] || ! $__CLANG_EXIST ; then echo "Command \`cmake\` or \`clang\` not found." && exit -1; fi
}

function build() {
__build_deps_check
cd ${PIPY_DIR}
BRANCH=`git branch --show-current`
git fetch
git pull origin $BRANCH
export CC=clang
export CXX=clang++
mkdir ${PIPY_DIR}/build 2>&1 > /dev/null || true
Expand Down Expand Up @@ -184,7 +188,7 @@ if ! $TEST_ONLY && $BUILD_RPM; then
--build-arg COMMIT_ID=$COMMIT_ID \
--build-arg COMMIT_DATE="$COMMIT_DATE" \
-f $DOCKERFILE .
sudo docker run -it --rm -v $PIPY_DIR/rpm:/data pipy-rpm:$RELEASE_VERSION cp /rpm/pipy-community-${RELEASE_VERSION}.el7.x86_64.rpm /data
sudo docker run -it --rm -v $PIPY_DIR/rpm:/data pipy-rpm:$RELEASE_VERSION cp /rpm/pipy-${RELEASE_VERSION}.el7.x86_64.rpm /data
git checkout -- $PIPY_DIR/rpm/pipy.spec
rm -f $PIPY_DIR/rpm/pipy.tar.gz
fi
Expand Down
Loading

0 comments on commit 9c5f137

Please sign in to comment.