rubypitaya 3.0.0 → 3.0.1
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/rubypitaya/app-template/Gemfile +1 -1
- data/lib/rubypitaya/app-template/Gemfile.lock +6 -14
- data/lib/rubypitaya/core/nats_connector.rb +12 -57
- data/lib/rubypitaya/core/postman.rb +3 -1
- data/lib/rubypitaya/core/protos/nats_connector.proto +47 -0
- data/lib/rubypitaya/core/protos/nats_connector_pb.rb +56 -0
- data/lib/rubypitaya/version.rb +1 -1
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d50d6d5ffeeab38f9d623c33970eb87e4e89ad64e385f4fe57a8d414342e969a
|
4
|
+
data.tar.gz: 7fb8db293deae83dd0de428a825588b9ca6418eab26a220ab983ac6b1737ab69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88510c87137b193a0f4f1f2a12ad7fd7c2c9acb1be8d2aaeee7545b8f1832b380b4e57a4e9d072deef7e526cc87dfd86461584933fc4e9e0d5f466c520408831
|
7
|
+
data.tar.gz: 341555828f6ed7c3996210cf64bc21cc36e756940b1f506cf81f62aaecbc0aadb18fe07fb9cc6c525d3455c4d45ff22e82efa257e6eee63d41b59b502a85c2c9
|
@@ -52,10 +52,10 @@ GEM
|
|
52
52
|
grpc (~> 1.17)
|
53
53
|
eventmachine (1.2.7)
|
54
54
|
ffi (1.15.4)
|
55
|
-
google-protobuf (3.18.0)
|
55
|
+
google-protobuf (3.18.0-x86_64-linux)
|
56
56
|
googleapis-common-protos-types (1.2.0)
|
57
57
|
google-protobuf (~> 3.14)
|
58
|
-
grpc (1.40.0)
|
58
|
+
grpc (1.40.0-x86_64-linux)
|
59
59
|
google-protobuf (~> 3.15)
|
60
60
|
googleapis-common-protos-types (~> 1.0)
|
61
61
|
i18n (1.8.10)
|
@@ -64,7 +64,6 @@ GEM
|
|
64
64
|
rb-fsevent (~> 0.10, >= 0.10.3)
|
65
65
|
rb-inotify (~> 0.9, >= 0.9.10)
|
66
66
|
method_source (1.0.0)
|
67
|
-
middleware (0.1.0)
|
68
67
|
mime-types (3.3.1)
|
69
68
|
mime-types-data (~> 3.2015)
|
70
69
|
mime-types-data (3.2021.0901)
|
@@ -79,11 +78,6 @@ GEM
|
|
79
78
|
eventmachine (~> 1.2, >= 1.2)
|
80
79
|
ostruct (0.4.0)
|
81
80
|
pg (1.2.3)
|
82
|
-
protobuf (3.10.4)
|
83
|
-
activesupport (>= 3.2)
|
84
|
-
middleware
|
85
|
-
thor
|
86
|
-
thread_safe
|
87
81
|
pry (0.14.1)
|
88
82
|
coderay (~> 1.1)
|
89
83
|
method_source (~> 1.0)
|
@@ -109,14 +103,14 @@ GEM
|
|
109
103
|
rspec-support (~> 3.10.0)
|
110
104
|
rspec-support (3.10.2)
|
111
105
|
ruby2_keywords (0.0.5)
|
112
|
-
rubypitaya (3.0.
|
106
|
+
rubypitaya (3.0.1)
|
113
107
|
activerecord (= 6.1.4.1)
|
114
108
|
etcdv3 (= 0.11.4)
|
109
|
+
google-protobuf (= 3.18.0)
|
115
110
|
mongo (= 2.15.0)
|
116
111
|
nats (= 0.11.0)
|
117
112
|
ostruct (= 0.4.0)
|
118
113
|
pg (= 1.2.3)
|
119
|
-
protobuf (= 3.10.4)
|
120
114
|
rake (= 13.0.6)
|
121
115
|
redis (= 4.4.0)
|
122
116
|
sinatra (= 2.1.0)
|
@@ -135,8 +129,6 @@ GEM
|
|
135
129
|
tilt (~> 2.0)
|
136
130
|
sys-uname (1.2.2)
|
137
131
|
ffi (~> 1.1)
|
138
|
-
thor (1.1.0)
|
139
|
-
thread_safe (0.3.6)
|
140
132
|
tilt (2.0.10)
|
141
133
|
tzinfo (2.0.4)
|
142
134
|
concurrent-ruby (~> 1.0)
|
@@ -144,7 +136,7 @@ GEM
|
|
144
136
|
zeitwerk (2.4.2)
|
145
137
|
|
146
138
|
PLATFORMS
|
147
|
-
|
139
|
+
x86_64-linux
|
148
140
|
|
149
141
|
DEPENDENCIES
|
150
142
|
bundler (= 2.2.22)
|
@@ -152,7 +144,7 @@ DEPENDENCIES
|
|
152
144
|
listen (= 3.7.0)
|
153
145
|
pry (= 0.14.1)
|
154
146
|
rspec (= 3.10.0)
|
155
|
-
rubypitaya (= 3.0.
|
147
|
+
rubypitaya (= 3.0.1)
|
156
148
|
|
157
149
|
BUNDLED WITH
|
158
150
|
2.2.22
|
@@ -1,5 +1,7 @@
|
|
1
|
-
require 'protobuf'
|
2
1
|
require 'nats/client'
|
2
|
+
require 'google/protobuf'
|
3
|
+
|
4
|
+
require 'rubypitaya/core/protos/nats_connector_pb'
|
3
5
|
|
4
6
|
module RubyPitaya
|
5
7
|
|
@@ -23,14 +25,16 @@ module RubyPitaya
|
|
23
25
|
NATS.start(:servers => [@nats_address]) do |nc|
|
24
26
|
|
25
27
|
NATS.subscribe(subscribe_topic) do |message, reply, a, b|
|
26
|
-
request = NatsRequest.decode(message).
|
28
|
+
request = NatsRequest.decode(message).to_h
|
27
29
|
|
28
30
|
Fiber.new do
|
29
31
|
response = yield request
|
30
32
|
|
31
33
|
nats_response = NatsResponse.new(data: response.to_json)
|
32
34
|
|
33
|
-
|
35
|
+
response = NatsResponse.encode(nats_response)
|
36
|
+
|
37
|
+
NATS.publish(reply, response)
|
34
38
|
end.resume
|
35
39
|
end
|
36
40
|
|
@@ -61,8 +65,11 @@ module RubyPitaya
|
|
61
65
|
metadata: session.metadata.to_json,
|
62
66
|
)
|
63
67
|
|
64
|
-
|
65
|
-
|
68
|
+
request = NatsRequest.encode(nats_request)
|
69
|
+
|
70
|
+
nats_response = NATS.request(frontend_topic, request)
|
71
|
+
|
72
|
+
response = NatsResponse.decode(nats_response).to_h
|
66
73
|
|
67
74
|
response
|
68
75
|
end
|
@@ -93,56 +100,4 @@ module RubyPitaya
|
|
93
100
|
"pitaya/connector/user/#{uid}/push"
|
94
101
|
end
|
95
102
|
end
|
96
|
-
|
97
|
-
class NatsSession < ::Protobuf::Message; end
|
98
|
-
class NatsMessage < ::Protobuf::Message; end
|
99
|
-
class NatsRequest < ::Protobuf::Message; end
|
100
|
-
class NatsResponse < ::Protobuf::Message; end
|
101
|
-
class NatsError < ::Protobuf::Message; end
|
102
|
-
class NatsBindMsg < ::Protobuf::Message; end
|
103
|
-
class NatsPush < ::Protobuf::Message; end
|
104
|
-
|
105
|
-
class NatsSession
|
106
|
-
optional :int32, :id, 1
|
107
|
-
optional :bytes, :uid, 2
|
108
|
-
optional :bytes, :data, 3
|
109
|
-
end
|
110
|
-
|
111
|
-
class NatsMessage
|
112
|
-
optional :int32, :id, 1
|
113
|
-
optional :bytes, :route, 2
|
114
|
-
optional :bytes, :data, 3
|
115
|
-
optional :bytes, :reply, 4
|
116
|
-
optional :int32, :type, 5
|
117
|
-
end
|
118
|
-
|
119
|
-
class NatsRequest
|
120
|
-
optional :int32, :type, 1
|
121
|
-
optional NatsSession, :session, 2
|
122
|
-
optional NatsMessage, :msg, 3
|
123
|
-
optional :bytes, :frontendID, 4
|
124
|
-
optional :bytes, :metadata, 5
|
125
|
-
end
|
126
|
-
|
127
|
-
class NatsError
|
128
|
-
optional :bytes, :code, 1
|
129
|
-
optional :bytes, :message, 2
|
130
|
-
optional :bytes, :metadata, 3
|
131
|
-
end
|
132
|
-
|
133
|
-
class NatsResponse
|
134
|
-
optional :bytes, :data, 1
|
135
|
-
optional NatsError, :error, 2
|
136
|
-
end
|
137
|
-
|
138
|
-
class NatsBindMsg
|
139
|
-
optional :bytes, :uid, 1
|
140
|
-
optional :bytes, :fid, 2
|
141
|
-
end
|
142
|
-
|
143
|
-
class NatsPush
|
144
|
-
optional :bytes, :route, 1
|
145
|
-
optional :bytes, :uid, 2
|
146
|
-
optional :bytes, :data, 3
|
147
|
-
end
|
148
103
|
end
|
@@ -19,7 +19,9 @@ module RubyPitaya
|
|
19
19
|
data: session.data.to_json,
|
20
20
|
)
|
21
21
|
|
22
|
-
|
22
|
+
payload = NatsSession.encode(nats_session)
|
23
|
+
|
24
|
+
response = @nats_connector.push_to_frontend(session, route, payload)
|
23
25
|
|
24
26
|
response
|
25
27
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
syntax = "proto3";
|
2
|
+
|
3
|
+
package RubyPitaya;
|
4
|
+
|
5
|
+
message NatsSession {
|
6
|
+
optional int32 id = 1;
|
7
|
+
optional bytes uid = 2;
|
8
|
+
optional bytes data = 3;
|
9
|
+
}
|
10
|
+
|
11
|
+
message NatsMessage {
|
12
|
+
optional int32 id = 1;
|
13
|
+
optional bytes route = 2;
|
14
|
+
optional bytes data = 3;
|
15
|
+
optional bytes reply = 4;
|
16
|
+
optional int32 type = 5;
|
17
|
+
}
|
18
|
+
|
19
|
+
message NatsRequest {
|
20
|
+
optional int32 type = 1;
|
21
|
+
optional NatsSession session = 2;
|
22
|
+
optional NatsMessage msg = 3;
|
23
|
+
optional bytes frontendID = 4;
|
24
|
+
optional bytes metadata = 5;
|
25
|
+
}
|
26
|
+
|
27
|
+
message NatsError {
|
28
|
+
optional bytes code = 1;
|
29
|
+
optional bytes message = 2;
|
30
|
+
optional bytes metadata = 3;
|
31
|
+
}
|
32
|
+
|
33
|
+
message NatsResponse {
|
34
|
+
optional bytes data = 1;
|
35
|
+
optional NatsError error = 2;
|
36
|
+
}
|
37
|
+
|
38
|
+
message NatsBindMsg {
|
39
|
+
optional bytes uid = 1;
|
40
|
+
optional bytes fid = 2;
|
41
|
+
}
|
42
|
+
|
43
|
+
message NatsPush {
|
44
|
+
optional bytes route = 1;
|
45
|
+
optional bytes uid = 2;
|
46
|
+
optional bytes data = 3;
|
47
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# source: nats_connector.proto
|
3
|
+
|
4
|
+
require 'google/protobuf'
|
5
|
+
|
6
|
+
Google::Protobuf::DescriptorPool.generated_pool.build do
|
7
|
+
add_file("nats_connector.proto", :syntax => :proto3) do
|
8
|
+
add_message "RubyPitaya.NatsSession" do
|
9
|
+
proto3_optional :id, :int32, 1
|
10
|
+
proto3_optional :uid, :bytes, 2
|
11
|
+
proto3_optional :data, :bytes, 3
|
12
|
+
end
|
13
|
+
add_message "RubyPitaya.NatsMessage" do
|
14
|
+
proto3_optional :id, :int32, 1
|
15
|
+
proto3_optional :route, :bytes, 2
|
16
|
+
proto3_optional :data, :bytes, 3
|
17
|
+
proto3_optional :reply, :bytes, 4
|
18
|
+
proto3_optional :type, :int32, 5
|
19
|
+
end
|
20
|
+
add_message "RubyPitaya.NatsRequest" do
|
21
|
+
proto3_optional :type, :int32, 1
|
22
|
+
proto3_optional :session, :message, 2, "RubyPitaya.NatsSession"
|
23
|
+
proto3_optional :msg, :message, 3, "RubyPitaya.NatsMessage"
|
24
|
+
proto3_optional :frontendID, :bytes, 4
|
25
|
+
proto3_optional :metadata, :bytes, 5
|
26
|
+
end
|
27
|
+
add_message "RubyPitaya.NatsError" do
|
28
|
+
proto3_optional :code, :bytes, 1
|
29
|
+
proto3_optional :message, :bytes, 2
|
30
|
+
proto3_optional :metadata, :bytes, 3
|
31
|
+
end
|
32
|
+
add_message "RubyPitaya.NatsResponse" do
|
33
|
+
proto3_optional :data, :bytes, 1
|
34
|
+
proto3_optional :error, :message, 2, "RubyPitaya.NatsError"
|
35
|
+
end
|
36
|
+
add_message "RubyPitaya.NatsBindMsg" do
|
37
|
+
proto3_optional :uid, :bytes, 1
|
38
|
+
proto3_optional :fid, :bytes, 2
|
39
|
+
end
|
40
|
+
add_message "RubyPitaya.NatsPush" do
|
41
|
+
proto3_optional :route, :bytes, 1
|
42
|
+
proto3_optional :uid, :bytes, 2
|
43
|
+
proto3_optional :data, :bytes, 3
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
module RubyPitaya
|
49
|
+
NatsSession = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsSession").msgclass
|
50
|
+
NatsMessage = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsMessage").msgclass
|
51
|
+
NatsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsRequest").msgclass
|
52
|
+
NatsError = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsError").msgclass
|
53
|
+
NatsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsResponse").msgclass
|
54
|
+
NatsBindMsg = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsBindMsg").msgclass
|
55
|
+
NatsPush = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("RubyPitaya.NatsPush").msgclass
|
56
|
+
end
|
data/lib/rubypitaya/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubypitaya
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luciano Prestes Cavalcanti
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -137,33 +137,33 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.7.0
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: activerecord
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 6.1.4.1
|
146
146
|
type: :runtime
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 6.1.4.1
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: google-protobuf
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - '='
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version:
|
159
|
+
version: 3.18.0
|
160
160
|
type: :runtime
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version:
|
166
|
+
version: 3.18.0
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
168
|
name: sinatra-contrib
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -353,6 +353,8 @@ files:
|
|
353
353
|
- "./lib/rubypitaya/core/parameters.rb"
|
354
354
|
- "./lib/rubypitaya/core/path.rb"
|
355
355
|
- "./lib/rubypitaya/core/postman.rb"
|
356
|
+
- "./lib/rubypitaya/core/protos/nats_connector.proto"
|
357
|
+
- "./lib/rubypitaya/core/protos/nats_connector_pb.rb"
|
356
358
|
- "./lib/rubypitaya/core/redis_connector.rb"
|
357
359
|
- "./lib/rubypitaya/core/routes_base.rb"
|
358
360
|
- "./lib/rubypitaya/core/session.rb"
|