rubypitaya 3.15.3 → 3.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubypitaya/app-template/.gitignore +0 -0
- data/lib/rubypitaya/app-template/.gitlab-ci.yml +0 -0
- data/lib/rubypitaya/app-template/.irbrc +0 -0
- data/lib/rubypitaya/app-template/Gemfile +4 -4
- data/lib/rubypitaya/app-template/Gemfile.lock +94 -82
- data/lib/rubypitaya/app-template/Makefile +4 -4
- data/lib/rubypitaya/app-template/Rakefile +0 -0
- data/lib/rubypitaya/app-template/app/app_initializer.rb +3 -0
- data/lib/rubypitaya/app-template/app/bll/player_bll.rb +0 -0
- data/lib/rubypitaya/app-template/app/config/initial_player.json +0 -0
- data/lib/rubypitaya/app-template/app/constants/status_codes.rb +0 -0
- data/lib/rubypitaya/app-template/app/handlers/error_handler.rb +0 -0
- data/lib/rubypitaya/app-template/app/handlers/hello_world_handler.rb +0 -0
- data/lib/rubypitaya/app-template/app/handlers/player_handler.rb +0 -0
- data/lib/rubypitaya/app-template/app/http/hello_world_http.rb +0 -0
- data/lib/rubypitaya/app-template/app/http/views/hello_world.erb +0 -0
- data/lib/rubypitaya/app-template/app/migrations/1606736477_create_player_migration.rb +0 -0
- data/lib/rubypitaya/app-template/app/models/player.rb +0 -0
- data/lib/rubypitaya/app-template/app/models/user.rb +0 -0
- data/lib/rubypitaya/app-template/app/setup/rubypitaya.yml +1 -1
- data/lib/rubypitaya/app-template/config/routes.rb +0 -0
- data/lib/rubypitaya/app-template/docker/dev/Dockerfile +4 -7
- data/lib/rubypitaya/app-template/docker/prod/Dockerfile +8 -8
- data/lib/rubypitaya/app-template/docker/stag/docker-compose.stag.yaml +67 -0
- data/lib/rubypitaya/app-template/docker/stag/update_image +6 -0
- data/lib/rubypitaya/app-template/docker-compose.yml +8 -5
- data/lib/rubypitaya/app-template/features/hello_world.feature +0 -0
- data/lib/rubypitaya/app-template/features/player.feature +0 -0
- data/lib/rubypitaya/app-template/features/step_definitions/player_steps.rb +0 -0
- data/lib/rubypitaya/app-template/features/step_definitions/rubypitaya_steps.rb +0 -0
- data/lib/rubypitaya/app-template/features/support/env.rb +0 -0
- data/lib/rubypitaya/app-template/helm/Chart.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/config-maps/nginx-config.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/deployments/connector.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/deployments/gameserver-nginx.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/deployments/rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/pods/gameserver.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/role-bindings/rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/roles/rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/service-accounts/rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/connector.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/etcd.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/gameserver-nginx.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/gameserver.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/nats.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/redis.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/services/rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/statefulsets/etcd.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/statefulsets/nats.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/templates/statefulsets/redis.yaml +0 -0
- data/lib/rubypitaya/app-template/helm/values.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/README.md +0 -0
- data/lib/rubypitaya/app-template/kubernetes/deployment-connector.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/deployment-rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/gameplay/deployment-nginx.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/gameplay/gameplay-template.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/gameplay/nginx.conf +0 -0
- data/lib/rubypitaya/app-template/kubernetes/gameplay/service-nginx.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/persistent-volume.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/role-rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/rolebinding-rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/service-connector.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/service-etcd.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/service-nats.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/service-postgres.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/service-redis.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/service-rubypitaya.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/statefulset-etcd.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/statefulset-nats.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/statefulset-postgres.yaml +0 -0
- data/lib/rubypitaya/app-template/kubernetes/statefulset-redis.yaml +0 -0
- data/lib/rubypitaya/app-template/plugins.yaml +0 -0
- data/lib/rubypitaya/app-template/spec/hello_world_handler_spec.rb +0 -0
- data/lib/rubypitaya/app-template/spec/player_handler_spec.rb +0 -0
- data/lib/rubypitaya/app-template/spec/redis_service_spec.rb +0 -0
- data/lib/rubypitaya/app-template/spec/spec_helper.rb +0 -0
- data/lib/rubypitaya/core/app/migrations/0000000001_create_user_migration.rb +0 -0
- data/lib/rubypitaya/core/app/models/user.rb +0 -0
- data/lib/rubypitaya/core/app/services/redis_service.rb +0 -0
- data/lib/rubypitaya/core/application_files_importer.rb +0 -0
- data/lib/rubypitaya/core/config.rb +0 -0
- data/lib/rubypitaya/core/config_core.rb +0 -0
- data/lib/rubypitaya/core/config_hash_extension.rb +0 -0
- data/lib/rubypitaya/core/database_config.rb +2 -0
- data/lib/rubypitaya/core/database_connector.rb +0 -0
- data/lib/rubypitaya/core/etcd_connector.rb +16 -6
- data/lib/rubypitaya/core/handler_base.rb +0 -0
- data/lib/rubypitaya/core/handler_router.rb +2 -0
- data/lib/rubypitaya/core/helpers/setup_helper.rb +0 -0
- data/lib/rubypitaya/core/http_base.rb +0 -0
- data/lib/rubypitaya/core/http_routes.rb +1 -1
- data/lib/rubypitaya/core/initializer_base.rb +0 -0
- data/lib/rubypitaya/core/initializer_broadcast.rb +0 -0
- data/lib/rubypitaya/core/initializer_content.rb +3 -2
- data/lib/rubypitaya/core/instance_holder.rb +0 -0
- data/lib/rubypitaya/core/main.rb +62 -60
- data/lib/rubypitaya/core/nats_connector.rb +0 -0
- data/lib/rubypitaya/core/parameters.rb +0 -0
- data/lib/rubypitaya/core/path.rb +0 -0
- data/lib/rubypitaya/core/postman.rb +0 -0
- data/lib/rubypitaya/core/protos/nats_connector.proto +0 -0
- data/lib/rubypitaya/core/protos/nats_connector_pb.rb +0 -0
- data/lib/rubypitaya/core/route_error.rb +0 -0
- data/lib/rubypitaya/core/routes_base.rb +0 -0
- data/lib/rubypitaya/core/service_base.rb +0 -0
- data/lib/rubypitaya/core/service_holder.rb +0 -0
- data/lib/rubypitaya/core/session.rb +0 -0
- data/lib/rubypitaya/core/setup.rb +0 -0
- data/lib/rubypitaya/core/spec-helpers/app_spec_helper.rb +2 -1
- data/lib/rubypitaya/core/spec-helpers/app_spec_helper_class.rb +0 -0
- data/lib/rubypitaya/core/spec-helpers/config_spec_helper.rb +0 -0
- data/lib/rubypitaya/core/spec-helpers/postman_spec_helper.rb +0 -0
- data/lib/rubypitaya/core/spec-helpers/rubypitaya_spec_helper.rb +1 -1
- data/lib/rubypitaya/core/spec-helpers/setup_spec_helper.rb +0 -0
- data/lib/rubypitaya/core/status_codes.rb +0 -0
- data/lib/rubypitaya/core/templates/template_migration.rb.erb +0 -0
- data/lib/rubypitaya/version.rb +1 -1
- data/lib/rubypitaya.rb +0 -0
- metadata +34 -32
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -13,6 +13,7 @@ module RubyPitaya
|
|
13
13
|
'encoding' => 'unicode',
|
14
14
|
'pool' => setup.fetch('rubypitaya.database.pool', 5),
|
15
15
|
'host' => setup['rubypitaya.database.host'],
|
16
|
+
'port' => setup['rubypitaya.database.port'],
|
16
17
|
'user' => setup['rubypitaya.database.user'],
|
17
18
|
'password' => setup['rubypitaya.database.password'],
|
18
19
|
'database' => setup['rubypitaya.database.name'],
|
@@ -33,6 +34,7 @@ module RubyPitaya
|
|
33
34
|
'encoding': config['encoding'],
|
34
35
|
'pool': config['pool'],
|
35
36
|
'host': config['host'],
|
37
|
+
'port': config['port'],
|
36
38
|
'user': config['user'],
|
37
39
|
'password': config['password'],
|
38
40
|
'database': config['database'],
|
File without changes
|
@@ -6,7 +6,7 @@ module RubyPitaya
|
|
6
6
|
class EtcdConnector
|
7
7
|
|
8
8
|
def initialize(server_uuid, desktop_name, server_name, etcd_prefix,
|
9
|
-
etcd_address, allow_reconnect, lease_seconds)
|
9
|
+
etcd_address, allow_reconnect, lease_seconds, log)
|
10
10
|
@server_uuid = server_uuid
|
11
11
|
@server_name = server_name
|
12
12
|
@desktop_name = desktop_name
|
@@ -14,6 +14,7 @@ module RubyPitaya
|
|
14
14
|
@etcd_address = etcd_address
|
15
15
|
@allow_reconnect = allow_reconnect
|
16
16
|
@lease_seconds = lease_seconds
|
17
|
+
@log = log
|
17
18
|
|
18
19
|
@renew_connection_seconds = lease_seconds / 2.0
|
19
20
|
|
@@ -27,7 +28,7 @@ module RubyPitaya
|
|
27
28
|
connection_value = get_connection_value
|
28
29
|
|
29
30
|
@connection = Etcdv3.new(endpoints: @etcd_address,
|
30
|
-
|
31
|
+
allow_reconnect: @allow_reconnect)
|
31
32
|
|
32
33
|
@lease = @connection.lease_grant(@lease_seconds)
|
33
34
|
|
@@ -40,6 +41,7 @@ module RubyPitaya
|
|
40
41
|
end
|
41
42
|
|
42
43
|
def disconnect
|
44
|
+
stop_renew_connection
|
43
45
|
@connection.del(get_connection_key)
|
44
46
|
end
|
45
47
|
|
@@ -60,15 +62,23 @@ module RubyPitaya
|
|
60
62
|
loop do
|
61
63
|
sleep(@renew_connection_seconds)
|
62
64
|
|
63
|
-
|
64
|
-
|
65
|
-
|
65
|
+
begin
|
66
|
+
@lease = @connection.lease_keep_alive_once(@lease.ID)
|
67
|
+
|
68
|
+
if @lease.TTL == 0
|
69
|
+
@lease = @connection.lease_grant(@lease_seconds)
|
70
|
+
@connection.put(@renew_connection_key, @renew_connection_value, lease: @lease.ID)
|
71
|
+
end
|
72
|
+
|
73
|
+
rescue Exception => error
|
74
|
+
@log.error "ETCD RENEW ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
|
75
|
+
end
|
66
76
|
end
|
67
77
|
end
|
68
78
|
end
|
69
79
|
|
70
80
|
def stop_renew_connection
|
71
|
-
@renew_connection_thread.exit unless @renew_connection_thread.nil?
|
81
|
+
@renew_connection_thread.exit.join unless @renew_connection_thread.nil?
|
72
82
|
end
|
73
83
|
|
74
84
|
def get_server_data
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,13 +2,14 @@ module RubyPitaya
|
|
2
2
|
|
3
3
|
class InitializerContent
|
4
4
|
|
5
|
-
attr_reader :log, :services, :setup, :config
|
5
|
+
attr_reader :log, :services, :setup, :config, :handlers
|
6
6
|
|
7
|
-
def initialize(log, services, setup, config)
|
7
|
+
def initialize(log, services, setup, config, handlers)
|
8
8
|
@log = log
|
9
9
|
@services = services
|
10
10
|
@setup = setup
|
11
11
|
@config = config
|
12
|
+
@handlers = handlers
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
File without changes
|
data/lib/rubypitaya/core/main.rb
CHANGED
@@ -50,12 +50,12 @@ module RubyPitaya
|
|
50
50
|
|
51
51
|
@etcd_prefix = @setup['rubypitaya.etcd.prefix']
|
52
52
|
@etcd_address = @setup['rubypitaya.etcd.url']
|
53
|
-
@etcd_lease_seconds = @setup['rubypitaya.etcd.leaseSeconds']
|
53
|
+
@etcd_lease_seconds = @setup['rubypitaya.etcd.leaseSeconds']
|
54
54
|
@allow_reconnect = false
|
55
55
|
@etcd_connector = EtcdConnector.new(@service_uuid, @desktop_name,
|
56
56
|
@server_name, @etcd_prefix,
|
57
57
|
@etcd_address, @allow_reconnect,
|
58
|
-
@etcd_lease_seconds)
|
58
|
+
@etcd_lease_seconds, @log)
|
59
59
|
@etcd_connector.connect
|
60
60
|
|
61
61
|
@nats_address = @setup['rubypitaya.nats.url']
|
@@ -72,15 +72,16 @@ module RubyPitaya
|
|
72
72
|
|
73
73
|
@services = ServiceHolder.new
|
74
74
|
|
75
|
+
@handler_router = HandlerRouter.new(@is_cheats_enabled)
|
76
|
+
|
75
77
|
@initializer_content = InitializerContent.new(@log,
|
76
78
|
@services,
|
77
79
|
@setup,
|
78
|
-
@config
|
80
|
+
@config,
|
81
|
+
@handler_router.handlers)
|
79
82
|
@initializer_broadcast = InitializerBroadcast.new
|
80
83
|
@initializer_broadcast.run(@initializer_content)
|
81
84
|
|
82
|
-
@handler_router = HandlerRouter.new(@is_cheats_enabled)
|
83
|
-
|
84
85
|
connect_services
|
85
86
|
|
86
87
|
run_http
|
@@ -148,63 +149,64 @@ module RubyPitaya
|
|
148
149
|
end
|
149
150
|
|
150
151
|
def run_nats_connection
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
152
|
+
loop do
|
153
|
+
@nats_connector.connect do |request|
|
154
|
+
start_time_seconds = Time.now.to_f
|
155
|
+
|
156
|
+
message_route = request[:msg][:route]
|
157
|
+
message_data = request[:msg][:data]
|
158
|
+
message_json = JSON.parse(message_data) if !message_data.nil? && !message_data.empty?
|
159
|
+
|
160
|
+
params = Parameters.new(message_json || {})
|
161
|
+
|
162
|
+
session_id = request[:session][:id]
|
163
|
+
session_uid = request[:session].fetch(:uid, '')
|
164
|
+
session_data = request[:session][:data]
|
165
|
+
session_data = JSON.parse(session_data, symbolize_names: true)
|
166
|
+
frontend_id = request[:frontendID]
|
167
|
+
metadata = request[:metadata]
|
168
|
+
metadata = JSON.parse(metadata, symbolize_names: true)
|
169
|
+
|
170
|
+
@session.update(session_id, session_uid, session_data, metadata,
|
171
|
+
frontend_id)
|
172
|
+
|
173
|
+
handler_name, action_name = message_route.scan(/\A\w+\.(\w+)\.(\w+)\z/)[0]
|
174
|
+
|
175
|
+
@log.info "request -> route: #{message_route}"
|
176
|
+
@log.info " -> data: #{message_data}"
|
177
|
+
|
178
|
+
@config.clear_cache
|
179
|
+
|
180
|
+
response = {}
|
181
|
+
|
182
|
+
begin
|
183
|
+
response = @handler_router.call(handler_name, action_name, @session,
|
184
|
+
@postman, @services, @setup, @config,
|
185
|
+
@log, params)
|
186
|
+
rescue RouteError => error
|
187
|
+
@log.error "ROUTE ERROR: #{error.code} | #{error.class} | #{error.message} \n #{error.backtrace.join("\n")}"
|
188
|
+
response = {
|
189
|
+
code: error.code,
|
190
|
+
message: error.message
|
191
|
+
}
|
192
|
+
rescue Exception => error
|
193
|
+
@log.error "INTERNAL ERROR: #{error.class} | #{error.message} \n #{error.backtrace.join("\n")}"
|
194
|
+
response = {
|
195
|
+
code: StatusCodes::CODE_INTERNAL_ERROR,
|
196
|
+
message: StatusCodes::MESSAGE_INTERNAL_ERROR,
|
197
|
+
}
|
198
|
+
end
|
199
|
+
|
200
|
+
response_json = JSON.generate(response)
|
201
|
+
delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
|
202
|
+
|
203
|
+
@log.info "response [#{delta_time_seconds}ms] -> #{response_json}"
|
204
|
+
|
205
|
+
response_json
|
196
206
|
end
|
197
|
-
|
198
|
-
|
199
|
-
delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
|
200
|
-
|
201
|
-
@log.info "response [#{delta_time_seconds}ms] -> #{response_json}"
|
202
|
-
|
203
|
-
response_json
|
207
|
+
rescue Exception => error
|
208
|
+
@log.error "INTERNAL ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
|
204
209
|
end
|
205
|
-
rescue Exception => error
|
206
|
-
@log.error "INTERNAL ERROR: #{error.class} | #{error.message}} \n #{error.backtrace.join("\n")}"
|
207
|
-
run_nats_connection
|
208
210
|
end
|
209
211
|
end
|
210
212
|
end
|
File without changes
|
File without changes
|
data/lib/rubypitaya/core/path.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -27,7 +27,8 @@ module RubyPitaya
|
|
27
27
|
@@initializer_content = InitializerContent.new(@@log,
|
28
28
|
@@services,
|
29
29
|
@@setup,
|
30
|
-
@@config
|
30
|
+
@@config,
|
31
|
+
@@handler_router.handlers)
|
31
32
|
@@initializer_broadcast = InitializerBroadcast.new
|
32
33
|
@@initializer_broadcast.run(@@initializer_content)
|
33
34
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/rubypitaya/version.rb
CHANGED
data/lib/rubypitaya.rb
CHANGED
File without changes
|