souls 0.40.0 → 0.41.0

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: 1fbe1578d6e8e0cb026243d7796df2e826a3c8850151de318170f8a80afb2879
4
- data.tar.gz: 5b22531a5e03fcd18494ff61e0cfc28e6699ef7a5b526c91c04450d5a9db62af
3
+ metadata.gz: df2f39add13ab11ad55c08ea91fb0c36bb310360c78ec6afd39456cdb6055f0d
4
+ data.tar.gz: 5feca9108b6cdaa7fdc84064f58aba6213c42ea803333180f49dbfceca33055a
5
5
  SHA512:
6
- metadata.gz: 0dfdb6a0bf05853ded99da0a75f73005f02129ba78c5c23dabd58c6e8073d7d04a74fb0f9fb50fbe4c6d5ecbb7015da57005059aac89ecb70a435c9145db7b74
7
- data.tar.gz: aab8c8adb4ef5da4f0855a9b3d4aa9f5a3244a1f17228754d64daf4c2232466e6fcba0e700a3ab6162b68222af33045c4f38fa15acfddc93e83ab756ba3737a2
6
+ metadata.gz: 2206bc5906aaa1530d7ec2207f53cf9ddb4ad4930e527609cac18fd591de0c08d4773fc6cf53289928daf897b424f334539a48d9b8a53aeea45a8c843c85a721
7
+ data.tar.gz: 0fbc64fbedb1bcedb240b042310c6e3ae72b89b03f83909b2ef3e90c386f02e9e9f5dcb032abe140dc2762ca1eaa4fa808cbd2c9aa85fa8e1fb30961c7c808a9
data/exe/souls CHANGED
@@ -135,24 +135,12 @@ begin
135
135
  when "release"
136
136
  Souls::Release.gem_release
137
137
  when "sync"
138
- target = ARGV[1]
139
- case target
140
- when "model", "m"
141
- status = Paint["Syncing Models...", :yellow]
142
- Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
143
- Whirly.status = status
144
- Souls::Sync.model
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]
153
- end
154
- else
155
- puts(Paint["Comannd doesn't exist.Check you command again!...", :red])
138
+ method_name = ARGV[1]
139
+ status = Paint["Syncing Files...", :yellow]
140
+ Whirly.start(spinner: "clock", interval: 420, stop: "🎉") do
141
+ Whirly.status = status
142
+ Souls::Sync..public_send(method_name)
143
+ Whirly.status = Paint["Synced!", :green]
156
144
  end
157
145
  when "create"
158
146
  service_name = ARGV[1]
@@ -2,7 +2,7 @@ module Souls
2
2
  module Gcloud
3
3
  module Run
4
4
  class << self
5
- def awake(app_name: "souls-app", url: "")
5
+ def awake(app_name: "", url: "")
6
6
  app_name = Souls.configuration.app if app_name.blank?
7
7
  system(
8
8
  "gcloud scheduler jobs create http #{app_name}-awake
@@ -10,6 +10,18 @@ module Souls
10
10
  --root-password='#{root_pass}' --database-flags cloudsql.iam_authentication=on"
11
11
  )
12
12
  end
13
+
14
+ def pathch_instance(instance_name: "")
15
+ app_name = Souls.configuration.app
16
+ instance_name = "#{Souls.configuration.app}-db" if instance_name.blank?
17
+ project_id = Souls.configuration.project_id
18
+ system(
19
+ "gcloud beta sql instances patch #{instance_name} \
20
+ --project=#{project_id} \
21
+ --network=#{app_name} \
22
+ --no-assign-ip"
23
+ )
24
+ end
13
25
  end
14
26
  end
15
27
  end
@@ -0,0 +1,46 @@
1
+ module Souls
2
+ module Sync
3
+ class << self
4
+ def conf
5
+ update_conf
6
+ update_conf(strain: "api")
7
+ end
8
+
9
+ def update_conf(strain: "mother")
10
+ workers = Souls.configuration.workers
11
+ file_path = strain == "mother" ? "config/souls.rb" : "apps/api/config/souls.rb"
12
+ new_file_path = "souls.rb"
13
+ worker_switch = false
14
+ File.open(new_file_path, "w") do |new_line|
15
+ File.open(file_path, "r") do |f|
16
+ f.each_line do |line|
17
+ worker_switch = true if line.include?("config.workers")
18
+ next if line.strip == "end"
19
+
20
+ new_line.write(line) unless worker_switch
21
+
22
+ next unless worker_switch
23
+
24
+ new_line.write(" config.workers = [\n")
25
+ workers.each do |worker|
26
+ endpoint = Souls::Gcloud::Run.get_endpoint(worker_name: worker[:name])
27
+ new_line.write(<<-TEXT)
28
+ {
29
+ name: "#{worker[:name]}",
30
+ endpoint: "#{endpoint}/endpoint",
31
+ port: #{worker[:port]}
32
+ },
33
+ TEXT
34
+ end
35
+ break
36
+ end
37
+ end
38
+ new_line.write(<<-TEXT)
39
+ ]
40
+ end
41
+ TEXT
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,3 +1,4 @@
1
1
  require "google/cloud/pubsub"
