Coder Social home page Coder Social logo

Comments (7)

viing937 avatar viing937 commented on July 24, 2024

I found how to set a key with ttl.

EtcdClient client = new EtcdClient("127.0.0.1", 2379);

long leaseId = client.LeaseGrant(new LeaseGrantRequest
{
    TTL = ttl
}).ID;

client.Put(new PutRequest
{
    Key = ByteString.CopyFromUtf8(key),
    Value = ByteString.CopyFromUtf8(val),
    Lease = leaseId
});

And this can keep lease alive, but I am not sure what are LeaseKeepAliveHandler and CancellationToken used for.

client.LeaseKeepAlive(new LeaseKeepAliveRequest
{
    ID = leaseId
}, LeaseKeepAliveHandler, new CancellationToken());

private static void LeaseKeepAliveHandler(LeaseKeepAliveResponse rep)
{
    Console.WriteLine($"Lease {rep.ID} keep alive");
}

from dotnet-etcd.

shubhamranjan avatar shubhamranjan commented on July 24, 2024

LeaseKeepAliveHandler : The method which contains instructions to be executed on each LeaseKeepAlive response.

CancellationToken: Propagates notification that operations should be canceled.

https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken?view=netframework-4.8

from dotnet-etcd.

shubhamranjan avatar shubhamranjan commented on July 24, 2024

I am working on restructuring the lib's code a bit without hurting method signatures. I will try to update documentation as soon as I can.

from dotnet-etcd.

viing937 avatar viing937 commented on July 24, 2024

Actually I do not need to execute anything on LeaseKeepAlive response, an overload of LeaseKeepAlive without LeaseKeepAliveHandler should be better.
Also, CancellationToken should be optional as the same reason.

from dotnet-etcd.

shubhamranjan avatar shubhamranjan commented on July 24, 2024

Noted. For now, you can use the overload which takes an array of Handlers and you can pass an empty array.

from dotnet-etcd.

spiderpoison avatar spiderpoison commented on July 24, 2024

I need Doc about Lease too, thanks very much

from dotnet-etcd.

anythink-wx avatar anythink-wx commented on July 24, 2024

LeaseGrant and LeaseKeepAlive doc ?

from dotnet-etcd.

Related Issues (20)

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.