From 4f16b2e5c830914d9a12fd9770f09202c60a8588 Mon Sep 17 00:00:00 2001 From: stulzq Date: Mon, 24 Sep 2018 22:59:56 +0800 Subject: [PATCH] update readme --- README.md | 60 ++++++++++++++++++- build/package.props | 13 ++-- sample/CanalSharp.SimpleClient/Program.cs | 7 ++- .../CanalSharp.Client.csproj | 5 +- .../CanalSharp.Common.csproj | 4 +- .../CanalSharp.Protocol.csproj | 4 +- 6 files changed, 77 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 4c13d3c..bdcca2b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,58 @@ -# canal-client-csharp -[![Build Status](https://travis-ci.org/CanalSharp/CanalSharp.svg?branch=dev)](https://travis-ci.org/CanalSharp/CanalSharp) -The .NET canal client for Alibaba canal https://github.com/alibaba/canal +# CanalSharp + +## 一.CanalSharp是什么? + +CanalSharp 是阿里巴巴开源项目 Canal 的 .NET 客户端。为 .NET 开发者提供一个更友好的使用 Canal 的方式。Canal 是mysql数据库binlog的增量订阅&消费组件。 + +基于日志增量订阅&消费支持的业务: + +1. 数据库镜像 +2. 数据库实时备份 +3. 多级索引 (卖家和买家各自分库索引) +4. search build +5. 业务cache刷新 +6. 价格变化等重要业务消息 + +关于 Canal 的更多信息请访问 https://github.com/alibaba/canal + +## 二.如何使用 + +1.安装Canal + +Canal的安装以及配置使用请查看 https://github.com/alibaba/canal + +2.建立一个.NET Core App项目 + +3.为该项目从 Nuget 安装 CanalSharp + +````shell +Install-Package CanalSharp.Client +```` + +4.建立与Canal的连接 + +````csharp +//canal 配置的 destination,默认为 example +var destination = "example"; +//创建一个简单CanalClient连接对象(此对象不支持集群)传入参数分别为 canal地址、端口、destination、用户名、密码 +var connector = CanalConnectors.NewSingleConnector("127.0.0.1", 11111, destination, "", ""); +//连接 Canal +connector.Connect(); +//订阅,同时传入Filter,如果不传则以Canal的Filter为准。Filter是一种过滤规则,通过该规则的表数据变更才会传递过来 +connector.Subscribe(""); +//获取消息并且需要发送Ack表示消费成功 +connector.Get(batchSize); +//获取消息但是不需要发送Ack来表示消费成功 +connector.GetWithoutAck(batchSize); +```` + +更多详情请查看 Sample + +## 三.贡献代码 + +1.fork本项目 + +2.做出你的更改 + +3.提交 pull request \ No newline at end of file diff --git a/build/package.props b/build/package.props index c8ad077..0783706 100644 --- a/build/package.props +++ b/build/package.props @@ -1,13 +1,14 @@ - C# client for canal. https://github.com/alibaba/canal - https://github.com/Canal4Net/Canal4Net/blob/master/LICENSE - https://github.com/Canal4Net/Canal4Net - https://github.com/Canal4Net/Canal4Net.git + + 阿里巴巴mysql数据库binlog的增量订阅/消费组件 Canal 的 .NET 客户端 + https://github.com/CanalSharp/CanalSharp/blob/dev/LICENSE + https://github.com/CanalSharp/CanalSharp + https://github.com/CanalSharp/CanalSharp.git git canal;mysql;binlog - Canal4Net Org. - stulzq,WithLin + CanalSharp Org. + stulzq,WithLin,CanalSharp diff --git a/sample/CanalSharp.SimpleClient/Program.cs b/sample/CanalSharp.SimpleClient/Program.cs index 85e7eb4..818e96d 100644 --- a/sample/CanalSharp.SimpleClient/Program.cs +++ b/sample/CanalSharp.SimpleClient/Program.cs @@ -11,12 +11,17 @@ class Program { static void Main(string[] args) { + //canal 配置的 destination,默认为 example var destination = "example"; + //创建一个简单CanalClient连接对象(此对象不支持集群)传入参数分别为 canal地址、端口、destination、用户名、密码 var connector = CanalConnectors.NewSingleConnector("127.0.0.1", 11111, destination, "", ""); + //连接 Canal connector.Connect(); - connector.Subscribe(); + //订阅,同时传入Filter,如果不传则以Canal的Filter为准。Filter是一种过滤规则,通过该规则的表数据变更才会传递过来 + connector.Subscribe(""); while (true) { + //获取消息数据 var message = connector.Get(5000); var batchId = message.Id; if (batchId == -1 || message.Entries.Count <= 0) diff --git a/src/CanalSharp.Client/CanalSharp.Client.csproj b/src/CanalSharp.Client/CanalSharp.Client.csproj index 87cb9be..c394b76 100644 --- a/src/CanalSharp.Client/CanalSharp.Client.csproj +++ b/src/CanalSharp.Client/CanalSharp.Client.csproj @@ -1,9 +1,10 @@ - - + + netstandard2.0 + diff --git a/src/CanalSharp.Common/CanalSharp.Common.csproj b/src/CanalSharp.Common/CanalSharp.Common.csproj index 9f5c4f4..a592c21 100644 --- a/src/CanalSharp.Common/CanalSharp.Common.csproj +++ b/src/CanalSharp.Common/CanalSharp.Common.csproj @@ -1,5 +1,5 @@ - - + + netstandard2.0 diff --git a/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj b/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj index 34f7c5c..b9722e7 100644 --- a/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj +++ b/src/CanalSharp.Protocol/CanalSharp.Protocol.csproj @@ -1,5 +1,5 @@ - - + + netstandard2.0