souls 0.38.5 → 0.40.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 57e0cfc8aff16ebc5d9fd873249ce97234b93abe6f95705841fc24cd8cbf7a95
4
- data.tar.gz: 86e60dbfea5ec5b8fba12b9e6cac9818420f7648253681d94cb46e6b64da84cb
3
+ metadata.gz: e777d40acc58d576ed2f737e9524903c29e2cfe6a5242cbfa90ffa76292df395
4
+ data.tar.gz: e793146caaf8286f1240441e0b9bfdc789f0aa3bc64bd231482d2da49586a905
5
5
  SHA512:
6
- metadata.gz: 52fa18a4e2d590e1970436d7bb0c96cadf6f814aba9eff998408491431fb94dc7fe5037b4fb281ddbc79b0d6d256ba2c1e1040a8c1fd9879fee075b66c727958
7
- data.tar.gz: cb59910b2cd27a5866c17a061f5621e9406bf4672cf4f53badda89d46516db6b98d6e76d7bab7f53c6cc2a363c29771561955d9625be1d1b87553d15b4ba12ec
6
+ metadata.gz: b9873772fe08923d77ba44a5c7a773689914f625060f30f6c16ec907cac2e07606ab0f0702973e7ff8d115fcb6bc2f6d3ec1567d67c66553ae8a75e9957f7247
7
+ data.tar.gz: a1fb4a32637d210e27a42ee6d3755eb0089054a6841e00553d6705a08bad77279efeb4abf1fc0c0a9ff4746e94e979b19ece86b98b7df71491a5afe66260c431
data/exe/souls CHANGED
@@ -142,7 +142,14 @@ begin
142
142
  Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
143
143
  Whirly.status = status
144
144
  Souls::Sync.model
145
- Whirly.status = Paint["API and Worker Both Models Synced!", :green]
145
+ Whirly.status = Paint["API and Workers Models Synced!", :green]
146
+ end
147
+ when "pubsub"
148
+ status = Paint["Syncing PubSub...", :yellow]
149
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
150
+ Whirly.status = status
151
+ Souls::Sync.pubsub
152
+ Whirly.status = Paint["Workers and Google Cloud PubSub Synced!", :green]
146
153
  end
147
154
  else
148
155
  puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
@@ -8,6 +8,7 @@ module Souls
8
8
  create_firewall_ssh(app_name: app_name)
9
9
  create_subnet(app_name: app_name, region: region, range: range)
10
10
  create_connector(app_name: app_name, region: region)
11
+ create_router(app_name: app_name, region: region)
11
12
  create_external_ip(app_name: app_name, region: region)
12
13
  create_nat(app_name: app_name, region: region)
13
14
  nat_credit(app_name: app_name)
@@ -53,6 +54,11 @@ module Souls
53
54
  )
54
55
  end
55
56
 
57
+ def create_router(app_name: "", region: "asia-northeast1")
58
+ app_name = Souls.configuration.app if app_name.blank?
59
+ system("gcloud compute routers create #{app_name}-router --network=#{app_name} --region=#{region}")
60
+ end
61
+
56
62
  def create_external_ip(app_name: "", region: "asia-northeast1")
57
63
  app_name = Souls.configuration.app if app_name.blank?
58
64
  system("gcloud compute addresses create #{app_name}-worker-ip --region=#{region}")
@@ -62,7 +68,7 @@ module Souls
62
68
  app_name = Souls.configuration.app if app_name.blank?
