sqler 2.2 发布了,支持定时任务以及触发器
sqler 在10前发布了,2.2 添加了定时任务以及触发器(webhook),都是比较方便的功能,
同时我也修改了dockerfile, 做了构建,添加了功能支持,同时push 到了dockerhub 仓库
使用
- docker-compose 文件
集成了一个测试webhook benthos
version: "3"
services:
sqler:
image: dalongrong/sqler:2.2
volumes:
- "./config/config-2-2-example.hcl:/app/config.example.hcl"
environment:
- "DSN=root:dalongrong@tcp(mysqldb:3306)/test?multiStatements=true"
ports:
- "3678:3678"
- "8025:8025"
benthos:
image: jeffail/benthos
volumes:
- "./configs/webhook.yaml:/benthos.yaml"
ports:
- "4195:4195"
mysqldb:
image: mysql:5.7.16
ports:
- 3306:3306
command: --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
environment:
MYSQL_ROOT_PASSWORD: dalongrong
MYSQL_DATABASE: test
MYSQL_USER: test
MYSQL_PASSWORD: test
TZ: Asia/Shanghai
- benthos webhook 配置
input:
type: broker
broker:
inputs:
- type: http_server
http_server:
path: /post/customer1
processors:
- type: text
text:
operator: prepend
value: "Customer 1 received: "
- type: http_server
http_server:
path: /post/customer2
processors:
- type: text
text:
operator: prepend
value: "Customer 2 received: "
- type: http_server
http_server:
path: /post/customer3
processors:
- type: text
text:
operator: prepend
value: "Customer 3 received: "
output:
type: stdout
- 参考配置文件
// create a macro/endpoint called "_boot",
// this macro is private "used within other macros"
// because it starts with "_".
_boot {
// the query we want to execute
exec = <<SQL
CREATE TABLE IF NOT EXISTS datax (
ID INT PRIMARY KEY,
data TEXT DEFAULT NULL
);
SQL
}
addpost {
include = ["_boot"]
methods = ["POST"]
// validators {
// title_is_empty = "$input.title && $input.title.trim().length > 0"
// content_is_empty = "$input.content"
// }
bind {
data = <<JS
JSON.stringify({
"title": $input.title,
"content": $input.content
})
JS
}
exec = <<SQL
INSERT INTO datax(ID, data) VALUES(default, :data) RETURNING id, data;
SQL
}
// adduser macro/endpoint, just hit `/adduser` with
// a `?user_name=&user_email=` or json `POST` request
// with the same fields.
adduser {
validators {
user_name_is_empty = "$input.user_name && $input.user_name.trim().length > 0"
user_email_is_empty = "$input.user_email && $input.user_email.trim().length > 0"
user_password_is_not_ok = "$input.user_password && $input.user_password.trim().length > 5"
}
bind {
name = "$input.user_name"
email = "$input.user_email"
password = "$input.user_password"
}
methods = ["POST"]
authorizer = <<JS
(function(){
log("use this for debugging")
token = $input.http_authorization
response = fetch("http://requestbin.fullcontact.com/zxpjigzx", {
headers: {
"Authorization": token
}
})
if ( response.statusCode != 200 ) {
return false
}
return true
})()
JS
// include some macros we declared before
include = ["_boot"]
exec = <<SQL
INSERT INTO users(name, email, password, time) VALUES(:name, :email, :password, UNIX_TIMESTAMP());
SELECT * FROM users WHERE id = LAST_INSERT_ID();
SQL
}
// list all databases, and run a transformer function
databases {
// include = ["_boot"]
exec = "SHOW DATABASES"
transformer = <<JS
(function(){
// $result
$new = [];
for ( i in $result ) {
$new.push($result[i].Database)
}
return $new
})()
JS
}
// list all tables from all databases
tables {
exec = "SELECT `table_name` as `table`, `table_schema` as `database` FROM INFORMATION_SCHEMA.tables"
transformer = <<SQL
(function(){
$ret = []
for ( i in $result ){
$ret.push({
table: $result[i].table,
database: $result[i].database,
})
}
return $ret
})()
SQL
}
data {
bind {
limit = 2
field = "'id'"
}
exec = "SELECT id FROM data limit 5"
}
// a macro that aggregates `databases` macro and `tables` macro into one macro
databases_tables {
aggregate = ["databases", "tables"]
}
_sqlite_tables {
exec = <<SQL
SELECT
name
FROM
userinfos;
SQL
cron = "* * * * *"
trigger {
webhook = "http://benthos:4195/post/customer1"
}
}
启动&&测试
- 启动
docker-compose up -d
- 准备测试数据表
参考如下脚本添加(主要测试定时任务以及webhook)
CREATE TABLE `userinfos` (
`id` bigint(20) DEFAULT NULL,
`name` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
INSERT INTO test.userinfos
(id, name)
VALUES(1, 'dalong');
- 效果
查看benthos 容器日志
docker-compose logs -f benthos
效果
sqler 日志
参考资料
https://github.com/alash3al/sqler
https://github.com/rongfengliang/sqler-docker-compose
https://github.com/Jeffail/benthos
sqler 2.2 发布了,支持定时任务以及触发器的更多相关文章
- Ranorex 5 发布,支持SAP、Oracle Forms、MS Dynamics等
Ranorex 5 发布,支持SAP.Oracle Forms.MS Dynamics等 http://blog.csdn.net/testing_is_believing/article/detai ...
- CentOS 7 ARM 版发布:支持树莓派2/香蕉派/CubieTruck
CentOS 7 ARM 版发布:支持树莓派2/香蕉派/CubieTruck 来自CentOS团队的Karanbir Singh很高兴地宣布,面向ARM硬件架构的CentOS 7 Linux已经正式发 ...
- [转]Ubuntu Tweak 0.8.7 发布:支持 Ubuntu 14.04
原文网址:http://www.oschina.net/news/51054/ubuntu-tweak-0-8-7 这是我开发 Ubuntu Tweak 七年以来第一次没在 Ubuntu 正式发布之前 ...
- Selenium WebDriver 2.34.0 发布,支持Firefox22
Selenium WebDriver 2.34.0 发布,支持Firefox22http://automationqa.com/forum.php?mod=viewthread&tid=270 ...
- ArcGIS图框工具5.2发布,支持ArcGIS10.0,10.110.2,支持国家2000坐标系
ArcGIS图框工具5.2发布,支持ArcGIS10.0,10.110.2,支持国家2000坐标系 下载地址http://files.cnblogs.com/gisoracle/atktoolnew. ...
- swoole-1.7.18 版本已发布,支持 PHP7
swoole-1.7.18 版本已发布,支持 PHP7 matyhtf 发布于: 2015年07月23日 (22评) 分享到: 收藏 +16 3月19日,深圳源创会火热报名中,go>> ...
- PostSharp-5.0.26安装包_KeyGen发布_支持VS2017
PostSharp-5.0.26安装包_KeyGen发布_支持VS2017 请低调使用. PostSharp安装及注册步骤截图.rar 请把浏览器主页设置为以下地址支持本人.https://www.d ...
- Akka.NET v1.0 已发布,支持Mono
Akka.NET 是Java/Scala 流行框架Akka的一个 .NET 开源移植.可用于构建高并发,分布式和容错事件驱动的应用在 .NET 和 Mono 平台之上.Akka.NET 经过一年多的努 ...
- EQueue 2.3.2版本发布(支持高可用)
前言 前段时间针对EQueue的完善终于告一段落了,实在值得庆祝,自己的付出和坚持总算有了成果.这次新版本主要为EQueue实现了集群功能,基本实现了Broker的高可用.另外还增加了很多实用的功能, ...
随机推荐
- JAVA基础系列:Arrays.sort()
JDK 1.8 java.util.Arrays.class(rt.jar) 1. Collections.sort方法底层就是调用的Arrays.sort方法. 2. Java Arrays中提供 ...
- FFT/NTT基础题总结
在学各种数各种反演之前把以前做的$FFT$/$NTT$的题整理一遍 还请数论$dalao$口下留情 T1快速傅立叶之二 题目中要求求出 $c_k=\sum\limits_{i=k}^{n-1}a_i* ...
- 数据仓库002 - 复习Linux shell命令 - echo bash_profile bashrc which命令的理解 alias history
1.echo 打印 . echo 的作用是在屏幕上打印输出内容,与文件和持久化可以理解为没有丝毫关联.如:在屏幕上打印“ echo 的作用是打印文字! ” 实例1:输出系统的环境变量名称 $PATH ...
- border和outline的区别
如果有一个需求,给一个元素增加一条边框,想必大家会习惯且娴熟的使用border来实现,我也是这样 但其实outline也能达到同样的效果,并且在有些场景下会更适用,比如下面的demo 使用bord ...
- 怎样用 C# 快速比较 2 个文件是否是相同的文件?
方案1: 直接贴代码了: using System; using System.Collections.Generic; using System.IO; using System.Linq; usi ...
- [Docker] Win10中安装Docker并运行Nginx镜像
一.安装Docker 进入官网:https://www.docker.com/products/docker-desktop 可能需要先注册登录,很简单的. 点击 Download Desktop f ...
- Centos安装jdk1.8出现-bash: //usr/local/soft/jdk1.8.0_191/bin/javac: /lib/ld-linux.so.2: bad ELF interpreter: 没有那个文件或目录错误。
1.从来没有这么郁闷,之前安装都是好好的,自从将Centos升级到7.0版本,安装了jdk报了这个错误,也是郁闷的一毛,参考了一下百度的,记录一下.使用java命令还有java -version命令都 ...
- .net core 发布到iis问题 HTTP Error 500.30 - ANCM In-Process Start Failure
1. 没有在Program里配置IIS webBuilder.UseIIS(); 2. StartupProduction 里AutoFac容器注入错误和新版的CORS中间件已经阻止使用允许任意Ori ...
- xshell使用zmodem拖拽上传
一.目的 windows向centos_linux服务器上传文件可以用ftp上传,但是没zmodem方便,zmodem拖拽上传,可以上传到指定的目录下. 二.安装使用 执行下面的命令安装后就可以使用了 ...
- 高强度学习训练第一天总结:Java内存区域
---恢复内容开始--- 程序计数器: 程序计数器(Program Counter Register) 是一块较小的空间,他可以看作是当前线程所执行的字节码的行号指示器.在虚拟机的概念模型里(仅是概念 ...