Giter Club home page Giter Club logo

nzookeeper's Introduction

NZookeeper

Latest version

English|中文

A zookeeper client library based on ZookeeperEx,easily use for Zookeeper.

Transaction operation is not supported at present, and will be supported in the next version

Get start

1.Connect to Zookeeper

using var loggerFactory = LoggerFactory.Create(builder =>
            {
                builder
                    .AddFilter("Microsoft", LogLevel.Debug)
                    .AddFilter("System", LogLevel.Information)
                    .AddConsole();
            });
var logger = loggerFactory.CreateLogger<ZkConnection>();
//Multiple zookeeper addresses are separated by ,
var zk = new ZkConnection(new ZkConnectionOptions() { ConnectionString = "localhost:2181", SessionTimeout = 5000 }, logger);
await zk.ConnectAsync();

2.Set watch event

It is used to monitor node changes and data changes. Node changes include: node creation and node deletion

zk.OnWatch += Zk_OnWatch;

private Task Zk_OnWatch(ZkWatchEventArgs args)
{
    Console.WriteLine($"OnWatch: Path {args.Path}, Type {args.EventType}, State {args.State}");
    return Task.CompletedTask;
}

3.Node operation

//Create node
await zk.CreateNodeAsync("/mynode", "nodedata",
                    new List<Acl>() { new Acl(AclPerm.All, AclScheme.World, AclId.World()) }, NodeType.Ephemeral);
//Get child node
await zk.GetChildrenAsync("/mynode");
//Delete node
await zk.DeleteNodeAsync("/mynode");
//Check if the node exists
await zk.NodeExistsAsync("/mynode")

4.Data

//Update node data
await zk.SetDataAsync("/mynode", "111");
//Get node data
await zk.GetDataAsync("/mynode")

5.ACL

//Get ACL
await zk.GetAclAsync("/mynode");
//Set ACL
await zk.SetAclAsync("/mynode",new List<Acl>() { new Acl(AclPerm.All, AclScheme.World, AclId.World()) })

nzookeeper's People

Contributors

stulzq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

orichisonic

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.