Code Monkey home page Code Monkey 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

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.