2
2
  require_relative "./model"
3
3
  require_relative "./pubsub"
4
+ require_relative "./conf"
@@ -12,7 +12,6 @@ module Souls
12
12
  pubsub = Google::Cloud::Pubsub.new
13
13
  topics = pubsub.topics
14
14
 
15
- puts("Topics in project:")
16
15
  topic_names =
17
16
  topics.map do |topic|
18
17
  topic.name.gsub("projects/#{project_id}/topics/", "")
@@ -24,7 +23,10 @@ module Souls
24
23
  end
25
24
 
26
25
  workers.each do |key, value|
27
- create_topic(topic_id: key) if value == 1
26
+ if value == 1
27
+ create_topic(topic_id: key)
28
+ create_push_subscription(topic_id: key)
29
+ end
28
30
  delete_topic(topic_id: key) if value == -1
29
31
  end
30
32
  workers
@@ -43,6 +45,24 @@ module Souls
43
45
  puts("Topic #{topic_id} deleted.")
44
46
  end
45
47
 
48
+ def create_push_subscription(topic_id: "mailer")
49
+ require("#{Souls.get_mother_path}/config/souls")
50
+ worker_name = topic_id.split("_")[0]
51
+
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
57
+ end
58
+
59
+ pubsub = Google::Cloud::Pubsub.new
60
+
61
+ topic = pubsub.topic(topic_id)
62
+ topic.subscribe(subscription_id, endpoint: endpoint)
63
+ puts("Push subscription #{subscription_id} created.")
64
+ end
65
+
46
66
  def get_workers
47
67
  require("#{Souls.get_mother_path}/config/souls")
48
68
  worker_paths = Souls.configuration.workers.map { |n| n[:name] }
data/lib/souls/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Souls
2
- VERSION = "0.40.0".freeze
2
+ VERSION = "0.41.0".freeze
3
3
  public_constant :VERSION
4
4
  end
@@ -1 +1 @@
1
- 0.19.0
1
+ 0.20.0
@@ -1 +1 @@
1
- 0.19.0
1
+ 0.20.0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: souls
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.40.0
4
+ version: 0.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
8
8
  - KishiTheMechanic
9
9
  - James Neve
10
- autorequire:
10
+ autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
13
  date: 2021-09-04 00:00:00.000000000 Z
@@ -152,6 +152,7 @@ files:
152
152
  - lib/souls/cli/index.rb
153
153
  - lib/souls/cli/release/index.rb
154
154
  - lib/souls/cli/release/release.rb
155
+ - lib/souls/cli/sync/conf.rb
155
156
  - lib/souls/cli/sync/index.rb
156
157
  - lib/souls/cli/sync/model.rb
157
158
  - lib/souls/cli/sync/pubsub.rb
@@ -174,7 +175,7 @@ metadata:
174
175
  homepage_uri: https://souls.elsoul.nl
175
176
  source_code_uri: https://github.com/elsoul/souls
176
177
  changelog_uri: https://github.com/elsoul/souls
177
- post_install_message:
178
+ post_install_message:
178
179
  rdoc_options: []
179
180
  require_paths:
180
181
  - lib
@@ -190,7 +191,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
190
191
  version: '0'
191
192
  requirements: []
192
193
  rubygems_version: 3.2.22
193
- signing_key:
194
+ signing_key:
194
195
  specification_version: 4
195
196
  summary: SOULs はサーバーレスフルスタックフレームワークです。柔軟な Ruby GraphQL API と Worker はルーティングの必要がありません。
196
197
  クラウド環境への自動デプロイ、CI/CD ワークフローを標準装備。開発者がビジネスロジックに集中し、楽しくコードが書けるような環境を目指しています。