souls 0.51.1 → 0.52.2
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/README.md +4 -1
- data/exe/souls +3 -200
- data/lib/souls/api/generate/application.rb +97 -94
- data/lib/souls/api/generate/connection.rb +5 -4
- data/lib/souls/api/generate/edge.rb +5 -4
- data/lib/souls/api/generate/index.rb +0 -1
- data/lib/souls/api/generate/manager.rb +9 -7
- data/lib/souls/api/generate/model.rb +16 -18
- data/lib/souls/api/generate/mutation.rb +217 -218
- data/lib/souls/api/generate/policy.rb +5 -5
- data/lib/souls/api/generate/query.rb +51 -51
- data/lib/souls/api/generate/resolver.rb +115 -115
- data/lib/souls/api/generate/rspec_factory.rb +53 -53
- data/lib/souls/api/generate/rspec_model.rb +5 -5
- data/lib/souls/api/generate/rspec_mutation.rb +178 -178
- data/lib/souls/api/generate/rspec_policy.rb +5 -5
- data/lib/souls/api/generate/rspec_query.rb +111 -111
- data/lib/souls/api/generate/rspec_resolver.rb +163 -163
- data/lib/souls/api/generate/type.rb +66 -66
- data/lib/souls/api/index.rb +7 -4
- data/lib/souls/api/update/index.rb +15 -0
- data/lib/souls/api/update/mutation.rb +68 -64
- data/lib/souls/api/update/resolver.rb +59 -60
- data/lib/souls/api/update/rspec_factory.rb +40 -39
- data/lib/souls/api/update/rspec_mutation.rb +84 -83
- data/lib/souls/api/update/rspec_resolver.rb +70 -69
- data/lib/souls/api/update/type.rb +39 -38
- data/lib/souls/cli/console/index.rb +13 -1
- data/lib/souls/cli/create/index.rb +98 -94
- data/lib/souls/cli/db/index.rb +122 -1
- data/lib/souls/cli/docker/index.rb +30 -38
- data/lib/souls/cli/gcloud/compute/index.rb +100 -98
- data/lib/souls/cli/gcloud/iam/index.rb +84 -69
- data/lib/souls/cli/gcloud/index.rb +36 -35
- data/lib/souls/cli/gcloud/pubsub/subscriptions.rb +40 -27
- data/lib/souls/cli/gcloud/pubsub/topics.rb +16 -10
- data/lib/souls/cli/gcloud/run/index.rb +23 -17
- data/lib/souls/cli/gcloud/sql/index.rb +66 -47
- data/lib/souls/cli/index.rb +3 -20
- data/lib/souls/cli/init/index.rb +140 -140
- data/lib/souls/cli/release/release.rb +106 -105
- data/lib/souls/cli/server/index.rb +12 -1
- data/lib/souls/cli/sync/conf.rb +39 -38
- data/lib/souls/cli/sync/model.rb +19 -20
- data/lib/souls/cli/sync/pubsub.rb +69 -70
- data/lib/souls/cli/upgrade/gemfile.rb +108 -0
- data/lib/souls/cli/upgrade/index.rb +1 -1
- data/lib/souls/cli.rb +57 -0
- data/lib/souls/index.rb +1 -5
- data/lib/souls/version.rb +1 -1
- data/lib/souls/versions/.souls_api_version +1 -1
- data/lib/souls/versions/.souls_worker_version +1 -1
- data/lib/souls/worker/generate/index.rb +1 -1
- data/lib/souls/worker/generate/job.rb +45 -0
- data/lib/souls/worker/generate/mailer.rb +38 -43
- data/lib/souls/worker/index.rb +3 -1
- data/lib/souls.rb +2 -0
- metadata +19 -5
- data/lib/souls/api/generate/migration.rb +0 -51
- data/lib/souls/cli/upgrade/gem_update.rb +0 -107
- data/lib/souls/worker/generate/mutation.rb +0 -44
@@ -1,127 +1,128 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end
|
26
|
-
overwrite_version(new_version: souls_new_ver)
|
27
|
-
puts("before add")
|
28
|
-
system("git add .")
|
29
|
-
puts("before commit")
|
30
|
-
system("git commit -m 'souls update v#{souls_new_ver}'")
|
31
|
-
puts("before build")
|
32
|
-
system("rake build")
|
33
|
-
system("rake release")
|
34
|
-
Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"]
|
2
|
+
class CLI < Thor
|
3
|
+
desc "release", "Release Gem"
|
4
|
+
def release
|
5
|
+
system("gem install souls")
|
6
|
+
sleep(3)
|
7
|
+
current_souls_ver = Souls::VERSION.strip.split(".").map(&:to_i)
|
8
|
+
prompt = TTY::Prompt.new
|
9
|
+
choices = [
|
10
|
+
"1. Patch(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'patch')})",
|
11
|
+
"2. Minor(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'minor')})",
|
12
|
+
"3. Major(#{Souls.version_detector(current_ver: current_souls_ver, update_kind: 'major')})"
|
13
|
+
]
|
14
|
+
choice_num = prompt.select("Select Version: ", choices)[0].to_i
|
15
|
+
update_kinds = %w[patch minor major]
|
16
|
+
update_kind = update_kinds[choice_num - 1]
|
17
|
+
souls_new_ver = Souls.version_detector(current_ver: current_souls_ver, update_kind: update_kind)
|
18
|
+
status = Paint["Saving Repo...", :yellow]
|
19
|
+
Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
|
20
|
+
Whirly.status = status
|
21
|
+
%w[api worker].each do |s_name|
|
22
|
+
update_service_gemfile(service_name: s_name, version: souls_new_ver)
|
23
|
+
result = Paint[update_repo(service_name: s_name, update_kind: update_kind), :green]
|
24
|
+
Whirly.status = result
|
35
25
|
end
|
26
|
+
overwrite_version(new_version: souls_new_ver)
|
27
|
+
puts("before add")
|
28
|
+
system("git add .")
|
29
|
+
puts("before commit")
|
30
|
+
system("git commit -m 'souls update v#{souls_new_ver}'")
|
31
|
+
puts("before build")
|
32
|
+
system("rake build")
|
33
|
+
system("rake release")
|
34
|
+
Whirly.status = Paint["soul-v#{souls_new_ver} successfully updated!"]
|
36
35
|
end
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
40
|
-
current_ver = Souls.get_latest_version_txt(service_name: service_name)
|
41
|
-
new_ver = Souls.version_detector(current_ver: current_ver, update_kind: update_kind)
|
42
|
-
bucket_url = "gs://souls-bucket/boilerplates"
|
43
|
-
file_name = "#{service_name}-v#{new_ver}.tgz"
|
44
|
-
release_name = "#{service_name}-latest.tgz"
|
38
|
+
private
|
45
39
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
system("echo '#{new_ver}' > .souls_#{service_name}_version")
|
54
|
-
system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
|
55
|
-
else
|
56
|
-
raise(StandardError, "You are at wrong directory!")
|
57
|
-
end
|
40
|
+
def update_repo(service_name: "api", update_kind: "patch")
|
41
|
+
current_dir_name = FileUtils.pwd.to_s.match(%r{/([^/]+)/?$})[1]
|
42
|
+
current_ver = Souls.get_latest_version_txt(service_name: service_name)
|
43
|
+
new_ver = Souls.version_detector(current_ver: current_ver, update_kind: update_kind)
|
44
|
+
bucket_url = "gs://souls-bucket/boilerplates"
|
45
|
+
file_name = "#{service_name}-v#{new_ver}.tgz"
|
46
|
+
release_name = "#{service_name}-latest.tgz"
|
58
47
|
|
59
|
-
|
60
|
-
|
61
|
-
system("
|
62
|
-
|
63
|
-
"
|
48
|
+
case current_dir_name
|
49
|
+
when "souls"
|
50
|
+
system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
|
51
|
+
system("echo '#{new_ver}' > apps/#{service_name}/.souls_#{service_name}_version")
|
52
|
+
system("cd apps/ && tar -czf ../#{service_name}.tgz #{service_name}/ && cd ..")
|
53
|
+
when "api", "worker", "console", "admin", "media"
|
54
|
+
system("echo '#{new_ver}' > lib/souls/versions/.souls_#{service_name}_version")
|
55
|
+
system("echo '#{new_ver}' > .souls_#{service_name}_version")
|
56
|
+
system("cd .. && tar -czf ../#{service_name}.tgz #{service_name}/ && cd #{service_name}")
|
57
|
+
else
|
58
|
+
raise(StandardError, "You are at wrong directory!")
|
64
59
|
end
|
65
60
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
61
|
+
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{file_name}")
|
62
|
+
system("gsutil cp #{service_name}.tgz #{bucket_url}/#{service_name.pluralize}/#{release_name}")
|
63
|
+
system("gsutil cp .rubocop.yml #{bucket_url}/.rubocop.yml")
|
64
|
+
FileUtils.rm("#{service_name}.tgz")
|
65
|
+
"#{service_name}-v#{new_ver} Succefully Stored to GCS! "
|
66
|
+
end
|
67
|
+
|
68
|
+
def update_service_gemfile(service_name: "api", version: "0.0.1")
|
69
|
+
file_dir = "./apps/#{service_name}"
|
70
|
+
file_path = "#{file_dir}/Gemfile"
|
71
|
+
gemfile_lock = "#{file_dir}/Gemfile.lock"
|
72
|
+
tmp_file = "#{file_dir}/tmp/Gemfile"
|
73
|
+
File.open(file_path, "r") do |f|
|
74
|
+
File.open(tmp_file, "w") do |new_line|
|
75
|
+
f.each_line do |line|
|
76
|
+
gem = line.gsub("gem ", "").gsub("\"", "").gsub("\n", "").gsub(" ", "").split(",")
|
77
|
+
if gem[0] == "souls"
|
78
|
+
old_ver = gem[1].split(".")
|
79
|
+
old_ver[2] = (old_ver[2].to_i + 1).to_s
|
80
|
+
new_line.write(" gem \"souls\", \"#{version}\"\n")
|
81
|
+
else
|
82
|
+
new_line.write(line)
|
82
83
|
end
|
83
84
|
end
|
84
85
|
end
|
85
|
-
FileUtils.rm(file_path)
|
86
|
-
FileUtils.rm(gemfile_lock) if File.exist?(gemfile_lock)
|
87
|
-
FileUtils.mv(tmp_file, file_path)
|
88
|
-
puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
|
89
86
|
end
|
87
|
+
FileUtils.rm(file_path)
|
88
|
+
FileUtils.rm(gemfile_lock) if File.exist?(gemfile_lock)
|
89
|
+
FileUtils.mv(tmp_file, file_path)
|
90
|
+
puts(Paint["\nSuccessfully Updated #{service_name} Gemfile!", :green])
|
91
|
+
end
|
90
92
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
102
|
-
overwrite_gemfile_lock(new_version: new_version)
|
103
|
-
true
|
104
|
-
rescue StandardError, e
|
105
|
-
raise(StandardError, e)
|
93
|
+
def overwrite_version(new_version: "0.1.1")
|
94
|
+
FileUtils.rm("./lib/souls/version.rb")
|
95
|
+
file_path = "./lib/souls/version.rb"
|
96
|
+
File.open(file_path, "w") do |f|
|
97
|
+
f.write(<<~TEXT)
|
98
|
+
module Souls
|
99
|
+
VERSION = "#{new_version}".freeze
|
100
|
+
public_constant :VERSION
|
101
|
+
end
|
102
|
+
TEXT
|
106
103
|
end
|
104
|
+
overwrite_gemfile_lock(new_version: new_version)
|
105
|
+
true
|
106
|
+
rescue StandardError, e
|
107
|
+
raise(StandardError, e)
|
108
|
+
end
|
107
109
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
end
|
110
|
+
def overwrite_gemfile_lock(new_version: "0.1.1")
|
111
|
+
file_path = "Gemfile.lock"
|
112
|
+
new_file_path = "Gemfile.lock.tmp"
|
113
|
+
File.open(file_path, "r") do |f|
|
114
|
+
File.open(new_file_path, "w") do |new_line|
|
115
|
+
f.each_line.with_index do |line, i|
|
116
|
+
if i == 3
|
117
|
+
new_line.write(" souls (#{new_version})\n")
|
118
|
+
else
|
119
|
+
new_line.write(line)
|
119
120
|
end
|
120
121
|
end
|
121
122
|
end
|
122
|
-
FileUtils.rm(file_path)
|
123
|
-
FileUtils.mv(new_file_path, file_path)
|
124
123
|
end
|
124
|
+
FileUtils.rm(file_path)
|
125
|
+
FileUtils.mv(new_file_path, file_path)
|
125
126
|
end
|
126
127
|
end
|
127
128
|
end
|
@@ -1,4 +1,15 @@
|
|
1
1
|
module Souls
|
2
|
-
|
2
|
+
class CLI < Thor
|
3
|
+
desc "server", "Run SOULs APP"
|
4
|
+
method_option all: :boolean, alias: "--all", default: false, desc: "Run All API & Workers"
|
5
|
+
def server
|
6
|
+
if options[:all]
|
7
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
8
|
+
system("foreman start -f Procfile.dev")
|
9
|
+
end
|
10
|
+
else
|
11
|
+
system("foreman start -f Procfile.dev")
|
12
|
+
end
|
13
|
+
end
|
3
14
|
end
|
4
15
|
end
|
data/lib/souls/cli/sync/conf.rb
CHANGED
@@ -1,61 +1,62 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
class Sync < Thor
|
3
|
+
desc "conf", "Sync config/souls.rb Endpoint with Google Cloud Run"
|
4
|
+
def conf
|
5
|
+
update_conf
|
6
|
+
update_conf(strain: "api")
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
8
10
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
def update_conf(strain: "mother")
|
12
|
+
require("#{Souls.get_mother_path}/config/souls")
|
13
|
+
workers = Souls.configuration.workers
|
14
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
15
|
+
file_path = strain == "mother" ? "config/souls.rb" : "apps/api/config/souls.rb"
|
16
|
+
new_file_path = "souls.rb"
|
17
|
+
worker_switch = false
|
18
|
+
File.open(new_file_path, "w") do |new_line|
|
19
|
+
File.open(file_path, "r") do |f|
|
20
|
+
f.each_line do |line|
|
21
|
+
worker_switch = true if line.include?("config.workers")
|
22
|
+
next if line.strip == "end"
|
21
23
|
|
22
|
-
|
24
|
+
new_line.write(line) unless worker_switch
|
23
25
|
|
24
|
-
|
26
|
+
next unless worker_switch
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
new_line.write(" config.workers = [\n")
|
29
|
+
workers.each_with_index do |worker, i|
|
30
|
+
base_url = Souls::Gcloud::Run.new.get_endpoint(worker_name: worker[:name])
|
31
|
+
endpoint = Souls.configuration.endpoint
|
32
|
+
if (i + 1) == workers.size
|
33
|
+
new_line.write(<<-TEXT)
|
32
34
|
{
|
33
35
|
name: "#{worker[:name]}",
|
34
36
|
endpoint: "#{base_url.strip}#{endpoint}",
|
35
37
|
port: #{worker[:port]}
|
36
38
|
}
|
37
|
-
|
38
|
-
|
39
|
-
|
39
|
+
TEXT
|
40
|
+
else
|
41
|
+
new_line.write(<<-TEXT)
|
40
42
|
{
|
41
43
|
name: "#{worker[:name]}",
|
42
44
|
endpoint: "#{base_url.strip}#{endpoint}",
|
43
45
|
port: #{worker[:port]}
|
44
46
|
},
|
45
|
-
|
46
|
-
end
|
47
|
+
TEXT
|
47
48
|
end
|
48
|
-
break
|
49
49
|
end
|
50
|
+
break
|
50
51
|
end
|
51
|
-
new_line.write(<<~TEXT)
|
52
|
-
]
|
53
|
-
end
|
54
|
-
TEXT
|
55
52
|
end
|
56
|
-
|
57
|
-
|
53
|
+
new_line.write(<<~TEXT)
|
54
|
+
]
|
55
|
+
end
|
56
|
+
TEXT
|
58
57
|
end
|
58
|
+
FileUtils.rm(file_path)
|
59
|
+
FileUtils.mv(new_file_path, file_path)
|
59
60
|
end
|
60
61
|
end
|
61
62
|
end
|
data/lib/souls/cli/sync/model.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
2
|
+
class Sync < Thor
|
3
|
+
desc "model", "Sync Model, DB, Factory Files with API"
|
4
|
+
def model
|
5
|
+
cp_dir = %w[db app/models spec/factories]
|
6
|
+
cp_dir.each do |dir|
|
7
|
+
cp_and_dl_files(dir: dir)
|
9
8
|
end
|
9
|
+
end
|
10
10
|
|
11
|
-
|
11
|
+
private
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
13
|
+
def cp_and_dl_files(dir: "db")
|
14
|
+
require("#{Souls.get_mother_path}/config/souls")
|
15
|
+
worker_paths = Souls.configuration.workers.map { |n| n[:name] }
|
16
|
+
worker_paths.each do |path|
|
17
|
+
cp_path = "./apps/api/#{dir}"
|
18
|
+
old_path = "./apps/#{path}/#{dir}"
|
19
|
+
system("rm -rf #{old_path}", chdir: Souls.get_mother_path)
|
20
|
+
system("mkdir -p #{old_path}", chdir: Souls.get_mother_path)
|
21
|
+
system("cp -r #{cp_path}/* #{old_path}", chdir: Souls.get_mother_path)
|
22
|
+
rescue StandardError
|
23
|
+
# Do nothing
|
25
24
|
end
|
26
25
|
end
|
27
26
|
end
|
@@ -1,93 +1,92 @@
|
|
1
1
|
module Souls
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
private
|
9
|
-
|
10
|
-
def get_topics(workers: {})
|
11
|
-
project_id = Souls.configuration.project_id
|
12
|
-
pubsub = Google::Cloud::Pubsub.new
|
13
|
-
topics = pubsub.topics
|
2
|
+
class Sync < Thor
|
3
|
+
desc "pubsub", "Sync Worker Jobs & Google Cloud Pubsub Subscriptions"
|
4
|
+
def pubsub
|
5
|
+
get_topics(workers: get_workers)
|
6
|
+
end
|
14
7
|
|
15
|
-
|
16
|
-
topics.map do |topic|
|
17
|
-
topic.name.gsub("projects/#{project_id}/topics/", "")
|
18
|
-
end
|
8
|
+
private
|
19
9
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
10
|
+
def get_topics(workers: {})
|
11
|
+
project_id = Souls.configuration.project_id
|
12
|
+
pubsub = Google::Cloud::Pubsub.new
|
13
|
+
topics = pubsub.topics
|
24
14
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
create_push_subscription(topic_id: key.to_s)
|
29
|
-
end
|
30
|
-
delete_topic(topic_id: key.to_s) if value == -1
|
15
|
+
topic_names =
|
16
|
+
topics.map do |topic|
|
17
|
+
topic.name.gsub("projects/#{project_id}/topics/", "")
|
31
18
|
end
|
32
|
-
workers
|
33
|
-
end
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
puts("Topic #{topic.name} created.")
|
20
|
+
topic_names.each do |name|
|
21
|
+
value = workers[name.to_sym] || 0
|
22
|
+
workers[name.to_sym] = value - 1
|
39
23
|
end
|
40
24
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
25
|
+
workers.each do |key, value|
|
26
|
+
if value == 1
|
27
|
+
create_topic(topic_id: key.to_s)
|
28
|
+
create_push_subscription(topic_id: key.to_s)
|
29
|
+
end
|
30
|
+
delete_topic(topic_id: key.to_s) if value == -1
|
46
31
|
end
|
32
|
+
workers
|
33
|
+
end
|
47
34
|
|
48
|
-
|
49
|
-
|
50
|
-
|
35
|
+
def create_topic(topic_id: "mailer")
|
36
|
+
pubsub = Google::Cloud::Pubsub.new
|
37
|
+
topic = pubsub.create_topic(topic_id)
|
38
|
+
puts("Topic #{topic.name} created.")
|
39
|
+
end
|
51
40
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
41
|
+
def delete_topic(topic_id: "mailer")
|
42
|
+
pubsub = Google::Cloud::Pubsub.new
|
43
|
+
topic = pubsub.topic(topic_id)
|
44
|
+
topic.delete
|
45
|
+
puts("Topic #{topic_id} deleted.")
|
46
|
+
end
|
58
47
|
|
59
|
-
|
48
|
+
def create_push_subscription(topic_id: "mailer")
|
49
|
+
require("#{Souls.get_mother_path}/config/souls")
|
50
|
+
worker_name = topic_id.split("_")[0]
|
60
51
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
52
|
+
subscription_id = "#{topic_id}_sub"
|
53
|
+
endpoint = ""
|
54
|
+
worker_paths = Souls.configuration.workers
|
55
|
+
worker_paths.each do |worker|
|
56
|
+
endpoint = worker[:endpoint] if worker[:name] == worker_name
|
65
57
|
end
|
66
58
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
59
|
+
pubsub = Google::Cloud::Pubsub.new
|
60
|
+
|
61
|
+
topic = pubsub.topic(topic_id)
|
62
|
+
sub = topic.subscribe(subscription_id, endpoint: endpoint, deadline: 20)
|
63
|
+
sub.expires_in = nil
|
64
|
+
puts("Push subscription #{subscription_id} created.")
|
65
|
+
end
|
66
|
+
|
67
|
+
def get_workers
|
68
|
+
require("#{Souls.get_mother_path}/config/souls")
|
69
|
+
worker_paths = Souls.configuration.workers.map { |n| n[:name] }
|
70
|
+
response = {}
|
71
|
+
Dir.chdir(Souls.get_mother_path.to_s) do
|
72
|
+
worker_paths.each do |worker|
|
73
|
+
mailers =
|
74
|
+
Dir["apps/#{worker}/app/graphql/mutations/mailers/*.rb"].map do |file|
|
75
|
+
file.gsub("apps/#{worker}/app/graphql/mutations/mailers/", "").gsub(".rb", "")
|
76
|
+
end
|
77
77
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
end
|
82
|
-
workers.delete("base_mutation")
|
83
|
-
local_files = mailers + workers
|
84
|
-
local_files.each do |file|
|
85
|
-
response[:"#{worker}_#{file}"] = 1
|
78
|
+
workers =
|
79
|
+
Dir["apps/#{worker}/app/graphql/mutations/*.rb"].map do |file|
|
80
|
+
file.gsub("apps/#{worker}/app/graphql/mutations/", "").gsub(".rb", "")
|
86
81
|
end
|
82
|
+
workers.delete("base_mutation")
|
83
|
+
local_files = mailers + workers
|
84
|
+
local_files.each do |file|
|
85
|
+
response[:"#{worker}_#{file}"] = 1
|
87
86
|
end
|
88
87
|
end
|
89
|
-
response
|
90
88
|
end
|
89
|
+
response
|
91
90
|
end
|
92
91
|
end
|
93
92
|
end
|