anycable 1.0.3 → 1.1.0.pre1

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: c4ad5eeba2fa05d2271aa9b84195fe9bf8e34365c3e76a993d9e695b2aec4772
4
- data.tar.gz: 4df199ef6e5f96c3c0dba5615d30c2da944780288c2d2cf8dbc7863814a1a73f
3
+ metadata.gz: da7b50556f5acc1d91b726c2c534ac2530395b2b3cbf994a7191ca95f82150d6
4
+ data.tar.gz: d1a66b384073c987c490a549f08cbe0c0a9dcd12f2fca1ce8c7b7a0143f60b7c
5
5
  SHA512:
6
- metadata.gz: bab0f69742979b57e8ed9f635c2e9e1f1350569a36d28ebe44f4102849b2a28f82445c78785d84bd4af1def082f67958d7fda337b2a487b6533a7d1115defdfa
7
- data.tar.gz: 0de66f9c23a4235c9460ac4e73c512a2e955ba48081e455298701a1f5106e5e4667d28cdb2c4decb8c3b0dc2b0be55681a12acb10a6b50bda03536dc9401d715
6
+ metadata.gz: c7238e70df8f7ec04c1c0301a3fa614a91cf764d541504a6d21aadbfe89691c949bb0f4828678ba30478249cfbe19d38a5e77332c1d466eac7d161aba8ed48fa
7
+ data.tar.gz: 92679d203f34bc1c5f26de2460f8724883b29c42e1b56fdc5b528b1749ed47ce1de4d81fe42fd934f6e31ce85964575e6084e1dddb1ff83a733efc73c51f2ba5
data/CHANGELOG.md CHANGED
@@ -2,6 +2,25 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.1.0-dev
6
+
7
+ - **BREAKING** Move middlewares from gRPC interceptors to custom implementation. ([@palkan][])
8
+
9
+ That allowed us to have _real_ middlewares with ability to modify responses, intercept exceptions, etc.
10
+ The API changed a bit:
11
+
12
+ ```diff
13
+ class SomeMiddleware < AnyCable::Middleware
14
+ - def call(request, rpc_call, rpc_handler)
15
+ + def call(rpc_method_name, request)
16
+ yield
17
+ end
18
+ end
19
+ ```
20
+
21
+ - **Ruby >= 2.6** is required.
22
+ - **Anyway Config >= 2.1** is required.
23
+
5
24
  ## 1.0.3 (2021-03-05)
6
25
 
7
26
  - Ruby 3.0 compatibility. ([@palkan][])
data/README.md CHANGED
@@ -12,14 +12,12 @@ AnyCable allows you to use any WebSocket server (written in any language) as a r
12
12
 
