semian 0.8.7 → 0.8.8
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 +4 -4
- data/lib/semian/grpc.rb +104 -0
- data/lib/semian/version.rb +1 -1
- metadata +31 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 482a9a2fce30afb0e07d277552e3bab16bad193f7773977ba6c6c3c1f6805eb3
|
4
|
+
data.tar.gz: f37534843a00fc5d9dd5dd4c060a088f47b183efc12e00699a4a82521b50f72f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9f82b1d85f221594485c6ac5e16f803935df723b8893849b0126c2a7a77b50015e9162129030188f3ac538a76dd828909b36871fed8368b12b763c17a9d1d3a
|
7
|
+
data.tar.gz: 1ea3b43414268a58e02d8dd53ed608e4bb576334a33e5948027557946cecb5b15bdc8e99aaabee4c00c1bb9737ba1740e67925abc9b052548099b0f32d360ef2
|
data/lib/semian/grpc.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'semian/adapter'
|
2
|
+
require 'grpc'
|
3
|
+
|
4
|
+
module GRPC
|
5
|
+
GRPC::Unavailable.include(::Semian::AdapterError)
|
6
|
+
GRPC::Unknown.include(::Semian::AdapterError)
|
7
|
+
GRPC::ResourceExhausted.include(::Semian::AdapterError)
|
8
|
+
|
9
|
+
class SemianError < GRPC::Unavailable
|
10
|
+
attr_reader :details
|
11
|
+
|
12
|
+
def initialize(semian_identifier, *args)
|
13
|
+
super(*args)
|
14
|
+
@details = message
|
15
|
+
@semian_identifier = semian_identifier
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ResourceBusyError = Class.new(SemianError)
|
20
|
+
CircuitOpenError = Class.new(SemianError)
|
21
|
+
end
|
22
|
+
|
23
|
+
module Semian
|
24
|
+
module GRPC
|
25
|
+
attr_reader :raw_semian_options
|
26
|
+
include Semian::Adapter
|
27
|
+
|
28
|
+
ResourceBusyError = ::GRPC::ResourceBusyError
|
29
|
+
CircuitOpenError = ::GRPC::CircuitOpenError
|
30
|
+
|
31
|
+
class SemianConfigurationChangedError < RuntimeError
|
32
|
+
def initialize(msg = "Cannot re-initialize semian_configuration")
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
attr_accessor :exceptions
|
39
|
+
attr_reader :semian_configuration
|
40
|
+
|
41
|
+
def semian_configuration=(configuration)
|
42
|
+
raise Semian::GRPC::SemianConfigurationChangedError unless @semian_configuration.nil?
|
43
|
+
@semian_configuration = configuration
|
44
|
+
end
|
45
|
+
|
46
|
+
def retrieve_semian_configuration(host)
|
47
|
+
@semian_configuration.call(host) if @semian_configuration.respond_to?(:call)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def raw_semian_options
|
52
|
+
@raw_semian_options ||= begin
|
53
|
+
# If the host is empty, it's possible that the adapter was initialized
|
54
|
+
# with the channel. Therefore, we look into the channel to find the host
|
55
|
+
if @host.empty?
|
56
|
+
host = @ch.target
|
57
|
+
else
|
58
|
+
host = @host
|
59
|
+
end
|
60
|
+
@raw_semian_options = Semian::GRPC.retrieve_semian_configuration(host)
|
61
|
+
@raw_semian_options = @raw_semian_options.dup unless @raw_semian_options.nil?
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def semian_identifier
|
66
|
+
@semian_identifier ||= raw_semian_options[:name]
|
67
|
+
end
|
68
|
+
|
69
|
+
def resource_exceptions
|
70
|
+
[
|
71
|
+
::GRPC::DeadlineExceeded,
|
72
|
+
::GRPC::ResourceExhausted,
|
73
|
+
::GRPC::Unavailable,
|
74
|
+
::GRPC::Unknown,
|
75
|
+
]
|
76
|
+
end
|
77
|
+
|
78
|
+
def disabled?
|
79
|
+
raw_semian_options.nil?
|
80
|
+
end
|
81
|
+
|
82
|
+
def request_response(*)
|
83
|
+
return super if disabled?
|
84
|
+
acquire_semian_resource(adapter: :grpc, scope: :request_response) { super }
|
85
|
+
end
|
86
|
+
|
87
|
+
def client_streamer(*)
|
88
|
+
return super if disabled?
|
89
|
+
acquire_semian_resource(adapter: :grpc, scope: :client_streamer) { super }
|
90
|
+
end
|
91
|
+
|
92
|
+
def server_streamer(*)
|
93
|
+
return super if disabled?
|
94
|
+
acquire_semian_resource(adapter: :grpc, scope: :server_streamer) { super }
|
95
|
+
end
|
96
|
+
|
97
|
+
def bidi_streamer(*)
|
98
|
+
return super if disabled?
|
99
|
+
acquire_semian_resource(adapter: :grpc, scope: :bidi_streamer) { super }
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
::GRPC::ClientStub.prepend(Semian::GRPC)
|
data/lib/semian/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: semian
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Francis
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-02-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rake-compiler
|
@@ -138,6 +138,34 @@ dependencies:
|
|
138
138
|
- - "~>"
|
139
139
|
- !ruby/object:Gem::Version
|
140
140
|
version: 1.0.0
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: grpc
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
type: :development
|
149
|
+
prerelease: false
|
150
|
+
version_requirements: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: mocha
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - ">="
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '0'
|
162
|
+
type: :development
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
141
169
|
description: |2
|
142
170
|
A Ruby C extention that is used to control access to shared resources
|
143
171
|
across process boundaries with SysV semaphores.
|
@@ -160,6 +188,7 @@ files:
|
|
160
188
|
- lib/semian.rb
|
161
189
|
- lib/semian/adapter.rb
|
162
190
|
- lib/semian/circuit_breaker.rb
|
191
|
+
- lib/semian/grpc.rb
|
163
192
|
- lib/semian/instrumentable.rb
|
164
193
|
- lib/semian/mysql2.rb
|
165
194
|
- lib/semian/net_http.rb
|