63
69
  system(
64
70
  "gcloud compute routers nats create #{app_name}-worker-nat \
65
- --router=#{app_name}-connector \
71
+ --router=#{app_name}-router \
66
72
  --region=#{region} \
67
73
  --nat-custom-subnet-ip-ranges=#{app_name}-subnet \
68
74
  --nat-external-ip-pool=#{app_name}-worker-ip"
@@ -99,7 +105,7 @@ module Souls
99
105
 
100
106
  Edit `.github/workflow/worker.yml`
101
107
 
102
- Add these 2 options in `- name: Deploy to Cloud Run` step
108
+ Add these 2 options in \n`- name: Deploy to Cloud Run` step
103
109
  \n--vpc-connector=#{app_name}-connector \
104
110
  \n--vpc-egress=all \
105
111
 
@@ -1 +1,3 @@
1
+ require "google/cloud/pubsub"
1
2
  require_relative "./model"
3
+ require_relative "./pubsub"
@@ -0,0 +1,71 @@
1
+ module Souls
2
+ module Sync
3
+ class << self
4
+ def pubsub
5
+ get_topics(workers: get_workers)
6
+ end
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
14
+
15
+ topic_names =
16
+ topics.map do |topic|
17
+ topic.name.gsub("projects/#{project_id}/topics/", "")
18
+ end
19
+
20
+ topic_names.each do |name|
21
+ value = workers[name.to_sym] || 0
22
+ workers[name.to_sym] = value - 1
23
+ end
24
+
25
+ workers.each do |key, value|
26
+ create_topic(topic_id: key) if value == 1
27
+ delete_topic(topic_id: key) if value == -1
28
+ end
29
+ workers
30
+ end
31
+
32
+ def create_topic(topic_id: "mailer")
33
+ pubsub = Google::Cloud::Pubsub.new
34
+ topic = pubsub.create_topic(topic_id)
35
+ puts("Topic #{topic.name} created.")
36
+ end
37
+
38
+ def delete_topic(topic_id: "mailer")
39
+ pubsub = Google::Cloud::Pubsub.new
40
+ topic = pubsub.topic(topic_id)
41
+ topic.delete
42
+ puts("Topic #{topic_id} deleted.")
43
+ end
44
+
45
+ def get_workers
46
+ require("#{Souls.get_mother_path}/config/souls")
47
+ worker_paths = Souls.configuration.workers.map { |n| n[:name] }
48
+ response = {}
49
+ Dir.chdir(Souls.get_mother_path.to_s) do
50
+ worker_paths.each do |worker|
51
+ mailers =
52
+ Dir["apps/#{worker}/app/graphql/mutations/mailers/*.rb"].map do |file|
53
+ file.gsub("apps/#{worker}/app/graphql/mutations/mailers/", "").gsub(".rb", "")
54
+ end
55
+
56
+ workers =
57
+ Dir["apps/#{worker}/app/graphql/mutations/*.rb"].map do |file|
58
+ file.gsub("apps/#{worker}/app/graphql/mutations/", "").gsub(".rb", "")
59
+ end
60
+ workers.delete("base_mutation")
61
+ local_files = mailers + workers
62
+ local_files.each do |file|
63
+ response[:"#{worker}_#{file}"] = 1
64
+ end
65
+ end
66
+ end
67
+ response
68
+ end
69
+ end
70
+ end
71
+ end
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.38.5".freeze
2
+ VERSION = "0.40.1".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.17.5
1
+ 0.19.1
@@ -1 +1 @@
1
- 0.17.5
1
+ 0.19.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.38.5
4
+ version: 0.40.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2021-09-02 00:00:00.000000000 Z
13
+ date: 2021-09-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -40,6 +40,20 @@ dependencies:
40
40
  - - ">="
41
41
  - !ruby/object:Gem::Version
42
42
  version: 0.87.2
43
+ - !ruby/object:Gem::Dependency
44
+ name: google-cloud-pubsub
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: 2.8.0
50
+ type: :runtime
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 2.8.0
43
57
  - !ruby/object:Gem::Dependency
44
58
  name: paint
45
59
  requirement: !ruby/object:Gem::Requirement
@@ -140,6 +154,7 @@ files:
140
154
  - lib/souls/cli/release/release.rb
141
155
  - lib/souls/cli/sync/index.rb
142
156
  - lib/souls/cli/sync/model.rb
157
+ - lib/souls/cli/sync/pubsub.rb
143
158
  - lib/souls/cli/upgrade/gem_update.rb
144
159
  - lib/souls/cli/upgrade/index.rb
145
160
  - lib/souls/index.rb