etcd
Version, currently 0.4.07 versions
github.com/icyleaf/etcd-crystal
Etcd client for crystal
1 stars
0 dependents
License: Apache 2
Installation
# Add this to your shard.yml
dependencies:
etcd:
github: icyleaf/etcd-crystal
version: ~> 0.4.0Then run:
shards installshard.yml
- Crystal
>= 0.36.1, < 2.0.0- License
- Apache 2
- Authors
- Teodor, icyleaf
Dependencies
This version declares no dependencies.
README
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.4.0- Tagged
- Mar 25, 2021
- Commit
1dbe7575578c- Crystal
>= 0.36.1, < 2.0.0- Indexed
- yes
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