reloader_interceptor 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/reloader_interceptor.rb +17 -1
- data/lib/reloader_interceptor/server_interceptor.rb +9 -2
- data/lib/reloader_interceptor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61ba3f1dd180dd43eb74aa60dd40f76484d467d8ffa2c5b056819ba59ad819a8
|
4
|
+
data.tar.gz: 8e9462708b474cd6f1c72f74fd313fe3d8cffa35ea8b943672577ad0dfccebb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fa7eb19c0ad9d5780175a4aae8c45ec7c959c7ab4cf830ed6231db49cd0796d1b6b49f58d90260ca407a971892bf39bdac5562d8f609a3e9386f7b37203a019
|
7
|
+
data.tar.gz: 72c86a51df465cef2151ab7c4d44ef7714b68e02f3b297bc19aca85ca2e8368f00921ac010f4db0f2b8f1be2d4c6c3669534edc3d42a75e9accdbe4426ce3107
|
data/Gemfile.lock
CHANGED
data/lib/reloader_interceptor.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "active_support"
|
1
2
|
require_relative "./reloader_interceptor/version"
|
2
3
|
require_relative "./reloader_interceptor/server_interceptor"
|
3
4
|
require_relative "./reloader_interceptor/wrapper"
|
@@ -6,6 +7,7 @@ module ReloaderInterceptor
|
|
6
7
|
@enabled = true # Enabled by default
|
7
8
|
|
8
9
|
class << self
|
10
|
+
# @return [bool]
|
9
11
|
def enabled?
|
10
12
|
@enabled
|
11
13
|
end
|
@@ -18,6 +20,20 @@ module ReloaderInterceptor
|
|
18
20
|
@enabled = false
|
19
21
|
end
|
20
22
|
|
21
|
-
|
23
|
+
# @return [Class] A class which inherits ActiveSupport::Executor
|
24
|
+
def executor
|
25
|
+
reloader.executor
|
26
|
+
end
|
27
|
+
|
28
|
+
# @return [Class] A class which inherits ActiveSupport::Reloader
|
29
|
+
def reloader
|
30
|
+
@reloader ||= begin
|
31
|
+
r = Class.new(ActiveSupport::Reloader)
|
32
|
+
r.executor = Class.new(ActiveSupport::Executor)
|
33
|
+
r
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
attr_writer :enabled, :reloader
|
22
38
|
end
|
23
39
|
end
|
@@ -2,18 +2,25 @@ require "grpc"
|
|
2
2
|
|
3
3
|
module ReloaderInterceptor
|
4
4
|
class ServerInterceptor < GRPC::ServerInterceptor
|
5
|
-
|
5
|
+
# @param [Class, nil] reloader A class which inherits ActiveSupport::Reloader
|
6
|
+
def initialize(reloader: nil)
|
6
7
|
@reloader = reloader
|
7
8
|
end
|
8
9
|
|
9
10
|
def request_response(request:, call:, method:, &block)
|
10
11
|
return yield unless ReloaderInterceptor.enabled?
|
11
12
|
|
12
|
-
|
13
|
+
reloader.wrap do
|
13
14
|
yield
|
14
15
|
end
|
15
16
|
end
|
16
17
|
|
17
18
|
# NOTE: For now, we don't support server_streamer, client_streamer and bidi_streamer
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def reloader
|
23
|
+
@reloader || ReloaderInterceptor.reloader
|
24
|
+
end
|
18
25
|
end
|
19
26
|
end
|