Coder Social home page Coder Social logo

etcd-api's Introduction

This is a C interface to etcd, plus a command-line tool that exercises the API. In brief, the supported calls are:

  • etcd_open (server-list [as an array])

  • etcd_open_str (server-list [as a string])

  • etcd_close and etcd_close_str

  • etcd_get (key) including support for listing keys by prefix

  • etcd_set (key, value, [optional] prev-value, [optional] ttl)

  • etcd_delete (key)

  • etcd_leader

  • etcd_watch (prefix, [optional] index)

  • etcd_lock (key, ttl, [optional] index)

  • etcd_unlock (key, index)

See etcd-api.h for precise types and so on. The library will automatically try requests on a succession of servers in server-list.

The command-line utility etcd-test (showing its origins and primary usage so far) can do get/set/delete/leader for you. Servers can be specified either on the command line (-s) or through the ETCD_SERVERS environment variable.

DEPRECATED The leader program is an example of how to use the etcd primitives for a simple leader-election protocol, for code that needs a leader separate from the etcd leader. It uses the same conventions as etcd-test for specifying the servers. Just for fun, leader.m includes a Murphi model for the protocol.

The above code is deprecated due to the existence of etcd's own lock module. These locks are really leases which expire after a specified timeout, but for now consistency with etcd's terminology is more important than consistency with the name any computer-science graduate would have used. There's also a leader module, but it lacks the critical timeout functionality.

  • Issue etcd_lock without an index to try for leadership. This provides notification when the local node gains leadership (if ever).

  • Once leadership has been obtained, periodically renew it by issuing etcd_lock with an index. This provides notification when the local node loses leadership (e.g. because it took too long to renew).

  • If you care about leadership changes between other nodes, you'll have to monitor for those separately. Unfortunately, neither the lock module nor the leader module seems to support "watch" functionality. There's not much you can do other than use etcd_watch on a separate key (probably in a separate thread) to get some idea when such changes occur.

This project depends on libcurl and YAJL 2.x (for the tree interface).

etcd-api's People

Contributors

jdarcy avatar jdoliner avatar seken avatar vtolstov avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

etcd-api's Issues

etcd_open / etcd_open_str

Why this function does not check url and not try to connect to server?
How i know does connection to server is successful?

etcd servers list and dns

I have etcd cluster with three static nodes (that running via inital-cluster) and 100 dynamic (via discovery-srv), what servers i need to specify in etcd_open?
Also i have etcd on host which runs program that use this etcd-api , so may be i need specify only local etcd address in this case?

using in external software

In my software i need to quarantine that only one instance write in the same time. So i want to use etcd and this library.
So my question is - how can i determine leader? As i understand i need to create key with locking? In key i can set content with current leader name for example?
Or i'm wrong ?

YAJI

/* TBD: see if common distros are packaging a JSON library that isn't total

  • crap.
    */

Jansson

http://www.digip.org/jansson/

Not mine but used it a lot and it's not crap (and it's available in EPEL jansson-devel)

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.