griffin 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e380066807405ad0cd85bb8d26d3b263ba3de198288c642430c2be19a7c86732
4
- data.tar.gz: 83608646081bc8ee5934ce025b161102be2f421340ce4ae045cbd68e98e260d0
3
+ metadata.gz: 7c652877e17adc1c4fa9b80a57e3221b82f96d293e91b651ec353ff50def5e9e
4
+ data.tar.gz: e18fdedd34dee63f6baa9b9ec27624e063441e9797667672f522ac24fe422651
5
5
  SHA512:
6
- metadata.gz: d4617d35228892ee4e2ef3a9d900154d5acf8a68361e26b1f4352f403b8c3abff1c00e41f354eb71f96c47c7695dbfea38ec76634b7b50fc0dde211faffa0268
7
- data.tar.gz: 3a631fddb85ec1319e29aa9b92a736b096c31acfbe76aa0d0c1e7e179816d20d95a41b9e72fc477f1f5209661e83fda167222a8a17111d2bbc08c7b0e4b1abfa
6
+ metadata.gz: f68f68011a3f44ab51c1df9023c886be6557c6df2c08880eea898d2ebde45a113a1b6b15d61a09d9e230553e7f081c606a8d0497c85db525c8bceeed3e7d4429
7
+ data.tar.gz: 3cf82bf6088dcba222d83bdde1466f24d3a7e79dea41c9557774dfc626c0daebbebea87415fe418133a8dd69e6a884162b8f5dec2177d95a92097d7f9f2cf8f3
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2018 TODO: ganmacs
3
+ Copyright (c) 2019 Yuta Iwama
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -67,6 +67,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/ganmac
67
67
 
68
68
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
69
69
 
70
- ## Code of Conduct
71
-
72
- TODO
data/griffin.gemspec CHANGED
@@ -7,7 +7,7 @@ require 'griffin/version'
7
7
  Gem::Specification.new do |spec|
8
8
  spec.name = 'griffin'
9
9
  spec.version = Griffin::VERSION
10
- spec.authors = ['ganmacs']
10
+ spec.authors = ['Yuta Iwama']
11
11
  spec.email = ['ganmacs@gmail.com']
12
12
 
13
13
  spec.summary = 'gRPC server and client for Ruby'
@@ -28,7 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rspec'
29
29
  spec.add_development_dependency 'rubocop'
30
30
 
31
- spec.add_dependency 'connection_pool', '~> 2.2.2'
32
31
  spec.add_dependency 'grpc_kit', '>= 0.2.0'
33
32
  spec.add_dependency 'serverengine', '~> 2.0.7'
34
33
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Griffin
4
- VERSION = '0.1.6'
4
+ VERSION = '0.1.7'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griffin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
- - ganmacs
7
+ - Yuta Iwama
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-21 00:00:00.000000000 Z
11
+ date: 2019-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: connection_pool
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 2.2.2
90
- type: :runtime
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 2.2.2
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: grpc_kit
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -156,8 +142,6 @@ files:
156
142
  - examples/routeguide_server.rb
157
143
  - griffin.gemspec
158
144
  - lib/griffin.rb
159
- - lib/griffin/connection_pool/multi_timed_stack.rb
160
- - lib/griffin/connection_pool/pool.rb
161
145
  - lib/griffin/counting_semaphore.rb
162
146
  - lib/griffin/engine.rb
163
147
  - lib/griffin/engine/server.rb
@@ -1,78 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'connection_pool'
4
-
5
- module Griffin
6
- module ConnectionPool
7
- # This code is based on https://github.com/drbrain/net-http-persistent/blob/0e5a8fb8a27deff37247ddb3bc5e6c9e390face5/lib/net/http/persistent/timed_stack_multi.rb
8
- class MultiTimedStack < ::ConnectionPool::TimedStack
9
- def initialize(size = 0, &block)
10
- super
11
-
12
- @enqueued = 0
13
- @ques = Hash.new { |h, k| h[k] = [] }
14
- @lru = []
15
- end
16
-
17
- def empty?
18
- length <= 0
19
- end
20
-
21
- def length
22
- @max - @created + @enqueued
23
- end
24
-
25
- private
26
-
27
- def connection_stored?(options = {})
28
- !@ques[options[:connection_args]].empty?
29
- end
30
-
31
- def fetch_connection(options = {})
32
- connection_args = options[:connection_args]
33
-
34
- @enqueued -= 1
35
- lru_update(connection_args)
36
- @ques[connection_args].pop
37
- end
38
-
39
- def shutdown_connections
40
- @ques.each_key do |key|
41
- super(connection_args: key)
42
- end
43
- end
44
-
45
- def store_connection(obj, options = {})
46
- @ques[options[:connection_args]].push(obj)
47
- @enqueued += 1
48
- end
49
-
50
- def try_create(options = {})
51
- connection_args = options[:connection_args]
52
-
53
- if @created >= @max && @enqueued >= 1
54
- oldest = lru_delete
55
- @ques[oldest].pop
56
-
57
- @created -= 1
58
- end
59
-
60
- if @created < @max
61
- obj = @create_block.call(connection_args)
62
- @created += 1
63
- lru_update(connection_args)
64
- obj
65
- end
66
- end
67
-
68
- def lru_update(key)
69
- @lru.delete(key)
70
- @lru.push(key)
71
- end
72
-
73
- def lru_delete
74
- @lru.shift
75
- end
76
- end
77
- end
78
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'connection_pool'
4
-
5
- require 'griffin/connection_pool/multi_timed_stack'
6
-
7
- module Griffin
8
- module ConnectionPool
9
- class Pool
10
- DEFAULTS = { size: 5, timeout: 5 }.freeze
11
-
12
- def initialize(options = {}, &block)
13
- raise ArgumentError, 'Connection pool requires a block' unless block
14
-
15
- options = DEFAULTS.merge(options)
16
-
17
- @size = Integer(options.fetch(:size))
18
- @timeout = Integer(options.fetch(:timeout))
19
-
20
- @available = Griffin::ConnectionPool::MultiTimedStack.new(@size, &block)
21
- @key = :"current-#{@available.object_id}"
22
- Thread.current[@key] = Hash.new { |h, k| h[k] = [] }
23
- end
24
-
25
- def checkin(key)
26
- stack = Thread.current[@key][key]
27
- raise 'no connections are checked out' if stack.empty?
28
-
29
- conn = stack.pop
30
- if stack.empty?
31
- @available.push(conn, connection_args: key)
32
- end
33
- nil
34
- end
35
-
36
- def checkout(key)
37
- stack = Thread.current[@key][key]
38
-
39
- conn =
40
- if stack.empty?
41
- @available.pop(connection_args: key)
42
- else
43
- stack.last
44
- end
45
-
46
- stack.push(conn)
47
-
48
- conn
49
- end
50
-
51
- def shutdown(&block)
52
- @available.shutdown(&block)
53
- end
54
- end
55
- end
56
- end