Skip to content

Commit

Permalink
Added etcd and etcdv3
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Aug 8, 2020
1 parent 1172fd3 commit 5eb8d52
Show file tree
Hide file tree
Showing 8 changed files with 148 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,14 @@ appraise "droplet_kit" do
gem "faraday"
end

appraise "etcd" do
gem "etcd"
end

appraise "etcdv3" do
gem "etcdv3"
end

appraise "elasticsearch" do
gem "elasticsearch"
end
Expand Down
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ Other
- [active_shipping](#active_shipping)
- [carrot2](#carrot2)
- [docker-api](#docker-api)
- [etcd](#etcd)
- [etcdv3](#etcdv3)
- [fastimage](#fastimage)
- [geocoder](#geocoder)
- [graphql-client](#graphql-client)
Expand Down Expand Up @@ -1503,6 +1505,34 @@ Connect timeout not configurable

Raises `Docker::Error::TimeoutError`

### etcd

```ruby
client = Etcd.client(read_timeout: 1)
```

Connect timeout not configurable

Default: 60s read timeout

Raises

- `Net::ReadTimeout` on read timeout

### etcdv3

```ruby
Etcdv3.new(command_timeout: 1)
```

or

```ruby
conn.get(key, timeout: 1)
```

Raises `GRPC::DeadlineExceeded`

### fastimage

```ruby
Expand Down
7 changes: 7 additions & 0 deletions gemfiles/etcd.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "minitest"
gem "etcd"
24 changes: 24 additions & 0 deletions gemfiles/etcd.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
GEM
remote: https://rubygems.org/
specs:
appraisal (2.3.0)
bundler
rake
thor (>= 0.14.0)
etcd (0.3.0)
mixlib-log
minitest (5.14.1)
mixlib-log (3.0.8)
rake (13.0.1)
thor (1.0.1)

PLATFORMS
ruby

DEPENDENCIES
appraisal
etcd
minitest

BUNDLED WITH
2.1.4
7 changes: 7 additions & 0 deletions gemfiles/etcdv3.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "appraisal"
gem "minitest"
gem "etcdv3"
29 changes: 29 additions & 0 deletions gemfiles/etcdv3.gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
GEM
remote: https://rubygems.org/
specs:
appraisal (2.3.0)
bundler
rake
thor (>= 0.14.0)
etcdv3 (0.10.2)
grpc (~> 1.17)
google-protobuf (3.12.4)
googleapis-common-protos-types (1.0.5)
google-protobuf (~> 3.11)
grpc (1.30.2)
google-protobuf (~> 3.12)
googleapis-common-protos-types (~> 1.0)
minitest (5.14.1)
rake (13.0.1)
thor (1.0.1)

PLATFORMS
ruby

DEPENDENCIES
appraisal
etcdv3
minitest

BUNDLED WITH
2.1.4
19 changes: 19 additions & 0 deletions test/etcd_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
require_relative "test_helper"

class EtcdTest < Minitest::Test
def test_connect
skip "No open timeout"

client = Etcd.client(host: connect_host, read_timeout: 1)
assert_timeout(Net::OpenTimeout) do
client.get("/nodes/n1")
end
end

def test_read
client = Etcd.client(host: read_host, port: read_port, read_timeout: 1)
assert_timeout(Net::ReadTimeout) do
client.get("/nodes/n1")
end
end
end
24 changes: 24 additions & 0 deletions test/etcdv3_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require_relative "test_helper"

class EtcdTest < Minitest::Test
def test_connect
conn = Etcdv3.new(endpoints: "http://#{connect_host}:2379", command_timeout: 1)
assert_timeout(GRPC::DeadlineExceeded) do
conn.get("test")
end
end

def test_read
conn = Etcdv3.new(endpoints: read_url, command_timeout: 1)
assert_timeout(GRPC::DeadlineExceeded) do
conn.get("test")
end
end

def test_request
conn = Etcdv3.new(endpoints: "http://#{connect_host}:2379")
assert_timeout(GRPC::DeadlineExceeded) do
conn.get("test", timeout: 1)
end
end
end

0 comments on commit 5eb8d52

Please sign in to comment.