etcd
Version, currently 0.2.17 versions
github.com/icyleaf/etcd-crystal
Etcd client for crystal
Nothing has been indexed for 0.2.1 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
etcd:
github: icyleaf/etcd-crystal
version: ~> 0.2.1Then run:
shards installshard.yml
No shard.yml has been indexed for 0.2.1. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
Etcd
A crystal client for etcd. Heavily inspired from the ruby etcd client.
ONLY support etcd API v2 version, it means you need run
etcd --enable-v2=truein etcd 3.0+ version.
Installation
Add this to your application's shard.yml:
dependencies:
etcd:
github: kuende/etcd-crystal
Usage
Create a client object
require "etcd"
client = Etcd.client # this will create a client against etcd server running on localhost on port 2379
client = Etcd.client("localhost:2379")
client = Etcd.client do |config|
config.user_name = "foo"
config.password = "bar"
end
client = Etcd.client("localhost:2379") do |config|
config.user_name = "foo"
config.password = "bar"
end
Set a key
client.set("/nodes/n1", {:value => "1"})
# with ttl
client.set("/nodes/n2", {:value => "2", :ttl => "4"}) # sets the ttl to 4 seconds
Get a key
client.get("/nodes/n2").value
Delete a key
client.delete("/nodes/n1")
client.delete("/nodes/", {:recursive => true})
Compare and swap
client.compare_and_swap("/nodes/n2", {:value => "2", :prevValue => "4"}) # will set /nodes/n2 's value to 2 only if its previous value was 4
Watch a key
client.watch("/nodes/n1") # will wait till the key is changed, and return once its changed
client.watch("/nodes/n1", Etcd::Options.new, 3) # watch a key with timeout
client.watch("/nodes/n1", {:recursive => true}) # watch a directory recursive
client.watch("/nodes/n1", {:recursive => true}, 3) # watch a directory recursive with timeout
List sub keys
client.get("/nodes")
TODO
- [ ] support SSL options
- [ ] failover support, currently only the first server provided is used
Contributing
- Fork it ( https://github.com/kuende/etcd-crystal/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.2.1- Tagged
- Mar 25, 2021
- Commit
66cf15ce01ab- Indexed
- not yet
Dependents
No indexed shard depends on this one yet.
Repository
github.com/icyleaf/etcd-crystal
Metadata
- Created
- Aug 16, 2026
- Updated
- Aug 16, 2026
- Synced
- Aug 16, 2026
- Versions
- 7