13
13
  AnyCable uses the same protocol as ActionCable, so you can use its [JavaScript client](https://www.npmjs.com/package/actioncable) without any monkey-patching.
14
14
 
15
- **Important** This is a readme for the upcoming v1.0 release. For v0.6.x see the readme from the [0-6-stable](https://github.com/anycable/anycable/tree/0-6-stable) branch.
16
-
17
15
  <a href="https://evilmartians.com/">
18
16
  <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg" alt="Sponsored by Evil Martians" width="236" height="54"></a>
19
17
 
20
18
  ## Requirements
21
19
 
22
- - Ruby >= 2.5
20
+ - Ruby >= 2.6
23
21
  - Redis (for broadcasting **in production**, [discuss other options](https://github.com/anycable/anycable/issues/2) with us!)
24
22
 
25
23
  ## Usage
metadata CHANGED
@@ -1,180 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0.pre1
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-05 00:00:00.000000000 Z
11
+ date: 2021-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: anyway_config
14
+ name: anycable-core
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 1.4.2
19
+ version: 1.1.0.pre1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 1.4.2
26
+ version: 1.1.0.pre1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: grpc
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.17'
33
+ version: '1.37'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.17'
41
- - !ruby/object:Gem::Dependency
42
- name: redis
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '4.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '4.0'
55
- - !ruby/object:Gem::Dependency
56
- name: bundler
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '1'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '1'
69
- - !ruby/object:Gem::Dependency
70
- name: rake
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '13.0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '13.0'
83
- - !ruby/object:Gem::Dependency
84
- name: rack
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '2.0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '2.0'
97
- - !ruby/object:Gem::Dependency
98
- name: rspec
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '3.5'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '3.5'
111
- - !ruby/object:Gem::Dependency
112
- name: webmock
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '3.8'
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '3.8'
125
- - !ruby/object:Gem::Dependency
126
- name: webrick
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
40
+ version: '1.37'
139
41
  description: AnyCable is a polyglot replacement for ActionCable-compatible servers
140
42
  email:
141
43
  - dementiev.vm@gmail.com
142
- executables:
143
- - anycable
144
- - anycabled
44
+ executables: []
145
45
  extensions: []
146
46
  extra_rdoc_files: []
147
47
  files:
148
48
  - CHANGELOG.md
149
49
  - MIT-LICENSE
150
50
  - README.md
151
- - bin/anycable
152
- - bin/anycabled
153
- - bin/console
154
- - bin/setup
155
- - lib/anycable.rb
156
- - lib/anycable/broadcast_adapters.rb
157
- - lib/anycable/broadcast_adapters/base.rb
158
- - lib/anycable/broadcast_adapters/http.rb
159
- - lib/anycable/broadcast_adapters/redis.rb
160
- - lib/anycable/cli.rb
161
- - lib/anycable/config.rb
162
- - lib/anycable/exceptions_handling.rb
163
- - lib/anycable/health_server.rb
164
- - lib/anycable/middleware.rb
165
- - lib/anycable/middleware_chain.rb
166
- - lib/anycable/middlewares/check_version.rb
167
- - lib/anycable/rpc.rb
168
- - lib/anycable/rpc/rpc_pb.rb
169
- - lib/anycable/rpc/rpc_services_pb.rb
170
- - lib/anycable/rpc_handler.rb
171
- - lib/anycable/rspec.rb
172
- - lib/anycable/rspec/rpc_command_context.rb
173
- - lib/anycable/rspec/rpc_stub_context.rb
174
- - lib/anycable/rspec/with_grpc_server.rb
175
- - lib/anycable/server.rb
176
- - lib/anycable/socket.rb
177
- - lib/anycable/version.rb
178
51
  homepage: http://github.com/anycable/anycable
179
52
  licenses:
180
53
  - MIT
@@ -184,7 +57,7 @@ metadata:
184
57
  documentation_uri: https://docs.anycable.io/
185
58
  homepage_uri: https://anycable.io/
186
59
  source_code_uri: http://github.com/anycable/anycable
187
- post_install_message:
60
+ post_install_message:
188
61
  rdoc_options: []
189
62
  require_paths:
190
63
  - lib
@@ -192,15 +65,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
192
65
  requirements:
193
66
  - - ">="
194
67
  - !ruby/object:Gem::Version
195
- version: 2.5.0
68
+ version: 2.6.0
196
69
  required_rubygems_version: !ruby/object:Gem::Requirement
197
70
  requirements:
198
- - - ">="
71
+ - - ">"
199
72
  - !ruby/object:Gem::Version
200
- version: '0'
73
+ version: 1.3.1
201
74
  requirements: []
202
- rubygems_version: 3.0.6
203
- signing_key:
75
+ rubygems_version: 3.2.15
76
+ signing_key:
204
77
  specification_version: 4
205
78
  summary: AnyCable is a polyglot replacement for ActionCable-compatible servers
206
79
  test_files: []
data/bin/anycable DELETED
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "anycable/cli"
4
-
5
- begin
6
- cli = AnyCable::CLI.new
7
- cli.run(ARGV)
8
- rescue => e
9
- raise e if $DEBUG
10
- STDERR.puts e.message
11
- STDERR.puts e.backtrace.join("\n")
12
- exit 1
13
- end
data/bin/anycabled DELETED
@@ -1,30 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "anycable/cli"
4
-
5
- begin
6
- require "daemons"
7
- rescue LoadError
8
- raise <<~MSG
9
- You need to add gem 'daemons' to your Gemfile if you want to use `anycabled`:
10
-
11
- # Gemfile
12
- gem "daemons", "~> 1.3", require: false
13
- MSG
14
- end
15
-
16
- options = {
17
- dir: "tmp/pids",
18
- log_output: false
19
- }
20
-
21
- # Preserve current directory. We need it inside the server.
22
- current_dir = Dir.pwd
23
-
24
- # Clean ARGV from daemon command and args
25
- _, _, args = Daemons::Controller.split_argv(ARGV)
26
-
27
- Daemons.run_proc("anycable", options) do
28
- Dir.chdir current_dir
29
- AnyCable::CLI.new.run(args)
30
- end
data/bin/console DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "anycable"
5
-
6
- require "pry"
7
- Pry.start
data/bin/setup DELETED
@@ -1,6 +0,0 @@
1
- #!/bin/sh
2
-
3
- set -e
4
-
5
- gem install bundler --conservative
6
- bundle check || bundle install
data/lib/anycable.rb DELETED
@@ -1,101 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anycable/version"
4
- require "logger"
5
-
6
- require "anycable/exceptions_handling"
7
- require "anycable/broadcast_adapters"
8
-
9
- require "anycable/middleware_chain"
10
-
11
- require "anycable/server"
12
-
13
- # AnyCable allows to use any websocket service (written in any language) as a replacement
14
- # for ActionCable server.
15
- #
16
- # AnyCable includes a gRPC server, which is used by external WS server to execute commands
17
- # (authentication, subscription authorization, client-to-server messages).
18
- #
19
- # Broadcasting messages to WS is done through _broadcast adapter_ (Redis Pub/Sub by default).
20
- module AnyCable
21
- class << self
22
- # Provide connection factory which
23
- # is a callable object with build
24
- # a Connection object
25
- attr_accessor :connection_factory
26
-
27
- attr_writer :logger
28
-
29
- attr_reader :middleware
30
-
31
- def logger
32
- return @logger if instance_variable_defined?(:@logger)
33
-
34
- log_output = AnyCable.config.log_file || $stdout
35
- @logger = Logger.new(log_output).tap do |logger|
36
- logger.level = AnyCable.config.log_level
37
- end
38
- end
39
-
40
- def config
41
- @config ||= begin
42
- # Load anyway_config as later as possible
43
- # to make sure all framework-dependent patches are loaded
44
- require "anycable/config"
45
- Config.new
46
- end
47
- end
48
-
49
- def configure
50
- yield(config) if block_given?
51
- end
52
-
53
- # Register a custom block that will be called
54
- # when an exception is raised during gRPC call
55
- def capture_exception(&block)
56
- ExceptionsHandling << block
57
- end
58
-
59
- # Register a callback to be invoked before
60
- # the server starts
61
- def configure_server(&block)
62
- server_callbacks << block
63
- end
64
-
65
- def server_callbacks
66
- @server_callbacks ||= []
67
- end
68
-
69
- def broadcast_adapter
70
- self.broadcast_adapter = AnyCable.config.broadcast_adapter.to_sym unless instance_variable_defined?(:@broadcast_adapter)
71
- @broadcast_adapter
72
- end
73
-
74
- def broadcast_adapter=(adapter)
75
- if adapter.is_a?(Symbol) || adapter.is_a?(Array)
76
- adapter = BroadcastAdapters.lookup_adapter(adapter)
77
- end
78
-
79
- unless adapter.respond_to?(:broadcast)
80
- raise ArgumentError, "BroadcastAdapter must implement #broadcast method. " \
81
- "#{adapter.class} doesn't implement it."
82
- end
83
-
84
- @broadcast_adapter = adapter
85
- end
86
-
87
- # Raw broadcast message to the channel, sends only string!
88
- # To send hash or object use ActionCable.server.broadcast instead!
89
- def broadcast(channel, payload)
90
- broadcast_adapter.broadcast(channel, payload)
91
- end
92
-
93
- private
94
-
95
- attr_writer :middleware
96
- end
97
-
98
- require "anycable/middlewares/check_version"
99
-
100
- self.middleware = MiddlewareChain.new
101
- end
@@ -1,35 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "anycable/broadcast_adapters/base"
4
-
5
- module AnyCable
6
- module BroadcastAdapters # :nodoc:
7
- module_function
8
-
9
- # rubocop: disable Metrics/AbcSize, Metrics/MethodLength
10
- def lookup_adapter(args)
11
- adapter, options = Array(args)
12
- path_to_adapter = "anycable/broadcast_adapters/#{adapter}"
13
- adapter_class_name = adapter.to_s.split("_").map(&:capitalize).join
14
-
15
- unless BroadcastAdapters.const_defined?(adapter_class_name, false)
16
- begin
17
- require path_to_adapter
18
- rescue LoadError => e
19
- # We couldn't require the adapter itself.
20
- if e.path == path_to_adapter
21
- raise e.class, "Couldn't load the '#{adapter}' broadcast adapter for AnyCable",
22
- e.backtrace
23
- # Bubbled up from the adapter require.
24
- else
25
- raise e.class, "Error loading the '#{adapter}' broadcast adapter for AnyCable",
26
- e.backtrace
27
- end
28
- end
29
- end
30
-
31
- BroadcastAdapters.const_get(adapter_class_name, false).new(**(options || {}))
32
- end
33
- # rubocop: enable Metrics/AbcSize, Metrics/MethodLength
34
- end
35
- end