rubypitaya 2.26.3 → 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 +5 -5
- data/lib/rubypitaya/app-template/Gemfile.lock +49 -57
- data/lib/rubypitaya/app-template/Makefile +1 -1
- data/lib/rubypitaya/app-template/app/app_initializer.rb +1 -11
- data/lib/rubypitaya/app-template/app/migrations/1606736477_create_player_migration.rb +1 -1
- data/lib/rubypitaya/app-template/docker/dev/Dockerfile +1 -1
- data/lib/rubypitaya/app-template/docker/prod/Dockerfile +2 -2
- data/lib/rubypitaya/app-template/features/step_definitions/rubypitaya_steps.rb +2 -0
- data/lib/rubypitaya/app-template/spec/player_handler_spec.rb +1 -1
- data/lib/rubypitaya/core/handler_base.rb +11 -4
- data/lib/rubypitaya/core/handler_router.rb +3 -3
- data/lib/rubypitaya/core/initializer_content.rb +2 -3
- data/lib/rubypitaya/core/main.rb +4 -5
- 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/core/session.rb +8 -0
- data/lib/rubypitaya/core/spec-helpers/handler_spec_helper.rb +2 -8
- data/lib/rubypitaya/core/spec-helpers/rubypitaya_spec_helper.rb +4 -0
- data/lib/rubypitaya/version.rb +1 -1
- data/lib/rubypitaya.rb +1 -1
- metadata +32 -16
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
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
source "https://rubygems.org"
|
|
2
2
|
|
|
3
|
-
gem 'rubypitaya', '
|
|
3
|
+
gem 'rubypitaya', '3.0.1'
|
|
4
4
|
|
|
5
5
|
group :development do
|
|
6
|
-
gem 'pry', '0.14.
|
|
7
|
-
gem 'bundler', '2.
|
|
6
|
+
gem 'pry', '0.14.1'
|
|
7
|
+
gem 'bundler', '2.2.22'
|
|
8
8
|
gem 'rspec', '3.10.0'
|
|
9
|
-
gem 'listen', '3.
|
|
10
|
-
gem 'cucumber', '
|
|
9
|
+
gem 'listen', '3.7.0'
|
|
10
|
+
gem 'cucumber', '7.0.0'
|
|
11
11
|
end
|
|
@@ -16,55 +16,57 @@ GEM
|
|
|
16
16
|
builder (3.2.4)
|
|
17
17
|
coderay (1.1.3)
|
|
18
18
|
concurrent-ruby (1.1.9)
|
|
19
|
-
cucumber (
|
|
19
|
+
cucumber (7.0.0)
|
|
20
20
|
builder (~> 3.2, >= 3.2.4)
|
|
21
|
-
cucumber-core (~>
|
|
22
|
-
cucumber-create-meta (~>
|
|
23
|
-
cucumber-cucumber-expressions (~>
|
|
24
|
-
cucumber-gherkin (~>
|
|
25
|
-
cucumber-html-formatter (~>
|
|
26
|
-
cucumber-messages (~>
|
|
27
|
-
cucumber-wire (~>
|
|
21
|
+
cucumber-core (~> 10.0, >= 10.0.1)
|
|
22
|
+
cucumber-create-meta (~> 6.0, >= 6.0.1)
|
|
23
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.1)
|
|
24
|
+
cucumber-gherkin (~> 20.0, >= 20.0.1)
|
|
25
|
+
cucumber-html-formatter (~> 16.0, >= 16.0.1)
|
|
26
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
27
|
+
cucumber-wire (~> 6.0, >= 6.0.1)
|
|
28
28
|
diff-lcs (~> 1.4, >= 1.4.4)
|
|
29
|
+
mime-types (~> 3.3, >= 3.3.1)
|
|
29
30
|
multi_test (~> 0.1, >= 0.1.2)
|
|
30
|
-
sys-uname (~> 1.2, >= 1.2.
|
|
31
|
-
cucumber-core (
|
|
32
|
-
cucumber-gherkin (~>
|
|
33
|
-
cucumber-messages (~>
|
|
34
|
-
cucumber-tag-expressions (~>
|
|
35
|
-
cucumber-create-meta (
|
|
36
|
-
cucumber-messages (~>
|
|
37
|
-
sys-uname (~> 1.2, >= 1.2.
|
|
38
|
-
cucumber-cucumber-expressions (
|
|
39
|
-
cucumber-gherkin (
|
|
40
|
-
cucumber-messages (~>
|
|
41
|
-
cucumber-html-formatter (
|
|
42
|
-
cucumber-messages (~>
|
|
43
|
-
cucumber-messages (
|
|
44
|
-
|
|
45
|
-
cucumber-
|
|
46
|
-
|
|
47
|
-
cucumber-
|
|
48
|
-
cucumber-
|
|
49
|
-
cucumber-messages (~> 13.0, >= 13.0.1)
|
|
31
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
|
32
|
+
cucumber-core (10.0.1)
|
|
33
|
+
cucumber-gherkin (~> 20.0, >= 20.0.1)
|
|
34
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
35
|
+
cucumber-tag-expressions (~> 3.0, >= 3.0.1)
|
|
36
|
+
cucumber-create-meta (6.0.1)
|
|
37
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
38
|
+
sys-uname (~> 1.2, >= 1.2.2)
|
|
39
|
+
cucumber-cucumber-expressions (12.1.3)
|
|
40
|
+
cucumber-gherkin (20.0.1)
|
|
41
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
42
|
+
cucumber-html-formatter (16.0.1)
|
|
43
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
44
|
+
cucumber-messages (17.1.1)
|
|
45
|
+
cucumber-tag-expressions (3.0.1)
|
|
46
|
+
cucumber-wire (6.1.1)
|
|
47
|
+
cucumber-core (~> 10.0, >= 10.0.1)
|
|
48
|
+
cucumber-cucumber-expressions (~> 12.1, >= 12.1.2)
|
|
49
|
+
cucumber-messages (~> 17.0, >= 17.0.1)
|
|
50
50
|
diff-lcs (1.4.4)
|
|
51
|
-
etcdv3 (0.11.
|
|
51
|
+
etcdv3 (0.11.4)
|
|
52
52
|
grpc (~> 1.17)
|
|
53
53
|
eventmachine (1.2.7)
|
|
54
54
|
ffi (1.15.4)
|
|
55
|
-
google-protobuf (3.
|
|
56
|
-
googleapis-common-protos-types (1.
|
|
55
|
+
google-protobuf (3.18.0-x86_64-linux)
|
|
56
|
+
googleapis-common-protos-types (1.2.0)
|
|
57
57
|
google-protobuf (~> 3.14)
|
|
58
|
-
grpc (1.
|
|
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)
|
|
62
62
|
concurrent-ruby (~> 1.0)
|
|
63
|
-
listen (3.
|
|
63
|
+
listen (3.7.0)
|
|
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
|
-
|
|
67
|
+
mime-types (3.3.1)
|
|
68
|
+
mime-types-data (~> 3.2015)
|
|
69
|
+
mime-types-data (3.2021.0901)
|
|
68
70
|
minitest (5.14.4)
|
|
69
71
|
mongo (2.15.0)
|
|
70
72
|
bson (>= 4.8.2, < 5.0.0)
|
|
@@ -76,17 +78,7 @@ GEM
|
|
|
76
78
|
eventmachine (~> 1.2, >= 1.2)
|
|
77
79
|
ostruct (0.4.0)
|
|
78
80
|
pg (1.2.3)
|
|
79
|
-
|
|
80
|
-
activesupport (>= 3.2)
|
|
81
|
-
middleware
|
|
82
|
-
thor
|
|
83
|
-
thread_safe
|
|
84
|
-
protobuf-cucumber (3.10.8)
|
|
85
|
-
activesupport (>= 3.2)
|
|
86
|
-
middleware
|
|
87
|
-
thor
|
|
88
|
-
thread_safe
|
|
89
|
-
pry (0.14.0)
|
|
81
|
+
pry (0.14.1)
|
|
90
82
|
coderay (~> 1.1)
|
|
91
83
|
method_source (~> 1.0)
|
|
92
84
|
rack (2.2.3)
|
|
@@ -111,18 +103,19 @@ GEM
|
|
|
111
103
|
rspec-support (~> 3.10.0)
|
|
112
104
|
rspec-support (3.10.2)
|
|
113
105
|
ruby2_keywords (0.0.5)
|
|
114
|
-
rubypitaya (
|
|
106
|
+
rubypitaya (3.0.1)
|
|
115
107
|
activerecord (= 6.1.4.1)
|
|
116
|
-
etcdv3 (= 0.11.
|
|
108
|
+
etcdv3 (= 0.11.4)
|
|
109
|
+
google-protobuf (= 3.18.0)
|
|
117
110
|
mongo (= 2.15.0)
|
|
118
111
|
nats (= 0.11.0)
|
|
119
112
|
ostruct (= 0.4.0)
|
|
120
113
|
pg (= 1.2.3)
|
|
121
|
-
protobuf (= 3.10.4)
|
|
122
114
|
rake (= 13.0.6)
|
|
123
115
|
redis (= 4.4.0)
|
|
124
116
|
sinatra (= 2.1.0)
|
|
125
117
|
sinatra-contrib (= 2.1.0)
|
|
118
|
+
webrick (= 1.7.0)
|
|
126
119
|
sinatra (2.1.0)
|
|
127
120
|
mustermann (~> 1.0)
|
|
128
121
|
rack (~> 2.2)
|
|
@@ -136,23 +129,22 @@ GEM
|
|
|
136
129
|
tilt (~> 2.0)
|
|
137
130
|
sys-uname (1.2.2)
|
|
138
131
|
ffi (~> 1.1)
|
|
139
|
-
thor (1.1.0)
|
|
140
|
-
thread_safe (0.3.6)
|
|
141
132
|
tilt (2.0.10)
|
|
142
133
|
tzinfo (2.0.4)
|
|
143
134
|
concurrent-ruby (~> 1.0)
|
|
135
|
+
webrick (1.7.0)
|
|
144
136
|
zeitwerk (2.4.2)
|
|
145
137
|
|
|
146
138
|
PLATFORMS
|
|
147
|
-
|
|
139
|
+
x86_64-linux
|
|
148
140
|
|
|
149
141
|
DEPENDENCIES
|
|
150
|
-
bundler (= 2.
|
|
151
|
-
cucumber (=
|
|
152
|
-
listen (= 3.
|
|
153
|
-
pry (= 0.14.
|
|
142
|
+
bundler (= 2.2.22)
|
|
143
|
+
cucumber (= 7.0.0)
|
|
144
|
+
listen (= 3.7.0)
|
|
145
|
+
pry (= 0.14.1)
|
|
154
146
|
rspec (= 3.10.0)
|
|
155
|
-
rubypitaya (=
|
|
147
|
+
rubypitaya (= 3.0.1)
|
|
156
148
|
|
|
157
149
|
BUNDLED WITH
|
|
158
|
-
2.
|
|
150
|
+
2.2.22
|
|
@@ -41,7 +41,7 @@ test-cucumber:
|
|
|
41
41
|
## Update gems dependencies on Gemfile.lock
|
|
42
42
|
update-dependencies:
|
|
43
43
|
@rm -f Gemfile.lock
|
|
44
|
-
@docker run --rm -v "$(PWD)":/usr/src/app -w /usr/src/app ruby:
|
|
44
|
+
@docker run --rm -v "$(PWD)":/usr/src/app -w /usr/src/app ruby:3.0.2 bundle install
|
|
45
45
|
|
|
46
46
|
## + Improve metagame
|
|
47
47
|
|
|
@@ -3,14 +3,6 @@ class AppInitializer < RubyPitaya::InitializerBase
|
|
|
3
3
|
# method: run
|
|
4
4
|
# parameter: initializer_content
|
|
5
5
|
# attributes:
|
|
6
|
-
# - bll
|
|
7
|
-
# - class: RubyPitaya::InstanceHolder
|
|
8
|
-
# - link: https://gitlab.com/LucianoPC/ruby-pitaya/-/blob/master/lib/rubypitaya/core/instance_holder.rb
|
|
9
|
-
# - methods:
|
|
10
|
-
# - add_instance(key, instance)
|
|
11
|
-
# - add any instance to any key
|
|
12
|
-
# - [](key)
|
|
13
|
-
# - get instance by key
|
|
14
6
|
# - redis
|
|
15
7
|
# - link: https://github.com/redis/redis-rb/
|
|
16
8
|
# - mongo
|
|
@@ -36,11 +28,9 @@ class AppInitializer < RubyPitaya::InitializerBase
|
|
|
36
28
|
# - log information
|
|
37
29
|
|
|
38
30
|
def run(initializer_content)
|
|
39
|
-
bll = initializer_content.bll
|
|
40
|
-
|
|
41
31
|
playerBll = PlayerBLL.new
|
|
42
32
|
|
|
43
|
-
bll.add_instance(:player, playerBll)
|
|
33
|
+
PlayerHandler.bll.add_instance(:player, playerBll)
|
|
44
34
|
end
|
|
45
35
|
|
|
46
36
|
def self.path
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
FROM ruby:
|
|
1
|
+
FROM ruby:3.0.2-slim as builder
|
|
2
2
|
|
|
3
3
|
RUN apt update && \
|
|
4
4
|
apt install -y --no-install-recommends \
|
|
@@ -17,7 +17,7 @@ RUN bundle config --global jobs 4 && \
|
|
|
17
17
|
|
|
18
18
|
# RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
|
|
19
19
|
|
|
20
|
-
FROM ruby:
|
|
20
|
+
FROM ruby:3.0.2-slim
|
|
21
21
|
|
|
22
22
|
ENV LANG=C.UTF-8
|
|
23
23
|
ENV LC_ALL=C.UTF-8
|
|
@@ -12,6 +12,8 @@ Given(/^[Ss]erver should response the following json[:]*$/) do |expected_json|
|
|
|
12
12
|
expected_json = JSON.generate(JSON.parse(expected_json.strip))
|
|
13
13
|
response_json = JSON.generate(@handler_helper.response)
|
|
14
14
|
|
|
15
|
+
puts JSON.pretty_generate(@handler_helper.response) if expected_json != response_json
|
|
16
|
+
|
|
15
17
|
expect(response_json).to eq(expected_json)
|
|
16
18
|
end
|
|
17
19
|
|
|
@@ -42,7 +42,7 @@ RSpec.describe 'PlayerHandler', type: :request do
|
|
|
42
42
|
request("rubypitaya.playerHandler.getInfo")
|
|
43
43
|
|
|
44
44
|
expect(response[:code]).to eq(RubyPitaya::StatusCodes::CODE_NOT_AUTHENTICATED)
|
|
45
|
-
expect(response[:
|
|
45
|
+
expect(response[:message]).to eq('Not authenticated')
|
|
46
46
|
end
|
|
47
47
|
end
|
|
48
48
|
end
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
require 'rubypitaya/core/instance_holder'
|
|
2
|
+
|
|
1
3
|
module RubyPitaya
|
|
2
4
|
|
|
3
5
|
class HandlerBase
|
|
4
6
|
|
|
5
7
|
class_attribute :non_authenticated_routes, default: []
|
|
8
|
+
class_attribute :handler_bll, default: nil, instance_reader: false, instance_writer: false, instance_accessor: false, instance_predicate: false
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
attr_reader :bll, :log, :redis, :setup, :config, :params, :session, :postman
|
|
8
11
|
|
|
9
12
|
def initialize
|
|
10
|
-
@bll = nil
|
|
11
13
|
@log = nil
|
|
12
14
|
@redis = nil
|
|
13
15
|
@setup = nil
|
|
@@ -15,10 +17,11 @@ module RubyPitaya
|
|
|
15
17
|
@params = nil
|
|
16
18
|
@session = nil
|
|
17
19
|
@postman = nil
|
|
20
|
+
|
|
21
|
+
@bll = self.class.bll
|
|
18
22
|
end
|
|
19
23
|
|
|
20
|
-
def set_attributes(
|
|
21
|
-
@bll = bll
|
|
24
|
+
def set_attributes(log, redis, mongo, setup, config, params, session, postman)
|
|
22
25
|
@log = log
|
|
23
26
|
@redis = redis
|
|
24
27
|
@mongo = mongo
|
|
@@ -29,6 +32,10 @@ module RubyPitaya
|
|
|
29
32
|
@postman = postman
|
|
30
33
|
end
|
|
31
34
|
|
|
35
|
+
def self.bll
|
|
36
|
+
self.handler_bll ||= InstanceHolder.new
|
|
37
|
+
end
|
|
38
|
+
|
|
32
39
|
def self.non_authenticated_actions(*action_names)
|
|
33
40
|
self.non_authenticated_routes = action_names.map(&:to_s)
|
|
34
41
|
end
|
|
@@ -57,7 +57,7 @@ module RubyPitaya
|
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def call(handler_name, action_name, session, postman, redis, mongo, setup,
|
|
60
|
-
config,
|
|
60
|
+
config, log, params)
|
|
61
61
|
unless @handler_name_map.include?(handler_name)
|
|
62
62
|
return {
|
|
63
63
|
code: StatusCodes::CODE_HANDLER_NOT_FOUND,
|
|
@@ -75,11 +75,11 @@ module RubyPitaya
|
|
|
75
75
|
handler = @handler_name_map[handler_name]
|
|
76
76
|
|
|
77
77
|
if !handler.class.authenticated_action_name?(action_name)
|
|
78
|
-
handler.set_attributes(
|
|
78
|
+
handler.set_attributes(log, redis, mongo, setup, config, params, session, postman)
|
|
79
79
|
handler.send(action_name)
|
|
80
80
|
else
|
|
81
81
|
if session.authenticated?
|
|
82
|
-
handler.set_attributes(
|
|
82
|
+
handler.set_attributes(log, redis, mongo, setup, config, params, session, postman)
|
|
83
83
|
handler.send(action_name)
|
|
84
84
|
else
|
|
85
85
|
return {
|
|
@@ -2,10 +2,9 @@ module RubyPitaya
|
|
|
2
2
|
|
|
3
3
|
class InitializerContent
|
|
4
4
|
|
|
5
|
-
attr_reader :
|
|
5
|
+
attr_reader :log, :redis, :mongo, :setup, :config
|
|
6
6
|
|
|
7
|
-
def initialize(
|
|
8
|
-
@bll = bll
|
|
7
|
+
def initialize(log, redis, mongo, setup, config)
|
|
9
8
|
@log = log
|
|
10
9
|
@mongo = mongo
|
|
11
10
|
@redis = redis
|
data/lib/rubypitaya/core/main.rb
CHANGED
|
@@ -87,8 +87,7 @@ module RubyPitaya
|
|
|
87
87
|
|
|
88
88
|
@bll = InstanceHolder.new
|
|
89
89
|
|
|
90
|
-
@initializer_content = InitializerContent.new(@
|
|
91
|
-
@log,
|
|
90
|
+
@initializer_content = InitializerContent.new(@log,
|
|
92
91
|
@redis_connector.redis,
|
|
93
92
|
@mongo_connector.mongo,
|
|
94
93
|
@setup,
|
|
@@ -166,10 +165,10 @@ module RubyPitaya
|
|
|
166
165
|
session_id = request[:session][:id]
|
|
167
166
|
session_uid = request[:session].fetch(:uid, '')
|
|
168
167
|
session_data = request[:session][:data]
|
|
169
|
-
session_data = JSON.parse(session_data, symbolize_names: true)
|
|
168
|
+
session_data = JSON.parse(session_data, symbolize_names: true)
|
|
170
169
|
frontend_id = request[:frontendID]
|
|
171
170
|
metadata = request[:metadata]
|
|
172
|
-
metadata = JSON.parse(metadata, symbolize_names: true)
|
|
171
|
+
metadata = JSON.parse(metadata, symbolize_names: true)
|
|
173
172
|
|
|
174
173
|
@session.update(session_id, session_uid, session_data, metadata,
|
|
175
174
|
frontend_id)
|
|
@@ -185,7 +184,7 @@ module RubyPitaya
|
|
|
185
184
|
response = @handler_router.call(handler_name, action_name, @session,
|
|
186
185
|
@postman, @redis_connector.redis,
|
|
187
186
|
@mongo_connector.mongo, @setup, @config,
|
|
188
|
-
@
|
|
187
|
+
@log, params)
|
|
189
188
|
|
|
190
189
|
delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
|
|
191
190
|
|
|
@@ -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
|
|
@@ -12,7 +12,6 @@ module RubyPitaya
|
|
|
12
12
|
def initialize(context)
|
|
13
13
|
@@context = context
|
|
14
14
|
|
|
15
|
-
@@bll = InstanceHolder.new
|
|
16
15
|
@@log = Logger.new('/dev/null')
|
|
17
16
|
@@setup = SetupSpecHelper.new
|
|
18
17
|
@@config = ConfigSpecHelper.new
|
|
@@ -27,8 +26,7 @@ module RubyPitaya
|
|
|
27
26
|
@@handler_router ||= HandlerRouter.new()
|
|
28
27
|
|
|
29
28
|
|
|
30
|
-
@@initializer_content = InitializerContent.new(@@
|
|
31
|
-
@@log,
|
|
29
|
+
@@initializer_content = InitializerContent.new(@@log,
|
|
32
30
|
@@redis_connector.redis,
|
|
33
31
|
@@mongo_connector.mongo,
|
|
34
32
|
@@setup,
|
|
@@ -43,7 +41,7 @@ module RubyPitaya
|
|
|
43
41
|
@@response = @@handler_router.call(handler_name, action_name, @@session,
|
|
44
42
|
@@postman, @@redis_connector.redis,
|
|
45
43
|
@@mongo_connector.mongo, @@setup,
|
|
46
|
-
@@config, @@
|
|
44
|
+
@@config, @@log, params)
|
|
47
45
|
end
|
|
48
46
|
|
|
49
47
|
def response
|
|
@@ -74,10 +72,6 @@ module RubyPitaya
|
|
|
74
72
|
@@setup.add(*keys, value)
|
|
75
73
|
end
|
|
76
74
|
|
|
77
|
-
def bll
|
|
78
|
-
@@bll
|
|
79
|
-
end
|
|
80
|
-
|
|
81
75
|
def log
|
|
82
76
|
@@log
|
|
83
77
|
end
|
data/lib/rubypitaya/version.rb
CHANGED
data/lib/rubypitaya.rb
CHANGED
|
@@ -66,7 +66,7 @@ module RubyPitaya
|
|
|
66
66
|
|
|
67
67
|
plugin_migrations_files.each_with_index do |migration_file, i|
|
|
68
68
|
migration_timestamp = base_migration_timestamp + i
|
|
69
|
-
new_file = migration_file.gsub(/^(.+\/
|
|
69
|
+
new_file = migration_file.gsub(/^(.+\/migrations\/)\d+(_.+)$/, "\\1#{migration_timestamp}\\2")
|
|
70
70
|
|
|
71
71
|
File.rename(migration_file, new_file)
|
|
72
72
|
end
|
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:
|
|
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
|
|
@@ -86,56 +86,56 @@ dependencies:
|
|
|
86
86
|
requirements:
|
|
87
87
|
- - '='
|
|
88
88
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: 0.11.
|
|
89
|
+
version: 0.11.4
|
|
90
90
|
type: :runtime
|
|
91
91
|
prerelease: false
|
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
93
|
requirements:
|
|
94
94
|
- - '='
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: 0.11.
|
|
96
|
+
version: 0.11.4
|
|
97
97
|
- !ruby/object:Gem::Dependency
|
|
98
|
-
name:
|
|
98
|
+
name: ostruct
|
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
|
100
100
|
requirements:
|
|
101
101
|
- - '='
|
|
102
102
|
- !ruby/object:Gem::Version
|
|
103
|
-
version:
|
|
103
|
+
version: 0.4.0
|
|
104
104
|
type: :runtime
|
|
105
105
|
prerelease: false
|
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
|
108
108
|
- - '='
|
|
109
109
|
- !ruby/object:Gem::Version
|
|
110
|
-
version:
|
|
110
|
+
version: 0.4.0
|
|
111
111
|
- !ruby/object:Gem::Dependency
|
|
112
|
-
name:
|
|
112
|
+
name: sinatra
|
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
|
114
114
|
requirements:
|
|
115
115
|
- - '='
|
|
116
116
|
- !ruby/object:Gem::Version
|
|
117
|
-
version:
|
|
117
|
+
version: 2.1.0
|
|
118
118
|
type: :runtime
|
|
119
119
|
prerelease: false
|
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
|
121
121
|
requirements:
|
|
122
122
|
- - '='
|
|
123
123
|
- !ruby/object:Gem::Version
|
|
124
|
-
version:
|
|
124
|
+
version: 2.1.0
|
|
125
125
|
- !ruby/object:Gem::Dependency
|
|
126
|
-
name:
|
|
126
|
+
name: webrick
|
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
|
128
128
|
requirements:
|
|
129
129
|
- - '='
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
|
-
version:
|
|
131
|
+
version: 1.7.0
|
|
132
132
|
type: :runtime
|
|
133
133
|
prerelease: false
|
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
|
135
135
|
requirements:
|
|
136
136
|
- - '='
|
|
137
137
|
- !ruby/object:Gem::Version
|
|
138
|
-
version:
|
|
138
|
+
version: 1.7.0
|
|
139
139
|
- !ruby/object:Gem::Dependency
|
|
140
140
|
name: activerecord
|
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -150,6 +150,20 @@ dependencies:
|
|
|
150
150
|
- - '='
|
|
151
151
|
- !ruby/object:Gem::Version
|
|
152
152
|
version: 6.1.4.1
|
|
153
|
+
- !ruby/object:Gem::Dependency
|
|
154
|
+
name: google-protobuf
|
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
|
156
|
+
requirements:
|
|
157
|
+
- - '='
|
|
158
|
+
- !ruby/object:Gem::Version
|
|
159
|
+
version: 3.18.0
|
|
160
|
+
type: :runtime
|
|
161
|
+
prerelease: false
|
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
163
|
+
requirements:
|
|
164
|
+
- - '='
|
|
165
|
+
- !ruby/object:Gem::Version
|
|
166
|
+
version: 3.18.0
|
|
153
167
|
- !ruby/object:Gem::Dependency
|
|
154
168
|
name: sinatra-contrib
|
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -184,14 +198,14 @@ dependencies:
|
|
|
184
198
|
requirements:
|
|
185
199
|
- - '='
|
|
186
200
|
- !ruby/object:Gem::Version
|
|
187
|
-
version: 2.
|
|
201
|
+
version: 2.2.22
|
|
188
202
|
type: :development
|
|
189
203
|
prerelease: false
|
|
190
204
|
version_requirements: !ruby/object:Gem::Requirement
|
|
191
205
|
requirements:
|
|
192
206
|
- - '='
|
|
193
207
|
- !ruby/object:Gem::Version
|
|
194
|
-
version: 2.
|
|
208
|
+
version: 2.2.22
|
|
195
209
|
- !ruby/object:Gem::Dependency
|
|
196
210
|
name: rspec
|
|
197
211
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -339,6 +353,8 @@ files:
|
|
|
339
353
|
- "./lib/rubypitaya/core/parameters.rb"
|
|
340
354
|
- "./lib/rubypitaya/core/path.rb"
|
|
341
355
|
- "./lib/rubypitaya/core/postman.rb"
|
|
356
|
+
- "./lib/rubypitaya/core/protos/nats_connector.proto"
|
|
357
|
+
- "./lib/rubypitaya/core/protos/nats_connector_pb.rb"
|
|
342
358
|
- "./lib/rubypitaya/core/redis_connector.rb"
|
|
343
359
|
- "./lib/rubypitaya/core/routes_base.rb"
|
|
344
360
|
- "./lib/rubypitaya/core/session.rb"
|
|
@@ -372,7 +388,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
372
388
|
- !ruby/object:Gem::Version
|
|
373
389
|
version: '0'
|
|
374
390
|
requirements: []
|
|
375
|
-
rubygems_version: 3.
|
|
391
|
+
rubygems_version: 3.2.22
|
|
376
392
|
signing_key:
|
|
377
393
|
specification_version: 4
|
|
378
394
|
summary: Create servers with pitaya
|