rubypitaya 2.21.0 → 2.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/rubypitaya +4 -3
- data/lib/rubypitaya.rb +15 -4
- data/lib/rubypitaya/app-template/Gemfile +1 -1
- data/lib/rubypitaya/app-template/Gemfile.lock +13 -9
- data/lib/rubypitaya/app-template/Makefile +3 -3
- data/lib/rubypitaya/app-template/app/app_initializer.rb +3 -0
- data/lib/rubypitaya/app-template/app/handlers/player_handler.rb +4 -0
- data/lib/rubypitaya/app-template/{db/migration → app/migrations}/1606736477_create_player_migration.rb +0 -0
- data/lib/rubypitaya/app-template/app/setup/rubypitaya.yml +6 -0
- data/lib/rubypitaya/app-template/bin/console +2 -2
- data/lib/rubypitaya/app-template/docker-compose.yml +24 -0
- data/lib/rubypitaya/app-template/helm/templates/config-maps/nginx-config.yaml +2 -2
- data/lib/rubypitaya/app-template/helm/templates/deployments/gameserver-nginx.yaml +2 -2
- data/lib/rubypitaya/app-template/helm/templates/deployments/rubypitaya.yaml +6 -6
- data/lib/rubypitaya/app-template/helm/templates/pods/gameserver.yaml +21 -0
- data/lib/rubypitaya/app-template/helm/templates/services/gameserver-nginx.yaml +2 -2
- data/lib/rubypitaya/app-template/helm/templates/services/gameserver.yaml +6 -13
- data/lib/rubypitaya/app-template/helm/values.yaml +2 -1
- data/lib/rubypitaya/core/{db/migration → app/migrations}/0000000001_create_user_migration.rb +0 -0
- data/lib/rubypitaya/core/application_files_importer.rb +3 -1
- data/lib/rubypitaya/core/handler_base.rb +2 -1
- data/lib/rubypitaya/core/handler_router.rb +4 -4
- data/lib/rubypitaya/core/helpers/setup_helper.rb +2 -2
- data/lib/rubypitaya/core/http_routes.rb +1 -0
- data/lib/rubypitaya/core/initializer_content.rb +3 -2
- data/lib/rubypitaya/core/main.rb +15 -2
- data/lib/rubypitaya/core/mongo_connector.rb +25 -0
- data/lib/rubypitaya/core/path.rb +3 -3
- data/lib/rubypitaya/core/spec-helpers/handler_spec_helper.rb +26 -6
- data/lib/rubypitaya/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f1c2aee3aba15fcf5485c3aca454f8c18808a3cfe156d80f59d4cdbfa58d441
|
4
|
+
data.tar.gz: b3c35e6aab203309e4d7992a61ed3a7484b61b044dfe4e4aa6467dabe1374bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fe1dc4a9b2101050157b6f204b9d69e113035746b4ec258e14cf21c4f42d6af8b05d1dd2eef7ef29f4df563672894d3aa504dfac953ddc1ebc27ba095398e09
|
7
|
+
data.tar.gz: 1c8b3aa7dad2432544585fb04e917392c74c9a5dff671db3845e70796ac7062e0bc8daefa3325dd24849252c70907c1806910f384923642f3381744e0cfbc870
|
data/bin/rubypitaya
CHANGED
@@ -67,9 +67,10 @@ def command_add_plugin(argv)
|
|
67
67
|
exit(-1)
|
68
68
|
end
|
69
69
|
|
70
|
-
|
70
|
+
plugin_git_url = argv[1]
|
71
|
+
branch_name = argv[2] || ""
|
71
72
|
|
72
|
-
plugin_name = RubyPitaya::RubyPitaya.add_plugin(
|
73
|
+
plugin_name = RubyPitaya::RubyPitaya.add_plugin(plugin_git_url, branch_name)
|
73
74
|
|
74
75
|
puts "Plugin #{plugin_name} added!"
|
75
76
|
end
|
@@ -94,7 +95,7 @@ def show_help_create_migration
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def show_help_add_plugin
|
97
|
-
puts 'Usage: $ rubypitaya add-plugin [plugin_git_link]'
|
98
|
+
puts 'Usage: $ rubypitaya add-plugin [plugin_git_link] [branch_name:optional]'
|
98
99
|
puts ''
|
99
100
|
end
|
100
101
|
|
data/lib/rubypitaya.rb
CHANGED
@@ -38,18 +38,29 @@ module RubyPitaya
|
|
38
38
|
migration_file_name
|
39
39
|
end
|
40
40
|
|
41
|
-
def self.add_plugin(
|
41
|
+
def self.add_plugin(plugin_git_url, branch_name)
|
42
42
|
Dir.mkdir(Path::PLUGINS_FOLDER_PATH) unless File.exists?(Path::PLUGINS_FOLDER_PATH)
|
43
43
|
|
44
|
-
plugin_name =
|
44
|
+
plugin_name = plugin_git_url.scan(/.+\/(.+)\.git/).flatten.first
|
45
45
|
plugin_folder_path = File.join(Path::PLUGINS_FOLDER_PATH, plugin_name)
|
46
46
|
plugin_git_path = File.join(plugin_folder_path, '.git/')
|
47
47
|
|
48
|
+
branch_command = ""
|
49
|
+
branch_command = "--branch #{branch_name}" unless branch_name.blank?
|
50
|
+
|
48
51
|
FileUtils.rm_rf(plugin_folder_path) if File.exists?(plugin_folder_path)
|
49
|
-
|
52
|
+
puts "git -C #{Path::PLUGINS_FOLDER_PATH} clone --depth 1 #{branch_command} #{plugin_git_url}"
|
53
|
+
`git -C #{Path::PLUGINS_FOLDER_PATH} clone --depth 1 #{branch_command} #{plugin_git_url}`
|
50
54
|
FileUtils.rm_rf(plugin_git_path)
|
51
55
|
|
52
|
-
|
56
|
+
Dir.entries(plugin_folder_path).each do |entry|
|
57
|
+
entry_path = File.join(plugin_folder_path, entry)
|
58
|
+
FileUtils.rm_rf(entry_path) unless entry == 'app' ||
|
59
|
+
entry == '.' ||
|
60
|
+
entry == '..'
|
61
|
+
end
|
62
|
+
|
63
|
+
plugin_migrations_path = File.join(plugin_folder_path, 'app/migrations/')
|
53
64
|
plugin_migrations_files = Dir[File.join(plugin_migrations_path, '*')]
|
54
65
|
base_migration_timestamp = Time.now.utc.to_i
|
55
66
|
|
@@ -12,9 +12,10 @@ GEM
|
|
12
12
|
minitest (>= 5.1)
|
13
13
|
tzinfo (~> 2.0)
|
14
14
|
zeitwerk (~> 2.3)
|
15
|
+
bson (4.12.1)
|
15
16
|
builder (3.2.4)
|
16
17
|
coderay (1.1.3)
|
17
|
-
concurrent-ruby (1.1.
|
18
|
+
concurrent-ruby (1.1.9)
|
18
19
|
cucumber (5.3.0)
|
19
20
|
builder (~> 3.2, >= 3.2.4)
|
20
21
|
cucumber-core (~> 8.0, >= 8.0.1)
|
@@ -50,11 +51,11 @@ GEM
|
|
50
51
|
etcdv3 (0.10.2)
|
51
52
|
grpc (~> 1.17)
|
52
53
|
eventmachine (1.2.7)
|
53
|
-
ffi (1.15.
|
54
|
-
google-protobuf (3.
|
55
|
-
googleapis-common-protos-types (1.0
|
54
|
+
ffi (1.15.3)
|
55
|
+
google-protobuf (3.17.3)
|
56
|
+
googleapis-common-protos-types (1.1.0)
|
56
57
|
google-protobuf (~> 3.14)
|
57
|
-
grpc (1.
|
58
|
+
grpc (1.38.0)
|
58
59
|
google-protobuf (~> 3.15)
|
59
60
|
googleapis-common-protos-types (~> 1.0)
|
60
61
|
i18n (1.8.10)
|
@@ -65,6 +66,8 @@ GEM
|
|
65
66
|
method_source (1.0.0)
|
66
67
|
middleware (0.1.0)
|
67
68
|
minitest (5.14.4)
|
69
|
+
mongo (2.15.0)
|
70
|
+
bson (>= 4.8.2, < 5.0.0)
|
68
71
|
multi_json (1.15.0)
|
69
72
|
multi_test (0.1.2)
|
70
73
|
mustermann (1.1.1)
|
@@ -90,7 +93,7 @@ GEM
|
|
90
93
|
rack-protection (2.1.0)
|
91
94
|
rack
|
92
95
|
rake (13.0.3)
|
93
|
-
rb-fsevent (0.
|
96
|
+
rb-fsevent (0.11.0)
|
94
97
|
rb-inotify (0.10.1)
|
95
98
|
ffi (~> 1.0)
|
96
99
|
redis (4.2.5)
|
@@ -107,10 +110,11 @@ GEM
|
|
107
110
|
diff-lcs (>= 1.2.0, < 2.0)
|
108
111
|
rspec-support (~> 3.10.0)
|
109
112
|
rspec-support (3.10.2)
|
110
|
-
ruby2_keywords (0.0.
|
111
|
-
rubypitaya (2.
|
113
|
+
ruby2_keywords (0.0.5)
|
114
|
+
rubypitaya (2.25.0)
|
112
115
|
activerecord (= 6.1.3)
|
113
116
|
etcdv3 (= 0.10.2)
|
117
|
+
mongo (= 2.15.0)
|
114
118
|
nats (= 0.11.0)
|
115
119
|
ostruct (= 0.3.3)
|
116
120
|
pg (= 1.2.3)
|
@@ -148,7 +152,7 @@ DEPENDENCIES
|
|
148
152
|
listen (= 3.4.1)
|
149
153
|
pry (= 0.14.0)
|
150
154
|
rspec (= 3.10.0)
|
151
|
-
rubypitaya (= 2.
|
155
|
+
rubypitaya (= 2.25.0)
|
152
156
|
|
153
157
|
BUNDLED WITH
|
154
158
|
2.1.4
|
@@ -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:2.7.2
|
44
|
+
@docker run --rm -v "$(PWD)":/usr/src/app -w /usr/src/app ruby:2.7.2 bundle install
|
45
45
|
|
46
46
|
## + Improve metagame
|
47
47
|
|
@@ -49,9 +49,9 @@ update-dependencies:
|
|
49
49
|
create-migration:
|
50
50
|
@docker-compose run --service-ports --rm rubypitaya-commands bundle exec rubypitaya create-migration $(NAME)
|
51
51
|
|
52
|
-
## Add or update a
|
52
|
+
## Add or update a plugin. GIT=[plugin-http-git-link] BRANCH=[branch-name:optional]
|
53
53
|
add-plugin:
|
54
|
-
@docker-compose run --service-ports --rm rubypitaya-commands bundle exec rubypitaya add-plugin $(GIT)
|
54
|
+
@docker-compose run --service-ports --rm rubypitaya-commands bundle exec ruby ../../../bin/rubypitaya add-plugin $(GIT) $(BRANCH)
|
55
55
|
|
56
56
|
## + Database Commands
|
57
57
|
|
@@ -13,6 +13,9 @@ class AppInitializer < RubyPitaya::InitializerBase
|
|
13
13
|
# - get instance by key
|
14
14
|
# - redis
|
15
15
|
# - link: https://github.com/redis/redis-rb/
|
16
|
+
# - mongo
|
17
|
+
# - class: Mongo::Client
|
18
|
+
# - link: https://docs.mongodb.com/ruby-driver/current/tutorials/quick-start/
|
16
19
|
# - config
|
17
20
|
# - class: RubyPitaya::Config
|
18
21
|
# - link: https://gitlab.com/LucianoPC/ruby-pitaya/-/blob/master/lib/rubypitaya/core/config.rb
|
@@ -11,6 +11,10 @@ class PlayerHandler < RubyPitaya::HandlerBase
|
|
11
11
|
# - @redis
|
12
12
|
# - link: https://github.com/redis/redis-rb/
|
13
13
|
#
|
14
|
+
# - @mongo
|
15
|
+
# - class: Mongo::Client
|
16
|
+
# - link: https://docs.mongodb.com/ruby-driver/current/tutorials/quick-start/
|
17
|
+
#
|
14
18
|
# - @config
|
15
19
|
# - info: Hash with config json files inside of 'app/config'
|
16
20
|
# - example:
|
File without changes
|
@@ -15,7 +15,7 @@ ActiveSupport::LogSubscriber.colorize_logging = true
|
|
15
15
|
# Loading core files
|
16
16
|
Gem.find_files('rubypitaya/**/*.rb').each do |path|
|
17
17
|
require path unless path.end_with?('spec.rb') ||
|
18
|
-
path.include?('
|
18
|
+
path.include?('app/migrations') ||
|
19
19
|
path.include?('core/templates') ||
|
20
20
|
path.include?('core/spec-helpers') ||
|
21
21
|
path.include?('app-template')
|
@@ -28,7 +28,7 @@ app_folder_paths.each do |app_folder_path|
|
|
28
28
|
|
29
29
|
Dir[app_files_path].each do |path|
|
30
30
|
require path unless path.end_with?('spec.rb') ||
|
31
|
-
path.include?('
|
31
|
+
path.include?('app/migrations') ||
|
32
32
|
path.include?('spec_helper.rb')
|
33
33
|
end
|
34
34
|
end
|
@@ -26,6 +26,28 @@ services:
|
|
26
26
|
ports:
|
27
27
|
- '9100:5432'
|
28
28
|
|
29
|
+
mongo:
|
30
|
+
image: mongo:5.0.0
|
31
|
+
restart: always
|
32
|
+
ports:
|
33
|
+
- 27017:27017
|
34
|
+
environment:
|
35
|
+
MONGO_INITDB_ROOT_USERNAME: user
|
36
|
+
MONGO_INITDB_ROOT_PASSWORD: password
|
37
|
+
|
38
|
+
mongo-express:
|
39
|
+
depends_on:
|
40
|
+
- 'mongo'
|
41
|
+
image: mongo-express:0.54.0
|
42
|
+
restart: always
|
43
|
+
ports:
|
44
|
+
- 8081:8081
|
45
|
+
environment:
|
46
|
+
ME_CONFIG_MONGODB_ADMINUSERNAME: user
|
47
|
+
ME_CONFIG_MONGODB_ADMINPASSWORD: password
|
48
|
+
ME_CONFIG_MONGODB_SERVER: 'mongo'
|
49
|
+
ME_CONFIG_MONGODB_PORT: '27017'
|
50
|
+
|
29
51
|
connector:
|
30
52
|
image: 'registry.gitlab.com/lucianopc/pitaya-connector:0.1.0'
|
31
53
|
depends_on:
|
@@ -49,6 +71,8 @@ services:
|
|
49
71
|
- 'nats'
|
50
72
|
- 'etcd'
|
51
73
|
- 'redis'
|
74
|
+
- 'mongo'
|
75
|
+
- 'mongo-express'
|
52
76
|
- 'connector'
|
53
77
|
build:
|
54
78
|
context: '.'
|
@@ -4,6 +4,6 @@ metadata:
|
|
4
4
|
name: nginx-config
|
5
5
|
data:
|
6
6
|
nginx.conf: "events {\n worker_connections 1024;\n}\n\nstream {\n server
|
7
|
-
{\n listen {{ .Values.gameserver.
|
8
|
-
valid=5s;\n\n proxy_pass gameserver-$server_port.{{ .Values.namespace }}.svc.cluster.local
|
7
|
+
{\n listen {{ .Values.gameserver.externalport.first }}-{{ .Values.gameserver.externalport.last }};\n \n resolver kube-dns.kube-system.svc.cluster.local
|
8
|
+
valid=5s;\n\n proxy_pass gameserver-$server_port.gameserver.{{ .Values.namespace }}.svc.cluster.local:{{ .Values.gameserver.gameport }};\n
|
9
9
|
\ }\n}\n"
|
@@ -21,8 +21,8 @@ spec:
|
|
21
21
|
- name: gameserver-nginx
|
22
22
|
image: nginx:1.18.0
|
23
23
|
ports:
|
24
|
-
{{- $initialValue := int .Values.gameserver.
|
25
|
-
{{- $finalValue := add .Values.gameserver.
|
24
|
+
{{- $initialValue := int .Values.gameserver.externalport.first }}
|
25
|
+
{{- $finalValue := add .Values.gameserver.externalport.last 1 }}
|
26
26
|
{{- $finalValue = int $finalValue }}
|
27
27
|
{{- range untilStep $initialValue $finalValue 1 }}
|
28
28
|
{{- $port := . }}
|
@@ -19,7 +19,7 @@ spec:
|
|
19
19
|
spec:
|
20
20
|
containers:
|
21
21
|
- name: rubypitaya
|
22
|
-
image: {{ .Values.rubypitaya.image.repository }}:{{ .Values.rubypitaya.image.tag }}
|
22
|
+
image: "{{ .Values.rubypitaya.image.repository }}:{{ .Values.rubypitaya.image.tag }}"
|
23
23
|
command: ["bundle", "exec", "rubypitaya", "run"]
|
24
24
|
ports:
|
25
25
|
- containerPort: 4567
|
@@ -48,19 +48,19 @@ spec:
|
|
48
48
|
- name: RUBYPITAYA_HTTP_AUTH_USER
|
49
49
|
value: {{ .Values.http.auth.user | quote }}
|
50
50
|
- name: RUBYPITAYA_HTTP_AUTH_PASS
|
51
|
-
value: {{ .Values.http.auth.
|
51
|
+
value: {{ .Values.http.auth.pass | quote }}
|
52
52
|
- name: MATCHMAKING_CURRENTROOMBLL
|
53
53
|
value: kubernetes
|
54
54
|
- name: MATCHMAKING_ROOMBLL_KUBERNETES_NAMESPACE
|
55
55
|
value: {{ .Values.namespace }}
|
56
56
|
- name: MATCHMAKING_ROOMBLL_KUBERNETES_CONTAINERIMAGE
|
57
|
-
value: {{ .Values.gameserver.image.repository }}:{{ .Values.gameserver.image.tag }}
|
57
|
+
value: "{{ .Values.gameserver.image.repository }}:{{ .Values.gameserver.image.tag }}"
|
58
58
|
- name: MATCHMAKING_ROOMBLL_KUBERNETES_INITIALPORT
|
59
|
-
value: {{ .Values.gameserver.
|
59
|
+
value: {{ .Values.gameserver.externalport.first | quote }}
|
60
60
|
- name: MATCHMAKING_ROOMBLL_KUBERNETES_FINALPORT
|
61
|
-
value: {{ .Values.gameserver.
|
61
|
+
value: {{ .Values.gameserver.externalport.last | quote }}
|
62
62
|
- name: MATCHMAKING_ROOMBLL_KUBERNETES_SERVICEHOST
|
63
|
-
value: {{ .Values.gameserver.servicehost }}
|
63
|
+
value: {{ .Values.gameserver.servicehost | quote }}
|
64
64
|
imagePullSecrets:
|
65
65
|
- name: gitlab-registry
|
66
66
|
serviceAccount: rubypitaya
|
@@ -0,0 +1,21 @@
|
|
1
|
+
apiVersion: v1
|
2
|
+
kind: Pod
|
3
|
+
metadata:
|
4
|
+
name: gameserver-{{ .Values.gameserver.port }}
|
5
|
+
labels:
|
6
|
+
app: rubypitaya
|
7
|
+
component: gameserver
|
8
|
+
spec:
|
9
|
+
hostname: gameserver-{{ .Values.gameserver.port }}
|
10
|
+
subdomain: gameserver
|
11
|
+
containers:
|
12
|
+
- name: gameserver-{{ .Values.gameserver.port }}
|
13
|
+
image: {{ .Values.gameserver.image.repository }}:{{ .Values.connector.image.tag }}
|
14
|
+
ports:
|
15
|
+
- containerPort: {{ .Values.gameserver.gameport }}
|
16
|
+
name: gameserver
|
17
|
+
env:
|
18
|
+
- name: ROOM_ID
|
19
|
+
value: {{ .Values.gameserver.roomid }}
|
20
|
+
- name: PORT
|
21
|
+
value: {{ .Values.gameserver.gameport }}
|
@@ -7,8 +7,8 @@ spec:
|
|
7
7
|
app: gameserver
|
8
8
|
component: gameserver-nginx
|
9
9
|
ports:
|
10
|
-
{{- $initialValue := int .Values.gameserver.
|
11
|
-
{{- $finalValue := add .Values.gameserver.
|
10
|
+
{{- $initialValue := int .Values.gameserver.externalport.first }}
|
11
|
+
{{- $finalValue := add .Values.gameserver.externalport.last 1 }}
|
12
12
|
{{- $finalValue = int $finalValue }}
|
13
13
|
{{- range untilStep $initialValue $finalValue 1 }}
|
14
14
|
{{- $port := . }}
|
@@ -1,20 +1,13 @@
|
|
1
|
-
{{- $initialValue := int .Values.gameserver.port.first }}
|
2
|
-
{{- $finalValue := add .Values.gameserver.port.last 1 }}
|
3
|
-
{{- $finalValue = int $finalValue }}
|
4
|
-
{{- range untilStep $initialValue $finalValue 1 }}
|
5
|
-
{{- $port := . }}
|
6
1
|
apiVersion: v1
|
7
2
|
kind: Service
|
8
3
|
metadata:
|
9
|
-
name: gameserver
|
4
|
+
name: gameserver
|
10
5
|
spec:
|
11
6
|
selector:
|
12
|
-
app:
|
13
|
-
component: gameserver
|
7
|
+
app: rubypitaya
|
8
|
+
component: gameserver
|
14
9
|
ports:
|
15
10
|
- protocol: TCP
|
16
|
-
port: {{
|
17
|
-
targetPort: {{
|
18
|
-
type: ClusterIP
|
19
|
-
---
|
20
|
-
{{- end }}
|
11
|
+
port: {{ .Values.gameserver.gameport }}
|
12
|
+
targetPort: {{ .Values.gameserver.gameport }}
|
13
|
+
type: ClusterIP
|
data/lib/rubypitaya/core/{db/migration → app/migrations}/0000000001_create_user_migration.rb
RENAMED
File without changes
|
@@ -10,7 +10,9 @@ module RubyPitaya
|
|
10
10
|
app_folder_paths.each do |app_folder_path|
|
11
11
|
app_files_path = "#{app_folder_path}/**/*.rb"
|
12
12
|
|
13
|
-
Gem.find_files(app_files_path).each
|
13
|
+
Gem.find_files(app_files_path).each do |path|
|
14
|
+
require path unless path.include?('app/migrations')
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
|
@@ -17,10 +17,11 @@ module RubyPitaya
|
|
17
17
|
@postman = nil
|
18
18
|
end
|
19
19
|
|
20
|
-
def set_attributes(bll, log, redis, setup, config, params, session, postman)
|
20
|
+
def set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
|
21
21
|
@bll = bll
|
22
22
|
@log = log
|
23
23
|
@redis = redis
|
24
|
+
@mongo = mongo
|
24
25
|
@setup = setup
|
25
26
|
@config = config
|
26
27
|
@params = params
|
@@ -54,8 +54,8 @@ module RubyPitaya
|
|
54
54
|
@handler_name_map = @handler_name_map.to_h
|
55
55
|
end
|
56
56
|
|
57
|
-
def call(handler_name, action_name, session, postman, redis,
|
58
|
-
bll, log, params)
|
57
|
+
def call(handler_name, action_name, session, postman, redis, mongo, setup,
|
58
|
+
config, bll, log, params)
|
59
59
|
unless @handler_name_map.include?(handler_name)
|
60
60
|
return {
|
61
61
|
code: StatusCodes::CODE_HANDLER_NOT_FOUND,
|
@@ -72,11 +72,11 @@ module RubyPitaya
|
|
72
72
|
handler = @handler_name_map[handler_name]
|
73
73
|
|
74
74
|
if !handler.class.authenticated_action_name?(action_name)
|
75
|
-
handler.set_attributes(bll, log, redis, setup, config, params, session, postman)
|
75
|
+
handler.set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
|
76
76
|
handler.send(action_name)
|
77
77
|
else
|
78
78
|
if session.authenticated?
|
79
|
-
handler.set_attributes(bll, log, redis, setup, config, params, session, postman)
|
79
|
+
handler.set_attributes(bll, log, redis, mongo, setup, config, params, session, postman)
|
80
80
|
handler.send(action_name)
|
81
81
|
else
|
82
82
|
return {
|
@@ -18,7 +18,7 @@ ActiveRecord::Migration.maintain_test_schema!
|
|
18
18
|
# Loading core files
|
19
19
|
Gem.find_files('rubypitaya/**/*.rb').each do |path|
|
20
20
|
require path unless path.end_with?('spec.rb') ||
|
21
|
-
path.include?('
|
21
|
+
path.include?('app/migrations') ||
|
22
22
|
path.include?('core/templates') ||
|
23
23
|
path.include?('core/spec-helpers') ||
|
24
24
|
path.include?('app-template')
|
@@ -31,6 +31,6 @@ app_folder_paths.each do |app_folder_path|
|
|
31
31
|
|
32
32
|
Dir[app_files_path].each do |path|
|
33
33
|
require path unless path.end_with?('spec.rb') ||
|
34
|
-
path.include?('
|
34
|
+
path.include?('app/migrations')
|
35
35
|
end
|
36
36
|
end
|
@@ -2,11 +2,12 @@ module RubyPitaya
|
|
2
2
|
|
3
3
|
class InitializerContent
|
4
4
|
|
5
|
-
attr_reader :bll, :log, :redis, :setup, :config
|
5
|
+
attr_reader :bll, :log, :redis, :mongo, :setup, :config
|
6
6
|
|
7
|
-
def initialize(bll, log, redis, setup, config)
|
7
|
+
def initialize(bll, log, redis, mongo, setup, config)
|
8
8
|
@bll = bll
|
9
9
|
@log = log
|
10
|
+
@mongo = mongo
|
10
11
|
@redis = redis
|
11
12
|
@setup = setup
|
12
13
|
@config = config
|
data/lib/rubypitaya/core/main.rb
CHANGED
@@ -16,8 +16,9 @@ require 'rubypitaya/core/handler_router'
|
|
16
16
|
require 'rubypitaya/core/etcd_connector'
|
17
17
|
require 'rubypitaya/core/nats_connector'
|
18
18
|
require 'rubypitaya/core/database_config'
|
19
|
-
require 'rubypitaya/core/redis_connector'
|
20
19
|
require 'rubypitaya/core/instance_holder'
|
20
|
+
require 'rubypitaya/core/mongo_connector'
|
21
|
+
require 'rubypitaya/core/redis_connector'
|
21
22
|
require 'rubypitaya/core/database_connector'
|
22
23
|
require 'rubypitaya/core/initializer_content'
|
23
24
|
require 'rubypitaya/core/initializer_broadcast'
|
@@ -71,6 +72,14 @@ module RubyPitaya
|
|
71
72
|
@database_connector = DatabaseConnector.new(@database_config)
|
72
73
|
@database_connector.connect
|
73
74
|
|
75
|
+
@mongo_address = @setup['rubypitaya.mongo.url']
|
76
|
+
@mongo_user = @setup['rubypitaya.mongo.user']
|
77
|
+
@mongo_password = @setup['rubypitaya.mongo.pass']
|
78
|
+
@mongo_database_name = @setup['rubypitaya.mongo.database']
|
79
|
+
@mongo_connector = MongoConnector.new(@mongo_address, @mongo_user,
|
80
|
+
@mongo_password, @mongo_database_name)
|
81
|
+
@mongo_connector.connect
|
82
|
+
|
74
83
|
@session = Session.new
|
75
84
|
@postman = Postman.new(@nats_connector)
|
76
85
|
@config = Config.new
|
@@ -81,6 +90,7 @@ module RubyPitaya
|
|
81
90
|
@initializer_content = InitializerContent.new(@bll,
|
82
91
|
@log,
|
83
92
|
@redis_connector.redis,
|
93
|
+
@mongo_connector.mongo,
|
84
94
|
@setup,
|
85
95
|
@config)
|
86
96
|
@initializer_broadcast = InitializerBroadcast.new
|
@@ -97,6 +107,8 @@ module RubyPitaya
|
|
97
107
|
def run_http
|
98
108
|
HttpRoutes.set :bll, @bll
|
99
109
|
HttpRoutes.set :log, @log
|
110
|
+
HttpRoutes.set :redis, @redis_connector.redis
|
111
|
+
HttpRoutes.set :mongo, @mongo_connector.mongo
|
100
112
|
HttpRoutes.set :setup, @setup
|
101
113
|
HttpRoutes.set :config, @config
|
102
114
|
HttpRoutes.set :views, [Path::HTTP_VIEWS_PATH] + Path::Plugins::HTTP_VIEWS_PATHS
|
@@ -172,7 +184,8 @@ module RubyPitaya
|
|
172
184
|
|
173
185
|
response = @handler_router.call(handler_name, action_name, @session,
|
174
186
|
@postman, @redis_connector.redis,
|
175
|
-
@
|
187
|
+
@mongo_connector.mongo, @setup, @config,
|
188
|
+
@bll, @log, params)
|
176
189
|
|
177
190
|
delta_time_seconds = ((Time.now.to_f - start_time_seconds) * 1000).round(2)
|
178
191
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'mongo'
|
2
|
+
|
3
|
+
module RubyPitaya
|
4
|
+
|
5
|
+
class MongoConnector
|
6
|
+
|
7
|
+
def initialize(mongo_address, mongo_user, mongo_password, mongo_database_name)
|
8
|
+
@mongo_address = mongo_address
|
9
|
+
@mongo_user = mongo_user
|
10
|
+
@mongo_password = mongo_password
|
11
|
+
@mongo_database_name = mongo_database_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def connect
|
15
|
+
@mongo_client = Mongo::Client.new([@mongo_address],
|
16
|
+
user: @mongo_user,
|
17
|
+
password: @mongo_password,
|
18
|
+
database: @mongo_database_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def mongo
|
22
|
+
@mongo_client
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/rubypitaya/core/path.rb
CHANGED
@@ -8,7 +8,7 @@ module RubyPitaya
|
|
8
8
|
HANDLERS_FOLDER_PATH = File.join(Dir.pwd, 'app/handlers/')
|
9
9
|
APP_CONFIG_FOLDER_PATH = File.join(Dir.pwd, 'app/config/')
|
10
10
|
APP_SETUP_FOLDER_PATH = File.join(Dir.pwd, 'app/setup/')
|
11
|
-
MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, '
|
11
|
+
MIGRATIONS_FOLDER_PATH = File.join(Dir.pwd, 'app/migrations/')
|
12
12
|
PLUGINS_FOLDER_PATH = File.join(Dir.pwd, 'plugins/')
|
13
13
|
|
14
14
|
ROUTES_FILE_PATH = File.join(Dir.pwd, 'config/routes.rb')
|
@@ -18,7 +18,7 @@ module RubyPitaya
|
|
18
18
|
|
19
19
|
class Core
|
20
20
|
APP_FOLDER_PATH = File.join(__dir__, 'app/')
|
21
|
-
MIGRATIONS_FOLDER_PATH = File.join(__dir__, '
|
21
|
+
MIGRATIONS_FOLDER_PATH = File.join(__dir__, 'app/migrations/')
|
22
22
|
end
|
23
23
|
|
24
24
|
class Plugins
|
@@ -26,7 +26,7 @@ module RubyPitaya
|
|
26
26
|
HANDLERS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/handlers'))
|
27
27
|
APP_CONFIG_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/config/'))
|
28
28
|
APP_SETUP_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/setup/'))
|
29
|
-
MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/
|
29
|
+
MIGRATIONS_FOLDER_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/migrations/'))
|
30
30
|
HTTP_VIEWS_PATHS = Dir.glob(File.join(Dir.pwd, 'plugins/*/app/http/views'))
|
31
31
|
end
|
32
32
|
end
|
@@ -22,6 +22,7 @@ module RubyPitaya
|
|
22
22
|
@@response = {}
|
23
23
|
|
24
24
|
initialize_redis
|
25
|
+
initialize_mongo
|
25
26
|
|
26
27
|
@@handler_router ||= HandlerRouter.new()
|
27
28
|
|
@@ -29,6 +30,7 @@ module RubyPitaya
|
|
29
30
|
@@initializer_content = InitializerContent.new(@@bll,
|
30
31
|
@@log,
|
31
32
|
@@redis_connector.redis,
|
33
|
+
@@mongo_connector.mongo,
|
32
34
|
@@setup,
|
33
35
|
@@config)
|
34
36
|
@@initializer_broadcast = InitializerBroadcast.new
|
@@ -40,7 +42,8 @@ module RubyPitaya
|
|
40
42
|
|
41
43
|
@@response = @@handler_router.call(handler_name, action_name, @@session,
|
42
44
|
@@postman, @@redis_connector.redis,
|
43
|
-
@@
|
45
|
+
@@mongo_connector.mongo, @@setup,
|
46
|
+
@@config, @@bll, @@log, params)
|
44
47
|
end
|
45
48
|
|
46
49
|
def response
|
@@ -71,23 +74,23 @@ module RubyPitaya
|
|
71
74
|
@@setup.add(*keys, value)
|
72
75
|
end
|
73
76
|
|
74
|
-
def
|
77
|
+
def bll
|
75
78
|
@@bll
|
76
79
|
end
|
77
80
|
|
78
|
-
def
|
81
|
+
def log
|
79
82
|
@@log
|
80
83
|
end
|
81
84
|
|
82
|
-
def
|
85
|
+
def session
|
83
86
|
@@session
|
84
87
|
end
|
85
88
|
|
86
|
-
def
|
89
|
+
def postman
|
87
90
|
@@postman
|
88
91
|
end
|
89
92
|
|
90
|
-
def
|
93
|
+
def redis
|
91
94
|
@@redis_connector.redis
|
92
95
|
end
|
93
96
|
|
@@ -105,5 +108,22 @@ module RubyPitaya
|
|
105
108
|
|
106
109
|
@@redis_connector.redis.flushall
|
107
110
|
end
|
111
|
+
|
112
|
+
def initialize_mongo
|
113
|
+
@@mongo_connector ||= nil
|
114
|
+
|
115
|
+
if @@mongo_connector.nil?
|
116
|
+
@@core_setup ||= Setup.new
|
117
|
+
mongo_address = @@core_setup['rubypitaya.mongo.url']
|
118
|
+
mongo_user = @@core_setup['rubypitaya.mongo.user']
|
119
|
+
mongo_password = @@core_setup['rubypitaya.mongo.pass']
|
120
|
+
mongo_database_name = @@core_setup['rubypitaya.mongo.database']
|
121
|
+
@@mongo_connector = MongoConnector.new(mongo_address, mongo_user,
|
122
|
+
mongo_password, mongo_database_name)
|
123
|
+
@@mongo_connector.connect
|
124
|
+
end
|
125
|
+
|
126
|
+
@@mongo_connector.mongo.collections.map(&:drop)
|
127
|
+
end
|
108
128
|
end
|
109
129
|
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: 2.
|
4
|
+
version: 2.25.0
|
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-
|
11
|
+
date: 2021-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -258,12 +258,12 @@ files:
|
|
258
258
|
- "./lib/rubypitaya/app-template/app/handlers/player_handler.rb"
|
259
259
|
- "./lib/rubypitaya/app-template/app/http/hello_world_http.rb"
|
260
260
|
- "./lib/rubypitaya/app-template/app/http/views/hello_world.erb"
|
261
|
+
- "./lib/rubypitaya/app-template/app/migrations/1606736477_create_player_migration.rb"
|
261
262
|
- "./lib/rubypitaya/app-template/app/models/player.rb"
|
262
263
|
- "./lib/rubypitaya/app-template/app/models/user.rb"
|
263
264
|
- "./lib/rubypitaya/app-template/app/setup/rubypitaya.yml"
|
264
265
|
- "./lib/rubypitaya/app-template/bin/console"
|
265
266
|
- "./lib/rubypitaya/app-template/config/routes.rb"
|
266
|
-
- "./lib/rubypitaya/app-template/db/migration/1606736477_create_player_migration.rb"
|
267
267
|
- "./lib/rubypitaya/app-template/docker-compose.yml"
|
268
268
|
- "./lib/rubypitaya/app-template/docker/dev/Dockerfile"
|
269
269
|
- "./lib/rubypitaya/app-template/docker/entrypoint.sh"
|
@@ -279,6 +279,7 @@ files:
|
|
279
279
|
- "./lib/rubypitaya/app-template/helm/templates/deployments/connector.yaml"
|
280
280
|
- "./lib/rubypitaya/app-template/helm/templates/deployments/gameserver-nginx.yaml"
|
281
281
|
- "./lib/rubypitaya/app-template/helm/templates/deployments/rubypitaya.yaml"
|
282
|
+
- "./lib/rubypitaya/app-template/helm/templates/pods/gameserver.yaml"
|
282
283
|
- "./lib/rubypitaya/app-template/helm/templates/role-bindings/rubypitaya.yaml"
|
283
284
|
- "./lib/rubypitaya/app-template/helm/templates/roles/rubypitaya.yaml"
|
284
285
|
- "./lib/rubypitaya/app-template/helm/templates/service-accounts/rubypitaya.yaml"
|
@@ -316,13 +317,13 @@ files:
|
|
316
317
|
- "./lib/rubypitaya/app-template/spec/hello_world_handler_spec.rb"
|
317
318
|
- "./lib/rubypitaya/app-template/spec/player_handler_spec.rb"
|
318
319
|
- "./lib/rubypitaya/app-template/spec/spec_helper.rb"
|
320
|
+
- "./lib/rubypitaya/core/app/migrations/0000000001_create_user_migration.rb"
|
319
321
|
- "./lib/rubypitaya/core/app/models/user.rb"
|
320
322
|
- "./lib/rubypitaya/core/application_files_importer.rb"
|
321
323
|
- "./lib/rubypitaya/core/config.rb"
|
322
324
|
- "./lib/rubypitaya/core/config_core.rb"
|
323
325
|
- "./lib/rubypitaya/core/database_config.rb"
|
324
326
|
- "./lib/rubypitaya/core/database_connector.rb"
|
325
|
-
- "./lib/rubypitaya/core/db/migration/0000000001_create_user_migration.rb"
|
326
327
|
- "./lib/rubypitaya/core/etcd_connector.rb"
|
327
328
|
- "./lib/rubypitaya/core/handler_base.rb"
|
328
329
|
- "./lib/rubypitaya/core/handler_router.rb"
|
@@ -333,6 +334,7 @@ files:
|
|
333
334
|
- "./lib/rubypitaya/core/initializer_content.rb"
|
334
335
|
- "./lib/rubypitaya/core/instance_holder.rb"
|
335
336
|
- "./lib/rubypitaya/core/main.rb"
|
337
|
+
- "./lib/rubypitaya/core/mongo_connector.rb"
|
336
338
|
- "./lib/rubypitaya/core/nats_connector.rb"
|
337
339
|
- "./lib/rubypitaya/core/parameters.rb"
|
338
340
|
- "./lib/rubypitaya/core/path.rb"
|