verm-client 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/verm/client.rb +2 -2
- data/lib/verm/version.rb +1 -1
- data/test/verm_test.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ce2084d3b2424bcc2e768dd946436af8e38925a
|
4
|
+
data.tar.gz: 8be9a875f01d58e946f7c3671cf3178c01f7a922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d462b82e2eaaf10e7c466d020a02b94e592c1a76f842bb3cc667b0364b640451f85257c25d9acff3f092abe44e1612d18ee675283f2cc9124d0899b3bad1ac8
|
7
|
+
data.tar.gz: 58294b9e7814e6fc2a5d2eb41acec6c53a43ac8fd5fb394295205c7fefea3d90041f6d25e58978fb7d08d81d3be4057b9ebb5e4f0f30884ae5d4b63db77b5921
|
data/README.md
CHANGED
@@ -113,3 +113,20 @@ VERM_CLIENT = Verm::Client.new("my-verm-server", timeout: 60)
|
|
113
113
|
```
|
114
114
|
|
115
115
|
Like Net::HTTP, this timeout applies to individual network operations, not the whole method.
|
116
|
+
|
117
|
+
|
118
|
+
Reusing connections
|
119
|
+
-------------------
|
120
|
+
|
121
|
+
By default, Ruby's Net::HTTP client will open a new connection for each request. This makes it very safe with regards to forking or threading, but it can become a bottleneck if you are doing a bulk upload or download from Verm. You can explicitly start a connection to work around this:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
VERM_CLIENT.http_client.start do
|
125
|
+
100.times do
|
126
|
+
VERM_CLIENT.store(...)
|
127
|
+
VERM_CLIENT.load(...)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
```
|
131
|
+
|
132
|
+
If you'd like to use another gem that manages connection reuse automatically, note that you can also substitute any HTTP client class that supports the Net::HTTP API, by providing the `http_class` option to `Verm::Client.new`.
|
data/lib/verm/client.rb
CHANGED
@@ -8,8 +8,8 @@ module Verm
|
|
8
8
|
|
9
9
|
attr_reader :http_client
|
10
10
|
|
11
|
-
def initialize(hostname, port: 3404, timeout: 15)
|
12
|
-
@http_client =
|
11
|
+
def initialize(hostname, port: 3404, timeout: 15, http_class: Net::HTTP)
|
12
|
+
@http_client = http_class.new(hostname, port)
|
13
13
|
@http_client.open_timeout = timeout
|
14
14
|
@http_client.read_timeout = timeout
|
15
15
|
@http_client.ssl_timeout = timeout
|
data/lib/verm/version.rb
CHANGED
data/test/verm_test.rb
CHANGED
@@ -120,4 +120,15 @@ class TestVerm < Minitest::Test
|
|
120
120
|
assert_equal uncompressed_content, result
|
121
121
|
assert chunks > 1, "should have been given the content in multiple chunks"
|
122
122
|
end
|
123
|
+
|
124
|
+
def test_reuses_socket_under_start
|
125
|
+
@client.http_client.start do
|
126
|
+
content, type = "this is a test", "text/plain"
|
127
|
+
assert_equal [content, type], @client.load(@client.store("/test/files_to_load", content, type))
|
128
|
+
@socket = @client.http_client.instance_variable_get("@socket")
|
129
|
+
|
130
|
+
assert_equal [content, type], @client.load(@client.store("/test/files_to_load", content, type))
|
131
|
+
assert_equal @socket, @client.http_client.instance_variable_get("@socket")
|
132
|
+
end
|
133
|
+
end
|
123
134
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: verm-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Bryant
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |
|
14
14
|
Adds one-line methods for storing files in Verm and retrieving them again.
|