anycable 1.0.0.rc1 → 1.0.3

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: deebe94f2e541a9d14ccf4a56df910cdb5a2fb17ae6815ffaaa2f761fdcd07ad
4
- data.tar.gz: e96c5b0d28dd7617c2cfa1249fde5bd357465be7596915720c27718f486c4f16
3
+ metadata.gz: c4ad5eeba2fa05d2271aa9b84195fe9bf8e34365c3e76a993d9e695b2aec4772
4
+ data.tar.gz: 4df199ef6e5f96c3c0dba5615d30c2da944780288c2d2cf8dbc7863814a1a73f
5
5
  SHA512:
6
- metadata.gz: b585f2797184d7bc78cc761707b741dcfa8a6b796df91cccd7ac1e44c9210a84852daba838adaaa6b2f1548d2d0f82cf57713b32a4a86d0ffa671f64321b9df1
7
- data.tar.gz: dccd27127eaafc5b7821ba18404546269e9aaf3163faccffaba864e166cb1c19cdc914ccf9de87da963cac447541058e0d7ba906674298f9dda8573ca4e917c8
6
+ metadata.gz: bab0f69742979b57e8ed9f635c2e9e1f1350569a36d28ebe44f4102849b2a28f82445c78785d84bd4af1def082f67958d7fda337b2a487b6533a7d1115defdfa
7
+ data.tar.gz: 0de66f9c23a4235c9460ac4e73c512a2e955ba48081e455298701a1f5106e5e4667d28cdb2c4decb8c3b0dc2b0be55681a12acb10a6b50bda03536dc9401d715
data/CHANGELOG.md CHANGED
@@ -1,6 +1,24 @@
1
1
  # Change log
2
2
 
3
- ## 1.0.0.rc1 (2020-06-10)
3
+ ## master
4
+
5
+ ## 1.0.3 (2021-03-05)
6
+
7
+ - Ruby 3.0 compatibility. ([@palkan][])
8
+
9
+ ## 1.0.2 (2021-01-05)
10
+
11
+ - Handle TLS Redis connections by using VERIFY_NONE mode. ([@palkan][])
12
+
13
+ ## 1.0.1 (2020-07-07)
14
+
15
+ - Support providing passwords for Redis Sentinels. ([@palkan][])
16
+
17
+ Use the following format: `ANYCABLE_REDIS_SENTINELS=:password1@my.redis.sentinel.first:26380,:password2@my.redis.sentinel.second:26380`.
18
+
19
+ ## 1.0.0 (2020-07-01)
20
+
21
+ - Add `embedded` option to CLI runner. ([@palkan][])
4
22
 
5
23
  - Add `Env#istate` and `EnvResponse#istate` to store channel state. ([@palkan][])
