NAME
Etcd::Keys - etcd key space API
VERSION
version 0.004
SYNOPSIS
use Etcd;
my $etcd = Etcd->new;
# set value for key
$etcd->set("/message", "hello world");
# get key
my $response = $etcd->get("/message");
# delete key
$etcd->delete("/message");
# atomic compare-and-swap value for key
$etcd->compare_and_swap("/message", "new", "old");
# atomic compare-and-delete key
$etcd->compare_and_delete("/message", "old");
# create key. like set, but fails if the key exists
$etcd->create("/message", "value");
# update key. like set, but fails if the key doesn't exist
$etcd->update("/message", "value");
# check if key exists
my $exists = $etcd->exists("/message");
# create dir, a "valueless" key to hold subkeys
$etcd->create_dir("/dir");
# delete key and everything under it
$etcd->delete_dir("/dir");
# atomically create in-order key
$etcd->create_in_order("/dir", "value");
# block until key changes
$etcd->watch("/message");
DESCRIPTION
This module provides access to etcd's key space API. The methods here map almost exactly to operations described in the etcd API documentation. See "SEE ALSO" in Etcd for further reading.
All methods except exists returns a Etcd::Response object on success and die on error. On error, $@ will contain either a reference to a Etcd::Error object (for API-level errors) or a regular string (for network, transport or other errors).
All methods can take any number of additional arguments in key => value form. These are added to the query parameters in the URL that gets submitted to etcd. This is how you would pass options for ttl or recursive, for example.
Any arguments of this kind that clash with the internal operation of a method will silently be ignored; for example, passing a value key to set will be ignored because that's how the value is passed internally.
METHODS
set$etcd->set("/message", "hello world");Set a value for a key. The key will be created if it doesn't exist.
This invokes the
PUTmethod for the given key.getmy $node = $etcd->get("/message");Get a key.
This invokes the
GETmethod for the given key.delete$etcd->delete("/message");Delete a key.
This invokes the
DELETEmethod for the given key.compare_and_swap$etcd->compare_and_swap("/message", "new", "old");Atomic compare-and-swap the value of a key.
This invokes the
PUTmethod for the given key with theprevValuequery parameter.compare_and_delete$etcd->compare_and_delete("/message", "old");Atomic compare-and-delete the value of a key.
This invokes the
DELETEmethod for the given key with theprevValuequery parameter.create$etcd->create("/message", "value");Create a key. Like set, but fails if the key exists.
This invokes the
PUTmethod for the given key with theprevExistquery parameter set tofalse.update$etcd->update("/message", "value");Update the value of a key. Like set, but fails if the key doesn't exist.
This invokes the
PUTmethod for the given key with theprevExistquery parameter set totrue.existsmy $exists = $etcd->exists("/message");Check if key exists. Unlike the other methods, it does not return a reference to a Etcd::Response object but insteads returns a true or false value. It may still throw an error.
This invokes the
GETmethod for the given key.create_dir$etcd->create_dir("/dir");Creates a directory, a "valueless" key to hold sub-keys.
This invokes the
PUTmethod for the given key with thedirquery parameter set totrue.delete_dir$etcd->delete_dir("/dir");Deletes a key and all its sub-keys.
This invokes the
DELETEmethod for the given key with thedirquery parameter set totrue.create_dir$etcd->create_in_order("/dir", "value");Atomically creates an in-order key.
This invokes the
POSTmethod for the given key.watch$etcd->watch("/message");Block until the given key changes, then return the change.
This invokes the
GETmethod for the given key with thewaitquery parameter set totrue.
KNOWN ISSUES
There is no convenient way to specify the
prevIndextest tocompare_and_swaporcompare_and_delete. These can be implemented directly withset.watchhas no asynchronous mode.
See "SUPPORT" in Etcd for information on how to report bugs or feature requests.
AUTHORS
Robert Norris <rob@eatenbyagrue.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by Robert Norris.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.