syucream / ts_mruby Goto Github PK
View Code? Open in Web Editor NEWEnchant Apache Traffic Server with mruby power.
License: Apache License 2.0
Enchant Apache Traffic Server with mruby power.
License: Apache License 2.0
and Filter#output=
as alias
TODO
URL string getter
To suit spec of mod_mruby and ngx_mruby ...
Only using cppapi, it can't be implemented but TS API has TSHttpHdrVersionSet()
Support below loading style ... ?:
map /test http://127.0.0.1/ @plugin=ts_mruby.so @pparam= \
echo "hoge"
reported by gcc:
src/ts_mruby_core.cpp:150:7: warning: variable ‘rc’ set but not used [-Wunused-but-set-variable]
int rc;
^
Current ATS::EventSystem
requires implements all of handlers(on_send_request_hdr
, on_read_response_hdr
and on_send_response_hdr
) but it goes to waste if a user doesn't need these handlers.
I'd like to fix to require minimum handlers.
My environment is Ubuntu 14.04 64bit.
FIrst, build trafficserver.
git clone https://github.com/apache/trafficserver.git
cd trafficserver
autoreconf -if
./configure --enable-cppapi --prefix=/usr/local/trafficserver-git-master
make
sudo make install
but, not found /usr/local/trafficserver-git-master/bin/tsxs
. Then,
./configure --prefix=/usr/local/trafficserver-git-master
make
sudo make install
installed bin/tsxs
and related binary.
Then, build ts_mruby after downloading mruby.
cd ts_mruby
autoreconf -if
./configure --with-ts-prefix-root=/usr/local/trafficserver-git-master/ --with-mruby-root=../mruby/
make build_mruby
make
But, a below error occurred.
$ make
/usr/local/trafficserver-git-master/bin/tsxs -I/usr/local/trafficserver-git-master/include -I../mruby/include -L/usr/local/trafficserver-git-master/lib/ts -L/usr/local/trafficserver-git-master/lib -L/home/matsumotory/DEV/mruby/build/host/lib -latscppapi -lmruby -lm -lreadline src/ts_mruby_*.cpp src/ts_mruby.cpp
compiling src/ts_mruby_core.cpp -> src/ts_mruby_core.lo
In file included from /usr/local/trafficserver-git-master/include/atscppapi/Transaction.h:30:0,
from src/ts_mruby_core.cpp:13:
/usr/local/trafficserver-git-master/include/atscppapi/shared_ptr.h:28:26: fatal error: ink_autoconf.h: No such file or directory
#include "ink_autoconf.h"
^
compilation terminated.
tsxs: compilation failed: c++ -I/usr/local/trafficserver-git-master/include -I/usr/local/trafficserver-git-master/include -I../mruby/include -std=c++11 -g -pipe -Wall -O3 -feliminate-unused-debug-symbols -fno-strict-aliasing -Wno-invalid-offsetof -mcx16 -fpic -c src/ts_mruby_core.cpp -o src/ts_mruby_core.lo
make: *** [ts_mruby.la] Error 1
Its a big issue so I should to fix it as a new milestone?
reference(issues an ideas to avoid blocking I/O in mruby scripts on h2o):
http://blog.kazuhooku.com/2015/11/mruby.html
Server = ATS
r = Server::Request.new
Server::echo r.scheme # => 'http'
Hi, @syucream
I try to install ts_mruby, but configure script failed.
$ autoreconf -if
$ ./configure --with-ts-prefix-root=/usr/local/trafficserver-git --with-mruby-root=../mruby
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
configure: creating ./config.status
config.status: error: cannot find input file: `Makefile.in'
Did I misunderstood the install process?
Current implementation compiles mruby scripts when ts_mruby
plugin is initialized.
However, To improve operations of ATS, it should enable to recompile when configuration reloaded. (For example, when traffic_line -x
is executed.)
$ traffic_ctl config reload
Current impl can support only PRE_REMAP hook or doRemap(), so ts_mruby can't support some methods(ATS::Headers_out#[]
, etc). In this issue I rethink about hooks to support those.
current actual behavior:
hin = ATS::Headers_in.new
ATS.rputs hin["User-Agent"] #=> User-Agent: curl/7.43.0
To support modifying response, We need to insert a new hook ....
Similar to ngx_mruby's one.
- [ ] performance report (if its possible)
Traffic management example script. It may work by dinamically changing high/low watermark.
https://trafficserver.readthedocs.io/en/latest/admin-guide/configuration/cache-basics.en.html#using-transaction-buffering-control
trafficserver-7.0.0
doesn't require alternate cppapi pkg so the ts_mruby Formula can be simplified.
It may work flexible hook handler and ATS cache generation.
googletest?
From #32
records = ATS::Records.new
# getter
records.proxy.config.url_remap.pristine_host_hdr #=> 0
records.url_remap.pristine_host_hdr #=> 0
# setter as #= method
records.proxy.config.url_remap.pristine_host_hdr = 1
records.url_remap.pristine_host_hdr = 1
records = ATS::Records.new
records.set do |proxy|
# records.config like accessor!
proxy.config.url_remap.pristine_host_hdr = 1
end
Support Records class, like Apache::Env and Nginx::Var.
I think it can implement by Transformation Plugin of atscppapi (but I haven't tried it yet)
We need to survey whether we can support it by current atscppapi.
The cppapi doesn't have a setter for HTTP method. However it exists in TS API.
http://syucream.hatenablog.jp/
In Japanese ... and English? (if possible :))
Like ngx_mruby
Similar to Apache::Request#hostname.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.