anycable-rack-server 0.4.0 → 0.5.0
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/LICENSE +1 -1
- data/README.md +2 -1
- data/lib/anycable/rack/coders/msgpack.rb +6 -2
- data/lib/anycable/rack/coders/proto/message_pb.rb +35 -0
- data/lib/anycable/rack/coders/protobuf.rb +38 -0
- data/lib/anycable/rack/middleware.rb +2 -1
- data/lib/anycable/rack/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e0fb06453d826cf3c314edb0dbb6ab1f1ab8774760b40985b105aaf87ca1316
|
4
|
+
data.tar.gz: a6fc8f21bf0944cf1cacb58b779b222782e485af7fe8dcec1bf719b31e05d38f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cba311e11d372c3c6b42f530350bd81729102814a24209c63ae37460fc810b638db350afc82b930b5f8623acdc9423182e70489e220247f82c7c89f09efb8b74
|
7
|
+
data.tar.gz: a8541982f21133340285977c16852f3bbc41c18f4ce431e5b0261f4d3509f8bdf7f9d3816f500c8401eeac3de7223da39b8f5e008fd9c28e131322d4ab8588ad
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2019-
|
3
|
+
Copyright (c) 2019-2022 Yulia Oletskaya, Vladimir Dementyev
|
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
@@ -74,7 +74,8 @@ config.any_cable_rack.rpc_port = 50051
|
|
74
74
|
|
75
75
|
## Broadcast adapters
|
76
76
|
|
77
|
-
AnyCable Rack supports Redis (default) and HTTP broadcast adapters
|
77
|
+
AnyCable Rack supports Redis (default) and HTTP broadcast adapters
|
78
|
+
(see [the documentation](https://docs.anycable.io/ruby/broadcast_adapters)).
|
78
79
|
|
79
80
|
Broadcast adapter is inherited from AnyCable configuration (so, you don't need to configure it twice).
|
80
81
|
|
@@ -12,8 +12,12 @@ module AnyCable
|
|
12
12
|
MessagePack.unpack(bin)
|
13
13
|
end
|
14
14
|
|
15
|
-
def encode(ruby_obj)
|
16
|
-
|
15
|
+
def encode(ruby_obj, binary_frame_wrap: true)
|
16
|
+
message_packed = MessagePack.pack(ruby_obj)
|
17
|
+
|
18
|
+
return message_packed unless binary_frame_wrap
|
19
|
+
|
20
|
+
BinaryFrame.new(message_packed)
|
17
21
|
end
|
18
22
|
end
|
19
23
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "google/protobuf"
|
4
|
+
|
5
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
6
|
+
add_message "action_cable.Message" do
|
7
|
+
optional :type, :enum, 1, "action_cable.Type"
|
8
|
+
optional :command, :enum, 2, "action_cable.Command"
|
9
|
+
optional :identifier, :string, 3
|
10
|
+
optional :data, :string, 4
|
11
|
+
optional :message, :bytes, 5
|
12
|
+
optional :reason, :string, 6
|
13
|
+
optional :reconnect, :bool, 7
|
14
|
+
end
|
15
|
+
add_enum "action_cable.Type" do
|
16
|
+
value :no_type, 0
|
17
|
+
value :welcome, 1
|
18
|
+
value :disconnect, 2
|
19
|
+
value :ping, 3
|
20
|
+
value :confirm_subscription, 4
|
21
|
+
value :reject_subscription, 5
|
22
|
+
end
|
23
|
+
add_enum "action_cable.Command" do
|
24
|
+
value :unknown_command, 0
|
25
|
+
value :subscribe, 1
|
26
|
+
value :unsubscribe, 2
|
27
|
+
value :message, 3
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module ActionCable
|
32
|
+
Message = Google::Protobuf::DescriptorPool.generated_pool.lookup("action_cable.Message").msgclass
|
33
|
+
Type = Google::Protobuf::DescriptorPool.generated_pool.lookup("action_cable.Type").enummodule
|
34
|
+
Command = Google::Protobuf::DescriptorPool.generated_pool.lookup("action_cable.Command").enummodule
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
gem "google-protobuf", "~> 3.19", ">= 3.19.1"
|
4
|
+
require_relative "./proto/message_pb"
|
5
|
+
require_relative "./msgpack"
|
6
|
+
|
7
|
+
module AnyCable
|
8
|
+
module Rack
|
9
|
+
module Coders
|
10
|
+
module Protobuf # :nodoc:
|
11
|
+
class << self
|
12
|
+
def decode(bin)
|
13
|
+
decoded_message = ActionCable::Message.decode(bin).to_h
|
14
|
+
|
15
|
+
decoded_message[:command] = decoded_message[:command].to_s
|
16
|
+
if decoded_message[:message].present?
|
17
|
+
decoded_message[:message] = Msgpack.decode(decoded_message[:message])
|
18
|
+
end
|
19
|
+
|
20
|
+
decoded_message.each_with_object({}) { |(k, v), h| h[k.to_s] = v }
|
21
|
+
end
|
22
|
+
|
23
|
+
def encode(ruby_obj)
|
24
|
+
message = ruby_obj.delete(:message)
|
25
|
+
|
26
|
+
data = ActionCable::Message.new(ruby_obj)
|
27
|
+
|
28
|
+
if message
|
29
|
+
data.message = Msgpack.encode(message, binary_frame_wrap: false)
|
30
|
+
end
|
31
|
+
|
32
|
+
BinaryFrame.new(ActionCable::Message.encode(data))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -9,7 +9,8 @@ require "anycable/rack/socket"
|
|
9
9
|
module AnyCable
|
10
10
|
module Rack
|
11
11
|
class Middleware # :nodoc:
|
12
|
-
PROTOCOLS = [
|
12
|
+
PROTOCOLS = %w[actioncable-v1-json actioncable-v1-msgpack actioncable-unsupported actioncable-v1-protobuf].freeze
|
13
|
+
|
13
14
|
attr_reader :pinger,
|
14
15
|
:hub,
|
15
16
|
:coder,
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: anycable-rack-server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yulia Oletskaya
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: anyway_config
|
@@ -171,6 +171,8 @@ files:
|
|
171
171
|
- lib/anycable/rack/broadcast_subscribers/redis_subscriber.rb
|
172
172
|
- lib/anycable/rack/coders/json.rb
|
173
173
|
- lib/anycable/rack/coders/msgpack.rb
|
174
|
+
- lib/anycable/rack/coders/proto/message_pb.rb
|
175
|
+
- lib/anycable/rack/coders/protobuf.rb
|
174
176
|
- lib/anycable/rack/config.rb
|
175
177
|
- lib/anycable/rack/connection.rb
|
176
178
|
- lib/anycable/rack/errors.rb
|
@@ -203,7 +205,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
205
|
- !ruby/object:Gem::Version
|
204
206
|
version: '0'
|
205
207
|
requirements: []
|
206
|
-
rubygems_version: 3.
|
208
|
+
rubygems_version: 3.3.7
|
207
209
|
signing_key:
|
208
210
|
specification_version: 4
|
209
211
|
summary: AnyCable Rack Server
|