|
1 |
| -## Welcome to GitHub Pages |
| 1 | +## Rabbit ZooKeeper Extensions |
2 | 2 |
|
3 |
| -You can use the [editor on GitHub](https://github.com/RabbitTeam/zookeeper-client/edit/master/README.md) to maintain and preview the content for your website in Markdown files. |
| 3 | +该项目使用了 [Apache ZooKeeper .NET async Client](https://www.nuget.org/packages/ZooKeeperNetEx/) 组件,除提供了基本的zk操作还额外封装了常用的功能以更方便.net开发者更好的使用zookeeper。 |
| 4 | +## 提供的功能 |
4 | 5 |
|
5 |
| -Whenever you commit to this repository, GitHub Pages will run [Jekyll](https://jekyllrb.com/) to rebuild the pages in your site, from the content in your Markdown files. |
| 6 | +1. session过期重连 |
| 7 | +2. 永久watcher |
| 8 | +3. 递归删除节点 |
| 9 | +4. 递归创建节点 |
| 10 | +5. 跨平台(支持.net core) |
6 | 11 |
|
7 |
| -### Markdown |
| 12 | +## 使用说明 |
| 13 | +### 创建连接 |
8 | 14 |
|
9 |
| -Markdown is a lightweight and easy-to-use syntax for styling your writing. It includes conventions for |
| 15 | + var client = new ZookeeperClient(new ZookeeperClientOptions |
| 16 | + { |
| 17 | + ConnectionString = "172.18.20.132:2181", |
| 18 | + BasePath = "/", //default value |
| 19 | + ConnectionTimeout = TimeSpan.FromSeconds(10), //default value |
| 20 | + SessionTimeout = TimeSpan.FromSeconds(20), //default value |
| 21 | + OperatingTimeout = TimeSpan.FromSeconds(60), //default value |
| 22 | + ReadOnly = false, //default value |
| 23 | + SessionId = 0, //default value |
| 24 | + SessionPasswd = null //default value |
| 25 | + }); |
| 26 | +### 创建节点 |
| 27 | + await client.CreateEphemeralAsync("/year", Encoding.UTF8.GetBytes("2016")); |
| 28 | + await client.CreateEphemeralAsync("/year", Encoding.UTF8.GetBytes("2016"), ZooDefs.Ids.OPEN_ACL_UNSAFE); |
10 | 29 |
|
11 |
| -```markdown |
12 |
| -Syntax highlighted code block |
| 30 | + await client.CreatePersistentAsync("/year", Encoding.UTF8.GetBytes("2016")); |
| 31 | + await client.CreatePersistentAsync("/year", Encoding.UTF8.GetBytes("2016"), ZooDefs.Ids.OPEN_ACL_UNSAFE); |
13 | 32 |
|
14 |
| -# Header 1 |
15 |
| -## Header 2 |
16 |
| -### Header 3 |
| 33 | + await client.CreateAsync("/year", Encoding.UTF8.GetBytes("2016"), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT_SEQUENTIAL); |
| 34 | + |
| 35 | + //递归创建 |
| 36 | + await client.CreateRecursiveAsync("/microsoft/netcore/aspnet", Encoding.UTF8.GetBytes("1.0.0"), CreateMode.PERSISTENT); |
| 37 | +### 获取节点数据 |
| 38 | + var data = await client.GetDataAsync("/year"); |
| 39 | + Encoding.UTF8.GetString(data.ToArray()); |
| 40 | +### 获取子节点 |
| 41 | + IEnumerable<string> children= await client.GetChildrenAsync("/microsoft"); |
| 42 | +### 判断节点是否存在 |
| 43 | + bool exists = await client.ExistsAsync("/year"); |
| 44 | +### 删除节点 |
| 45 | + await client.DeleteAsync("/year"); |
17 | 46 |
|
18 |
| -- Bulleted |
19 |
| -- List |
20 |
| - |
21 |
| -1. Numbered |
22 |
| -2. List |
23 |
| - |
24 |
| -**Bold** and _Italic_ and `Code` text |
25 |
| - |
26 |
| -[Link](url) and  |
27 |
| -``` |
28 |
| - |
29 |
| -For more details see [GitHub Flavored Markdown](https://guides.github.com/features/mastering-markdown/). |
30 |
| - |
31 |
| -### Jekyll Themes |
32 |
| - |
33 |
| -Your Pages site will use the layout and styles from the Jekyll theme you have selected in your [repository settings](https://github.com/RabbitTeam/zookeeper-client/settings). The name of this theme is saved in the Jekyll `_config.yml` configuration file. |
34 |
| - |
35 |
| -### Support or Contact |
36 |
| - |
37 |
| -Having trouble with Pages? Check out our [documentation](https://help.github.com/categories/github-pages-basics/) or [contact support](https://github.com/contact) and we’ll help you sort it out. |
| 47 | + //递归删除 |
| 48 | + bool success = await client.DeleteRecursiveAsync("/microsoft"); |
| 49 | +### 更新数据 |
| 50 | + Stat stat = await client.SetDataAsync("/year", Encoding.UTF8.GetBytes("2017")); |
| 51 | +### 订阅数据变化 |
| 52 | + await client.SubscribeDataChange("/year", (ct, args) => |
| 53 | + { |
| 54 | + IEnumerable<byte> currentData = args.CurrentData; |
| 55 | + string path = args.Path; |
| 56 | + Watcher.Event.EventType eventType = args.Type; |
| 57 | + return Task.CompletedTask; |
| 58 | + }); |
| 59 | +### 订阅子节点变化 |
| 60 | + await client.SubscribeChildrenChange("/microsoft", (ct, args) => |
| 61 | + { |
| 62 | + IEnumerable<string> currentChildrens = args.CurrentChildrens; |
| 63 | + string path = args.Path; |
| 64 | + Watcher.Event.EventType eventType = args.Type; |
| 65 | + return Task.CompletedTask; |
| 66 | + }); |
0 commit comments