6
24
 
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2017-2020 Vladimir Dementyev
1
+ Copyright 2017-2021 Vladimir Dementyev
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
- [![GitPitch](https://gitpitch.com/assets/badge.svg)](https://gitpitch.com/anycable/anycable/master?grs=github)
2
1
  [![Gem Version](https://badge.fury.io/rb/anycable.svg)](https://rubygems.org/gems/anycable)
3
2
  [![Build](https://github.com/anycable/anycable/workflows/Build/badge.svg)](https://github.com/anycable/anycable/actions)
4
3
  [![Gitter](https://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/anycable/Lobby)
@@ -29,6 +28,8 @@ Check out our 📑 [Documentation](https://docs.anycable.io/v1).
29
28
 
30
29
  ## Links
31
30
 
31
+ - [AnyCable 1.0: Four years of real-time web with Ruby and Go](https://evilmartians.com/chronicles/anycable-1-0-four-years-of-real-time-web-with-ruby-and-go)
32
+
32
33
  - [AnyCable: Action Cable on steroids!](https://evilmartians.com/chronicles/anycable-actioncable-on-steroids)
33
34
 
34
35
  - [Connecting LiteCable to Hanami](http://gabrielmalakias.com.br/ruby/hanami/iot/2017/05/26/websockets-connecting-litecable-to-hanami.html) by [@GabrielMalakias](https://github.com/GabrielMalakias)
data/lib/anycable.rb CHANGED
@@ -31,7 +31,7 @@ module AnyCable
31
31
  def logger
32
32
  return @logger if instance_variable_defined?(:@logger)
33
33
 
34
- log_output = AnyCable.config.log_file || STDOUT
34
+ log_output = AnyCable.config.log_file || $stdout
35
35
  @logger = Logger.new(log_output).tap do |logger|
36
36
  logger.level = AnyCable.config.log_level
37
37
  end
@@ -41,7 +41,7 @@ module AnyCable
41
41
  DELAY = 2
42
42
 
43
43
  attr_reader :url, :headers, :authorized
44
- alias authorized? authorized
44
+ alias_method :authorized?, :authorized
45
45
 
46
46
  def initialize(url: AnyCable.config.http_broadcast_url, secret: AnyCable.config.http_broadcast_secret)
47
47
  @url = url
data/lib/anycable/cli.rb CHANGED
@@ -20,17 +20,22 @@ module AnyCable
20
20
  # Wait for external process termination (s)
21
21
  WAIT_PROCESS = 2
22
22
 
23
- attr_reader :server, :health_server
23
+ attr_reader :server, :health_server, :embedded
24
+ alias_method :embedded?, :embedded
25
+
26
+ def initialize(embedded: false)
27
+ @embedded = embedded
28
+ end
24
29
 
25
30
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
26
- def run(args = {})
31
+ def run(args = [])
27
32
  @at_stop = []
28
33
 
29
34
  extra_options = parse_cli_options!(args)
30
35
 
31
36
  # Boot app first, 'cause it might change
32
37
  # configuration, loggin settings, etc.
33
- boot_app!
38
+ boot_app! unless embedded?
34
39
 
35
40
  parse_gem_options!(extra_options)
36
41
 
@@ -40,7 +45,7 @@ module AnyCable
40
45
 
41
46
  print_versions!
42
47
 
43
- logger.info "Serving #{defined?(::Rails) ? "Rails " : ""}application from #{boot_file}"
48
+ logger.info "Serving #{defined?(::Rails) ? "Rails " : ""}application from #{boot_file}" unless embedded?
44
49
 
45
50
  verify_connection_factory!
46
51
 
@@ -66,6 +71,8 @@ module AnyCable
66
71
 
67
72
  run_custom_server_command! unless server_command.nil?
68
73
 
74
+ return if embedded?
75
+
69
76
  begin
70
77
  wait_till_terminated
71
78
  rescue Interrupt => e
@@ -81,7 +88,7 @@ module AnyCable
81
88
 
82
89
  def shutdown
83
90
  at_stop.each(&:call)
84
- server.stop
91
+ server&.stop
85
92
  end
86
93
 
87
94
  private
@@ -96,9 +103,9 @@ module AnyCable
96
103
  AnyCable.logger
97
104
  end
98
105
 
99
- def at_stop
100
- if block_given?
101
- @at_stop << Proc.new
106
+ def at_stop(&block)
107
+ if block
108
+ @at_stop << block
102
109
  else
103
110
  @at_stop
104
111
  end
@@ -3,6 +3,8 @@
3
3
  require "anyway_config"
4
4
  require "grpc"
5
5
 
6
+ require "uri"
7
+
6
8
  module AnyCable
7
9
  # AnyCable configuration.
8
10
  class Config < Anyway::Config
@@ -45,7 +47,7 @@ module AnyCable
45
47
  version_check_enabled: true
46
48
  )
47
49
 
48
- alias version_check_enabled? version_check_enabled
50
+ alias_method :version_check_enabled?, :version_check_enabled
49
51
 
50
52
  ignore_options :rpc_server_args
51
53
  flag_options :log_grpc, :debug
@@ -75,7 +77,7 @@ module AnyCable
75
77
  @debug != false
76
78
  end
77
79
 
78
- alias debug? debug
80
+ alias_method :debug?, :debug
79
81
  end
80
82
 
81
83
  def http_health_port_provided?
@@ -96,13 +98,17 @@ module AnyCable
96
98
  # Build Redis parameters
97
99
  def to_redis_params
98
100
  {url: redis_url}.tap do |params|
99
- next if redis_sentinels.nil?
101
+ next if redis_sentinels.nil? || redis_sentinels.empty?
100
102
 
101
103
  sentinels = Array(redis_sentinels)
102
104
 
103
105
  next if sentinels.empty?
104
106
 
105
107
  params[:sentinels] = sentinels.map(&method(:parse_sentinel))
108
+ end.tap do |params|
109
+ next unless redis_url.match?(/rediss:\/\//)
110
+
111
+ params[:ssl_params] = {verify_mode: OpenSSL::SSL::VERIFY_NONE}
106
112
  end
107
113
  end
108
114
 
@@ -116,16 +122,14 @@ module AnyCable
116
122
 
117
123
  private
118
124
 
119
- SENTINEL_RXP = /^([\w\-_]*)\:(\d+)$/.freeze
120
-
121
125
  def parse_sentinel(sentinel)
122
126
  return sentinel.transform_keys!(&:to_sym) if sentinel.is_a?(Hash)
123
127
 
124
- matches = sentinel.match(SENTINEL_RXP)
128
+ uri = URI.parse("redis://#{sentinel}")
125
129
 
126
- raise ArgumentError, "Invalid Sentinel value: #{sentinel}" if matches.nil?
127
-
128
- {host: matches[1], port: matches[2].to_i}
130
+ {host: uri.host, port: uri.port}.tap do |opts|
131
+ opts[:password] = uri.password if uri.password
132
+ end
129
133
  end
130
134
  end
131
135
  end
@@ -7,7 +7,7 @@ module AnyCable
7
7
  handlers << procify(block)
8
8
  end
9
9
 
10
- alias << add_handler
10
+ alias_method :<<, :add_handler
11
11
 
12
12
  def notify(exp, method_name, message)
13
13
  handlers.each do |handler|
@@ -53,7 +53,11 @@ module AnyCable
53
53
  end
54
54
 
55
55
  def build_server
56
- require "webrick"
56
+ begin
57
+ require "webrick"
58
+ rescue LoadError
59
+ raise "Please, install webrick gem to use health server"
60
+ end
57
61
 
58
62
  WEBrick::HTTPServer.new(
59
63
  Port: port,
@@ -137,7 +137,7 @@ module AnyCable
137
137
  "SERVER_PORT" => "80",
138
138
  "rack.url_scheme" => "http",
139
139
  "rack.input" => StringIO.new("", "r").tap { |io| io.set_encoding(Encoding::ASCII_8BIT) },
140
- "rack.version" => Rack::VERSION,
140
+ "rack.version" => ::Rack::VERSION,
141
141
  "rack.errors" => StringIO.new("").tap { |io| io.set_encoding(Encoding::ASCII_8BIT) },
142
142
  "rack.multithread" => true,
143
143
  "rack.multiprocess" => false,
@@ -9,6 +9,7 @@ RSpec.shared_context "anycable:rpc:server" do
9
9
  )
10
10
 
11
11
  @server.start
12
+ sleep 0.1
12
13
  end
13
14
 
14
15
  after(:all) { @server.stop }
@@ -17,7 +17,7 @@ module AnyCable
17
17
  source&.[](key)
18
18
  end
19
19
 
20
- alias [] read
20
+ alias_method :[], :read
21
21
 
22
22
  def write(key, val)
23
23
  return if source&.[](key) == val
@@ -28,7 +28,7 @@ module AnyCable
28
28
  source[key] = val
29
29
  end
30
30
 
31
- alias []= write
31
+ alias_method :[]=, :write
32
32
 
33
33
  def changed_fields
34
34
  return unless source && dirty_keys
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module AnyCable
4
- VERSION = "1.0.0.rc1"
4
+ VERSION = "1.0.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anycable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - palkan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2021-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: anyway_config
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
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'
125
139
  description: AnyCable is a polyglot replacement for ActionCable-compatible servers
126
140
  email:
127
141
  - dementiev.vm@gmail.com
@@ -181,9 +195,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
195
  version: 2.5.0
182
196
  required_rubygems_version: !ruby/object:Gem::Requirement
183
197
  requirements:
184
- - - ">"
198
+ - - ">="
185
199
  - !ruby/object:Gem::Version
186
- version: 1.3.1
200
+ version: '0'
187
201
  requirements: []
188
202
  rubygems_version: 3.0.6
189
203
  signing_key: