verm-client 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b0944a2110fde443b969980a417fe24fc9e3c142
4
- data.tar.gz: c880b7919042d31f450957f1f57f058d8499be9a
3
+ metadata.gz: 0ce2084d3b2424bcc2e768dd946436af8e38925a
4
+ data.tar.gz: 8be9a875f01d58e946f7c3671cf3178c01f7a922
5
5
  SHA512:
6
- metadata.gz: 93b9676a8d0736cda53c432b44404bfd1b0f37c5bda67c4d7f38d8d2c2d9e454b225b8a874854c2ddaa4879cf2e33f8bacfdea55b5eabebaa4e1661274975bb1
7
- data.tar.gz: d1a8c4feff6b62811eed414f511dd2bbea3d1d71e008775535a1a8326ab9efdab9218b159e545f81da7c304b1a2a62e70dc798d612ee3745842e3781b5c4c5ca
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`.
@@ -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 = Net::HTTP.new(hostname, port)
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
@@ -1,3 +1,3 @@
1
1
  module Verm
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -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.1.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-03-04 00:00:00.000000000 Z
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.