souls 0.8.0 → 0.8.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: 560643126ebd83bbba6b537f3df4ff4dab5e071a4f5eaf95c4c80b41dfad178c
4
- data.tar.gz: 82f2814417af32ed219cd812c5f3f03239f6e612bbe357b70b98f61e31570ca3
3
+ metadata.gz: c2f7f929b1640d3a618f6244944f72ff08a1fc51136d1bb276a4c19a24bc0076
4
+ data.tar.gz: df57c53de699968a8e0d781803fc0627b04ef94d29f0eecb82f51e9ff736dd50
5
5
  SHA512:
6
- metadata.gz: ee757a67e212e058cc07b35bc8d4c74af030e9e60a7e58312623349ea5c5a6bed113ff769dcdc2eb755a7445bad7e13ba5a069636be6be18f30bfe4f34f69486
7
- data.tar.gz: 97327b26bba04c5f4c8699540fa6a4708084c7d01a34730fb463d66a1b70ee41833c306cf4d8a9c3cc6daeff7a3d7c835ea15a7146d96f93a5dafba415369045
6
+ metadata.gz: b14c6586602a8fc1745b50c11564936d896bd5b34996edf552d82a22a69cbebc1d926625974f1a9dd4f908dd2e3efe82144521cdec277e08d439fb268aeec4a8
7
+ data.tar.gz: 33d4ed28ecb5fa0260f50c964ac7669dc1f6294ab8caefea5923b1148c172e4c8f453bc01d9d926bc4b9a6efff2e6cc972f77fc6b9a5967e7a41d96917313a4b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- souls (0.7.9)
4
+ souls (0.8.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/exe/souls CHANGED
@@ -2,7 +2,11 @@
2
2
  require "souls"
3
3
 
4
4
  begin
5
- require "./config/initializers/souls" unless ARGV[0] == "new"
5
+ begin
6
+ require "./config/initializers/souls" unless ARGV[0] == "new"
7
+ rescue
8
+ Souls::Init.config_init
9
+ end
6
10
  case ARGV[0]
7
11
  when "new"
8
12
  if ARGV[1].nil?
@@ -38,7 +42,7 @@ begin
38
42
  when "p", "proto"
39
43
  Souls::Init.proto proto_package_name: "souls", service: ARGV[1]
40
44
  when "init"
41
- Souls::Init.config
45
+ Souls::Init.config_init
42
46
  when "-v", "--version"
43
47
  puts Souls::VERSION
44
48
  when "g", "generate"
@@ -49,6 +49,7 @@ module Souls
49
49
  end
50
50
 
51
51
  def config_init app_name: "souls", project: {}
52
+ puts "Generating souls conf..."
52
53
  file_path = "#{app_name}/config/initializers/souls.rb"
53
54
  File.open(file_path, "w") do |f|
54
55
  f.write <<~EOS
@@ -83,7 +84,7 @@ module Souls
83
84
  system "tar -zxvf ./#{version}.tar.gz"
84
85
  system "mkdir #{app_name}"
85
86
  folder = version.delete "v"
86
- system "cp -aiv #{repository_name}-#{folder}/* #{app_name}/"
87
+ system "cp -r #{repository_name}-#{folder}/ #{app_name}/"
87
88
  system "rm -rf #{version}.tar.gz && rm -rf #{repository_name}-#{folder}"
88
89
  txt = <<~TEXT
89
90
  _____ ____ __ ____
@@ -103,13 +104,6 @@ module Souls
103
104
 
104
105
  def proto proto_package_name: "souls", service: "blog"
105
106
  system "grpc_tools_ruby_protoc -I ./protos --ruby_out=./app/services --grpc_out=./app/services ./protos/#{service}.proto"
106
- file_path = "./app/services/#{service}_pb.rb"
107
- File.open(file_path, "a") do |f|
108
- f.write <<~EOS
109
- module #{service.capitalize}Pb
110
- end
111
- EOS
112
- end
113
107
  service_pb_path = "./app/services/#{service}_services_pb.rb"
114
108
  new_file = "./app/services/#{proto_package_name}.rb"
115
109
  File.open(new_file, "w") do |new_line|
@@ -120,8 +114,6 @@ module Souls
120
114
  new_line.write "# Generated by the SOULs protocol buffer compiler. DO NOT EDIT!\n"
121
115
  when 3
122
116
  next
123
- when 4
124
- new_line.write "require_relative \"#{service}_pb\""
125
117
  else
126
118
  puts "#{i}: #{line}"
127
119
  new_line.write line.to_s
@@ -1,3 +1,3 @@
1
1
  module Souls
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
@@ -0,0 +1 @@
1
+ GOOGLE_APPLICATION_CREDENTIALS="./config/keyfile.json"
@@ -0,0 +1,31 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+ .DS_Store
10
+ # Ignore all logfiles and tempfiles.
11
+ /log/*
12
+ /tmp/*
13
+ !/log/.keep
14
+ !/tmp/.keep
15
+
16
+ # Ignore pidfiles, but keep the directory.
17
+ /tmp/pids/*
18
+ !/tmp/pids/
19
+ !/tmp/pids/.keep
20
+
21
+ # Ignore uploaded files in development.
22
+ /storage/*
23
+ !/storage/.keep
24
+ .byebug_history
25
+
26
+ # Ignore master key for decrypting credentials and more.
27
+ /config/master.key
28
+ .irb_history
29
+ .idea
30
+ .env
31
+ /config/keyfile.json
@@ -0,0 +1,2 @@
1
+ require "./app"
2
+ require "google/cloud/firestore"
@@ -0,0 +1,212 @@
1
+ AllCops:
2
+ EnabledByDefault: true
3
+ Exclude:
4
+ - "db/migrate/*.rb"
5
+ - "db/schema.rb"
6
+ - "app/services/*.rb"
7
+
8
+ Style/AndOr:
9
+ Enabled: false
10
+
11
+ Style/ClassAndModuleChildren:
12
+ Enabled: false
13
+
14
+ Style/AsciiComments:
15
+ Enabled: false
16
+
17
+ Style/SymbolArray:
18
+ Enabled: false
19
+
20
+ Style/WordArray:
21
+ Enabled: false
22
+
23
+ Style/MixinGrouping:
24
+ Enabled: false
25
+
26
+ Style/RescueStandardError:
27
+ Enabled: false
28
+
29
+ Style/MethodCallWithArgsParentheses:
30
+ Enabled: false
31
+
32
+ Style/DocumentationMethod:
33
+ Enabled: false
34
+
35
+ Style/CollectionMethods:
36
+ PreferredMethods:
37
+ detect: "detect"
38
+ find: "detect"
39
+ inject: "inject"
40
+ reduce: "inject"
41
+
42
+ Style/Documentation:
43
+ Enabled: false
44
+
45
+ Style/DoubleNegation:
46
+ Enabled: false
47
+
48
+ Lint/ConstantResolution:
49
+ Enabled: false
50
+
51
+ Layout/DotPosition:
52
+ EnforcedStyle: trailing
53
+
54
+
55
+ Layout/EmptyLineAfterGuardClause:
56
+ Enabled: false
57
+
58
+ Style/EmptyElse:
59
+ EnforcedStyle: empty
60
+
61
+ Layout/ExtraSpacing:
62
+ Exclude:
63
+ - "db/migrate/*.rb"
64
+ - "*.gemspec"
65
+
66
+ Style/FormatString:
67
+ EnforcedStyle: percent
68
+
69
+ Style/MissingElse:
70
+ Enabled: false
71
+
72
+ Style/StringHashKeys:
73
+ Exclude:
74
+ - "spec/queries/*.rb"
75
+ - "*.gemspec"
76
+
77
+ Style/GuardClause:
78
+ MinBodyLength: 5
79
+ Exclude:
80
+ - "spec/spec_helper.rb"
81
+
82
+ Style/HashSyntax:
83
+ EnforcedStyle: ruby19
84
+ Exclude:
85
+ - "**/*.rake"
86
+ - "Rakefile"
87
+
88
+ Style/IfUnlessModifier:
89
+ Enabled: false
90
+
91
+ Style/PreferredHashMethods:
92
+ EnforcedStyle: short
93
+
94
+ Style/Lambda:
95
+ Enabled: false
96
+
97
+ Style/NumericLiterals:
98
+ MinDigits: 7
99
+
100
+ Style/PerlBackrefs:
101
+ AutoCorrect: false
102
+
103
+ Style/RedundantSelf:
104
+ Enabled: false
105
+
106
+ Style/FrozenStringLiteralComment:
107
+ Enabled: false
108
+
109
+ Style/RedundantReturn:
110
+ AllowMultipleReturnValues: true
111
+
112
+ Style/Semicolon:
113
+ Exclude:
114
+ - "spec/**/*"
115
+
116
+ Style/SignalException:
117
+ EnforcedStyle: only_raise
118
+
119
+ Style/MethodDefParentheses:
120
+ Enabled: false
121
+
122
+ Style/StringLiterals:
123
+ EnforcedStyle: double_quotes
124
+
125
+ Style/StringLiteralsInInterpolation:
126
+ Enabled: false
127
+
128
+ Style/SingleLineBlockParams:
129
+ Enabled: false
130
+
131
+ Lint/UnderscorePrefixedVariableName:
132
+ Enabled: false
133
+
134
+ Lint/UnusedMethodArgument:
135
+ Enabled: false
136
+
137
+
138
+ Metrics/AbcSize:
139
+ Enabled: false
140
+
141
+ Metrics/CyclomaticComplexity:
142
+ Max: 10
143
+
144
+ Metrics/PerceivedComplexity:
145
+ Enabled: false
146
+
147
+ Metrics/BlockLength:
148
+ Enabled: false
149
+
150
+ Layout/LineLength:
151
+ Enabled: false
152
+
153
+
154
+ Metrics/MethodLength:
155
+ Enabled: false
156
+
157
+ Metrics/ClassLength:
158
+ Enabled: false
159
+
160
+ Naming/HeredocDelimiterNaming:
161
+ Enabled: false
162
+
163
+ Naming/AccessorMethodName:
164
+ Enabled: false
165
+
166
+ Metrics/ModuleLength:
167
+ Enabled: false
168
+
169
+ Lint/UnusedBlockArgument:
170
+ Enabled: false
171
+
172
+ Lint/RescueException:
173
+ Enabled: false
174
+
175
+ Naming/RescuedExceptionsVariableName:
176
+ Enabled: false
177
+
178
+ Bundler/GemComment:
179
+ Enabled: false
180
+
181
+ Style/SafeNavigation:
182
+ Enabled: false
183
+
184
+ Lint/NumberConversion:
185
+ Enabled: false
186
+ Style/ConstantVisibility:
187
+ Enabled: false
188
+ Style/MutableConstant:
189
+ Enabled: false
190
+ Style/Copyright:
191
+ Enabled: false
192
+ Style/MultilineTernaryOperator:
193
+ Enabled: false
194
+ Layout/MultilineAssignmentLayout:
195
+ Enabled: false
196
+ Style/Send:
197
+ Enabled: false
198
+ Style/MixinUsage:
199
+ Enabled: false
200
+ Style/GlobalStdStream:
201
+ Enabled: false
202
+ Lint/ConstantDefinitionInBlock:
203
+ Enabled: false
204
+ Layout/TrailingEmptyLines:
205
+ Enabled: false
206
+ Style/PercentLiteralDelimiters:
207
+ Enabled: false
208
+ Style/ClassVars:
209
+ Exclude:
210
+ - "spec/spec_helper.rb"
211
+ Style/StringConcatenation:
212
+ Enabled: false
@@ -0,0 +1 @@
1
+ 2.7.2
@@ -0,0 +1 @@
1
+ 2.7.2
@@ -0,0 +1,16 @@
1
+ FROM ruby:2.7.2
2
+ RUN apt-get update -qq && apt-get install -y nodejs postgresql-client
3
+
4
+ USER root
5
+
6
+ RUN mkdir /myapp
7
+ WORKDIR /myapp
8
+
9
+ COPY Gemfile /myapp/Gemfile
10
+ COPY Gemfile.lock /myapp/Gemfile.lock
11
+ RUN gem install bundler:2.1.4
12
+ RUN bundle
13
+ COPY . /myapp
14
+
15
+ EXPOSE 50051
16
+ CMD ["rake", "run_server"]
@@ -0,0 +1,41 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "activerecord", require: "active_record"
4
+ gem "dotenv", "2.7.6"
5
+ gem "grpc", "1.34.0"
6
+ gem "grpc-tools", "1.34.0"
7
+ gem "jwt", "2.2.2"
8
+ gem "rake", "13.0.3"
9
+ gem "zeitwerk", "2.4.2"
10
+
11
+ ## Select DB gem.
12
+ # Firestore
13
+ gem "google-cloud-firestore"
14
+
15
+ # NoSQL
16
+ # gem "mongoid", "7.2"
17
+
18
+ # PostgreSQL
19
+ # gem "pg", ">= 0.18", "< 2.0"
20
+
21
+ group :development, :test do
22
+ gem "byebug", platforms: %i[mri mingw x64_mingw]
23
+ gem "capybara", "2.18.0"
24
+ gem "capybara-user_agent", "0.0.3"
25
+ gem "database_cleaner", "1.8.5"
26
+ gem "factory_bot", "6.1.0"
27
+ gem "faker", "2.15.1"
28
+ gem "rack-test", "1.1.0"
29
+ gem "rspec", "3.10.0"
30
+ gem "rubocop", "1.7.0"
31
+ gem "souls", "0.8.0"
32
+ gem "webmock", "3.11.0"
33
+ end
34
+
35
+ group :development do
36
+ gem "listen", "~> 3.2"
37
+ gem "spring", "2.1.0"
38
+ gem "spring-watcher-listen", "~> 2.0.0"
39
+ end
40
+
41
+ gem "tzinfo-data", platforms: %i[mingw mswin x64_mingw jruby]
@@ -0,0 +1,191 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activemodel (6.1.1)
5
+ activesupport (= 6.1.1)
6
+ activerecord (6.1.1)
7
+ activemodel (= 6.1.1)
8
+ activesupport (= 6.1.1)
9
+ activesupport (6.1.1)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
15
+ addressable (2.7.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ ast (2.4.1)
18
+ byebug (11.1.3)
19
+ capybara (2.18.0)
20
+ addressable
21
+ mini_mime (>= 0.1.3)
22
+ nokogiri (>= 1.3.3)
23
+ rack (>= 1.0.0)
24
+ rack-test (>= 0.5.4)
25
+ xpath (>= 2.0, < 4.0)
26
+ capybara-user_agent (0.0.3)
27
+ capybara (~> 2.0, >= 2.0.2)
28
+ concurrent-ruby (1.1.7)
29
+ crack (0.4.5)
30
+ rexml
31
+ database_cleaner (1.8.5)
32
+ diff-lcs (1.4.4)
33
+ dotenv (2.7.6)
34
+ factory_bot (6.1.0)
35
+ activesupport (>= 5.0.0)
36
+ faker (2.15.1)
37
+ i18n (>= 1.6, < 2)
38
+ faraday (1.2.0)
39
+ multipart-post (>= 1.2, < 3)
40
+ ruby2_keywords
41
+ ffi (1.14.2)
42
+ foreman (0.87.2)
43
+ gapic-common (0.3.4)
44
+ google-protobuf (~> 3.12, >= 3.12.2)
45
+ googleapis-common-protos (>= 1.3.9, < 2.0)
46
+ googleapis-common-protos-types (>= 1.0.4, < 2.0)
47
+ googleauth (~> 0.9)
48
+ grpc (~> 1.25)
49
+ google-cloud-core (1.5.0)
50
+ google-cloud-env (~> 1.0)
51
+ google-cloud-errors (~> 1.0)
52
+ google-cloud-env (1.4.0)
53
+ faraday (>= 0.17.3, < 2.0)
54
+ google-cloud-errors (1.0.1)
55
+ google-cloud-firestore (2.4.0)
56
+ concurrent-ruby (~> 1.0)
57
+ google-cloud-core (~> 1.5)
58
+ google-cloud-firestore-v1 (~> 0.0)
59
+ rbtree (~> 0.4.2)
60
+ google-cloud-firestore-v1 (0.2.2)
61
+ gapic-common (~> 0.3)
62
+ google-cloud-errors (~> 1.0)
63
+ google-protobuf (3.14.0)
64
+ googleapis-common-protos (1.3.10)
65
+ google-protobuf (~> 3.11)
66
+ googleapis-common-protos-types (>= 1.0.5, < 2.0)
67
+ grpc (~> 1.27)
68
+ googleapis-common-protos-types (1.0.5)
69
+ google-protobuf (~> 3.11)
70
+ googleauth (0.14.0)
71
+ faraday (>= 0.17.3, < 2.0)
72
+ jwt (>= 1.4, < 3.0)
73
+ memoist (~> 0.16)
74
+ multi_json (~> 1.11)
75
+ os (>= 0.9, < 2.0)
76
+ signet (~> 0.14)
77
+ grpc (1.34.0)
78
+ google-protobuf (~> 3.13)
79
+ googleapis-common-protos-types (~> 1.0)
80
+ grpc-tools (1.34.0)
81
+ hashdiff (1.0.1)
82
+ i18n (1.8.7)
83
+ concurrent-ruby (~> 1.0)
84
+ jwt (2.2.2)
85
+ listen (3.4.1)
86
+ rb-fsevent (~> 0.10, >= 0.10.3)
87
+ rb-inotify (~> 0.9, >= 0.9.10)
88
+ memoist (0.16.2)
89
+ mini_mime (1.0.2)
90
+ mini_portile2 (2.5.0)
91
+ minitest (5.14.3)
92
+ multi_json (1.15.0)
93
+ multipart-post (2.1.1)
94
+ nokogiri (1.11.1)
95
+ mini_portile2 (~> 2.5.0)
96
+ racc (~> 1.4)
97
+ os (1.1.1)
98
+ parallel (1.20.1)
99
+ parser (3.0.0.0)
100
+ ast (~> 2.4.1)
101
+ public_suffix (4.0.6)
102
+ racc (1.5.2)
103
+ rack (2.2.3)
104
+ rack-test (1.1.0)
105
+ rack (>= 1.0, < 3)
106
+ rainbow (3.0.0)
107
+ rake (13.0.3)
108
+ rb-fsevent (0.10.4)
109
+ rb-inotify (0.10.1)
110
+ ffi (~> 1.0)
111
+ rbtree (0.4.2)
112
+ regexp_parser (2.0.2)
113
+ rexml (3.2.4)
114
+ rspec (3.10.0)
115
+ rspec-core (~> 3.10.0)
116
+ rspec-expectations (~> 3.10.0)
117
+ rspec-mocks (~> 3.10.0)
118
+ rspec-core (3.10.1)
119
+ rspec-support (~> 3.10.0)
120
+ rspec-expectations (3.10.1)
121
+ diff-lcs (>= 1.2.0, < 2.0)
122
+ rspec-support (~> 3.10.0)
123
+ rspec-mocks (3.10.1)
124
+ diff-lcs (>= 1.2.0, < 2.0)
125
+ rspec-support (~> 3.10.0)
126
+ rspec-support (3.10.1)
127
+ rubocop (1.7.0)
128
+ parallel (~> 1.10)
129
+ parser (>= 2.7.1.5)
130
+ rainbow (>= 2.2.2, < 4.0)
131
+ regexp_parser (>= 1.8, < 3.0)
132
+ rexml
133
+ rubocop-ast (>= 1.2.0, < 2.0)
134
+ ruby-progressbar (~> 1.7)
135
+ unicode-display_width (>= 1.4.0, < 2.0)
136
+ rubocop-ast (1.3.0)
137
+ parser (>= 2.7.1.5)
138
+ ruby-progressbar (1.10.1)
139
+ ruby2_keywords (0.0.2)
140
+ signet (0.14.0)
141
+ addressable (~> 2.3)
142
+ faraday (>= 0.17.3, < 2.0)
143
+ jwt (>= 1.5, < 3.0)
144
+ multi_json (~> 1.10)
145
+ souls (0.8.0)
146
+ spring (2.1.0)
147
+ spring-watcher-listen (2.0.1)
148
+ listen (>= 2.7, < 4.0)
149
+ spring (>= 1.2, < 3.0)
150
+ tzinfo (2.0.4)
151
+ concurrent-ruby (~> 1.0)
152
+ unicode-display_width (1.7.0)
153
+ webmock (3.11.0)
154
+ addressable (>= 2.3.6)
155
+ crack (>= 0.3.2)
156
+ hashdiff (>= 0.4.0, < 2.0.0)
157
+ xpath (3.2.0)
158
+ nokogiri (~> 1.8)
159
+ zeitwerk (2.4.2)
160
+
161
+ PLATFORMS
162
+ ruby
163
+
164
+ DEPENDENCIES
165
+ activerecord
166
+ byebug
167
+ capybara (= 2.18.0)
168
+ capybara-user_agent (= 0.0.3)
169
+ database_cleaner (= 1.8.5)
170
+ dotenv (= 2.7.6)
171
+ factory_bot (= 6.1.0)
172
+ faker (= 2.15.1)
173
+ foreman (= 0.87.2)
174
+ google-cloud-firestore
175
+ grpc (= 1.34.0)
176
+ grpc-tools (= 1.34.0)
177
+ jwt (= 2.2.2)
178
+ listen (~> 3.2)
179
+ rack-test (= 1.1.0)
180
+ rake (= 13.0.3)
181
+ rspec (= 3.10.0)
182
+ rubocop (= 1.7.0)
183
+ souls (= 0.8.0)
184
+ spring (= 2.1.0)
185
+ spring-watcher-listen (~> 2.0.0)
186
+ tzinfo-data
187
+ webmock (= 3.11.0)
188
+ zeitwerk (= 2.4.2)
189
+
190
+ BUNDLED WITH
191
+ 2.1.4
@@ -0,0 +1,75 @@
1
+ # gRPC Ruby Server
2
+ gRPC Ruby Server Boilerplate
3
+
4
+ <p align="center">
5
+
6
+ <a aria-label="Ruby logo" href="https://el-soul.com">
7
+ <img src="https://badgen.net/badge/icon/Made%20by%20ELSOUL?icon=ruby&label&color=black&labelColor=black">
8
+ </a>
9
+ <br/>
10
+ </p>
11
+
12
+ ## Installation
13
+
14
+ git clone
15
+
16
+ ```
17
+ git clone git@github.com:elsoul/grpc-ruby-server.git
18
+ cd grpc-ruby-server
19
+ bundle install
20
+ ```
21
+
22
+
23
+
24
+ ## Usage
25
+
26
+ Check Rakefile to see what command is available
27
+
28
+ ```ruby
29
+ rake -T
30
+ ```
31
+
32
+
33
+ # Run Server on local
34
+
35
+ ```ruby
36
+ rake run_server
37
+ ```
38
+
39
+ # Run Server with Docker
40
+
41
+ ```ruby
42
+ rake run_test
43
+ ```
44
+
45
+ # Run Client to check response
46
+
47
+ ```ruby
48
+ rake run_client
49
+ ```
50
+
51
+ Then you will get response below;
52
+
53
+ ```
54
+ "Greeting: Hello world"
55
+ "Greeting: Hello again, world"
56
+ ```
57
+
58
+
59
+ ## Development
60
+
61
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+
63
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org/gems/grpc-ruby-server).
64
+
65
+ ## Contributing
66
+
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/elsoul/grpc-ruby-server. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [Apache-2.0 License](https://www.apache.org/licenses/LICENSE-2.0).
72
+
73
+ ## Code of Conduct
74
+
75
+ Everyone interacting in the HotelPrice project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/elsoul/grpc-ruby-server/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,34 @@
1
+ require "yaml"
2
+ require "erb"
3
+ require "logger"
4
+
5
+ desc "Generate proto files"
6
+ task :proto do
7
+ system "grpc_tools_ruby_protoc -I ./protos --ruby_out=./app/services --grpc_out=./app/services ./protos/blog.proto"
8
+ end
9
+
10
+ desc "Run gRPC Server"
11
+ task :run_server do
12
+ system "ruby grpc_server.rb"
13
+ end
14
+
15
+ desc "Run gRPC Client"
16
+ task :run_client do
17
+ system "ruby greeter_client.rb"
18
+ end
19
+
20
+ desc "Run gRPC Server with Docker"
21
+ task :run_test do
22
+ system "docker build . -t souls_service:latest"
23
+ system "docker rm -f web"
24
+ system "docker run --name web -p 50051:50051 souls_service:latest"
25
+ end
26
+
27
+ desc "Update Google Container Registry"
28
+ task :update do
29
+ version = ARGV[1]
30
+ project_id = "elsoul2"
31
+ system("docker build . -t souls_service:#{version}")
32
+ system("docker tag souls_service:#{version} asia.gcr.io/#{project_id}/souls_service:#{version}")
33
+ system("docker push asia.gcr.io/#{project_id}/souls_service:#{version}")
34
+ end
@@ -0,0 +1,26 @@
1
+ require "grpc"
2
+ require "yaml"
3
+ require "erb"
4
+ require "logger"
5
+ require "zeitwerk"
6
+ require "dotenv/load"
7
+ require "google/cloud/firestore"
8
+ require "./app"
9
+
10
+ ENV["SOULS_ENV"] ||= "development"
11
+
12
+ # NoSQL Conf
13
+ # YAML.safe_load(ERB.new(File.new("./config/mongoid.yml").read).result)
14
+
15
+ ## SQL Conf
16
+ # db_conf = YAML.safe_load(ERB.new(File.read("./config/database.yml")).result, [], [], true)
17
+ # ActiveRecord::Base.establish_connection(db_conf[ENV["RACK_ENV"]])
18
+
19
+ loader = Zeitwerk::Loader.new
20
+ loader.push_dir("#{Dir.pwd}/app/controllers")
21
+ loader.push_dir("#{Dir.pwd}/app/services")
22
+ loader.do_not_eager_load("#{Dir.pwd}/app/services")
23
+ loader.collapse("#{__dir__}/app/services")
24
+ loader.setup
25
+
26
+ loader.eager_load
@@ -0,0 +1,3 @@
1
+ class ApplicationController < Souls::Blog::Service
2
+ include ArticleMethod, HelloMethod
3
+ end
@@ -0,0 +1,60 @@
1
+ module ArticleMethod
2
+ def create_article(grpc_req, _unused_call)
3
+ logger = Logger.new(STDOUT)
4
+ firestore = Google::Cloud::Firestore.new
5
+ article = firestore.col("articles").doc
6
+ article.set({})
7
+ data = firestore.col("articles").doc(article.document_id)
8
+ article_hash = {
9
+ id: article.document_id,
10
+ user_id: grpc_req.user_id,
11
+ title: grpc_req.title,
12
+ body: grpc_req.body,
13
+ thumnail_url: grpc_req.thumnail_url,
14
+ public_date: grpc_req.public_date,
15
+ is_public: grpc_req.is_public,
16
+ tag: grpc_req.tag.to_a,
17
+ created_at: Time.now.utc,
18
+ updated_at: Time.now.utc
19
+ }
20
+ data.update article_hash
21
+ res = Souls::CreateArticleReply.new(
22
+ { article: article_hash }
23
+ )
24
+ logger.info res.article
25
+ res
26
+ rescue StandardError => error
27
+ logger.debug error
28
+ end
29
+
30
+ def get_article(grpc_req, _unused_call)
31
+ logger = Logger.new(STDOUT)
32
+ article = Article.find(grpc_req.id)
33
+ reply = JSON.parse(article.to_json)
34
+ reply["created_at"] = article.created_at.to_s
35
+ reply["updated_at"] = article.updated_at.to_s
36
+ res = Souls::GetArticleReply.new(
37
+ { article: Souls::Article.new(reply) }
38
+ )
39
+ logger.info res.article
40
+ res
41
+ rescue StandardError => error
42
+ logger.debug error
43
+ end
44
+
45
+ def get_articles
46
+ return enum_for(:get_articles) unless block_given?
47
+ q = ::Article
48
+ limit = 100
49
+ q.limit(limit).each do |article|
50
+ sleep(rand(0.01..0.3))
51
+ Souls::Article.new article.to_proto
52
+ end
53
+ rescue StandardError => e
54
+ fail!(:internal, :unknown, "Unknown error when listing Articles: #{e.message}")
55
+ end
56
+
57
+ def update_article(grpc_req, _unused_call); end
58
+
59
+ def delete_article(grpc_req, _unused_call); end
60
+ end
@@ -0,0 +1,13 @@
1
+ module HelloMethod
2
+ def say_hello(hello_req, _unused_call)
3
+ logger = Logger.new(STDOUT)
4
+ logger.info hello_req
5
+ Souls::HelloReply.new(message: "Hello #{hello_req.name}")
6
+ end
7
+
8
+ def say_hello_again(hello_req, _unused_call)
9
+ logger = Logger.new(STDOUT)
10
+ logger.info hello_req
11
+ Souls::HelloReply.new(message: "Works Perfect, #{hello_req.name}")
12
+ end
13
+ end
@@ -0,0 +1,69 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: blog.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/protobuf/timestamp_pb'
7
+ Google::Protobuf::DescriptorPool.generated_pool.build do
8
+ add_file("blog.proto", :syntax => :proto3) do
9
+ add_message "Souls.HelloRequest" do
10
+ optional :name, :string, 1
11
+ end
12
+ add_message "Souls.HelloReply" do
13
+ optional :message, :string, 1
14
+ end
15
+ add_message "Souls.Article" do
16
+ optional :id, :string, 1
17
+ optional :user_id, :string, 2
18
+ optional :title, :string, 3
19
+ optional :body, :string, 4
20
+ optional :thumnail_url, :string, 5
21
+ optional :public_date, :uint32, 6
22
+ optional :article_category_id, :uint32, 7
23
+ optional :is_public, :bool, 8
24
+ repeated :tag, :string, 9
25
+ optional :has_series, :bool, 10
26
+ optional :series_id, :uint32, 11
27
+ optional :episode_num, :uint32, 12
28
+ optional :created_at, :message, 13, "google.protobuf.Timestamp"
29
+ optional :updated_at, :message, 14, "google.protobuf.Timestamp"
30
+ end
31
+ add_message "Souls.GetArticlRequest" do
32
+ optional :id, :uint32, 1
33
+ end
34
+ add_message "Souls.GetArticleReply" do
35
+ optional :article, :message, 1, "Souls.Article"
36
+ end
37
+ add_message "Souls.GetArticlesRequest" do
38
+ optional :search, :string, 1
39
+ optional :limit, :uint32, 2
40
+ end
41
+ add_message "Souls.UpdateArticlesReply" do
42
+ repeated :articles, :message, 1, "Souls.Article"
43
+ end
44
+ add_message "Souls.DeleteArticlRequest" do
45
+ optional :id, :uint32, 1
46
+ end
47
+ add_message "Souls.DeleteArticleReply" do
48
+ optional :article, :message, 1, "Souls.Article"
49
+ end
50
+ add_message "Souls.CreateArticleReply" do
51
+ optional :article, :message, 1, "Souls.Article"
52
+ end
53
+ end
54
+ end
55
+
56
+ module Souls
57
+ HelloRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.HelloRequest").msgclass
58
+ HelloReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.HelloReply").msgclass
59
+ Article = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.Article").msgclass
60
+ GetArticlRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.GetArticlRequest").msgclass
61
+ GetArticleReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.GetArticleReply").msgclass
62
+ GetArticlesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.GetArticlesRequest").msgclass
63
+ UpdateArticlesReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.UpdateArticlesReply").msgclass
64
+ DeleteArticlRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.DeleteArticlRequest").msgclass
65
+ DeleteArticleReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.DeleteArticleReply").msgclass
66
+ CreateArticleReply = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("Souls.CreateArticleReply").msgclass
67
+ end
68
+ module BlogPb
69
+ end
@@ -0,0 +1,30 @@
1
+ # Generated by the SOULs protocol buffer compiler. DO NOT EDIT!
2
+ # Source: blog.proto for package 'Souls'
3
+
4
+ require_relative "blog_pb"
5
+ module Souls
6
+ module Blog
7
+ class Service
8
+
9
+ include GRPC::GenericService
10
+
11
+ self.marshal_class_method = :encode
12
+ self.unmarshal_class_method = :decode
13
+ self.service_name = 'Souls.Blog'
14
+
15
+ # Sends a greeting
16
+ rpc :SayHello, ::Souls::HelloRequest, ::Souls::HelloReply
17
+ # Sends another greeting
18
+ rpc :SayHelloAgain, ::Souls::HelloRequest, ::Souls::HelloReply
19
+ # Blog Service Sample
20
+ rpc :GetArticle, ::Souls::GetArticlRequest, ::Souls::GetArticleReply
21
+ rpc :GetArticles, ::Souls::GetArticlesRequest, stream(::Souls::Article)
22
+ rpc :CreateArticle, ::Souls::Article, ::Souls::CreateArticleReply
23
+ rpc :UpdateArticles, stream(::Souls::Article), ::Souls::UpdateArticlesReply
24
+ rpc :DeleteArticle, ::Souls::DeleteArticlRequest, ::Souls::DeleteArticleReply
25
+ rpc :CreateArticlesInStream, stream(::Souls::Article), stream(::Souls::Article)
26
+ end
27
+
28
+ Stub = Service.rpc_stub_class
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ Souls.configure do |config|
2
+ config.project_id = "elsoul2"
3
+ config.app = "blog"
4
+ config.network = "elsoul"
5
+ config.machine_type = "custom-1-6656"
6
+ config.zone = "asia-northeast1-b"
7
+ config.domain = "blog.el-soul.com"
8
+ config.google_application_credentials = "./config/credentials.json"
9
+ config.strain = "service"
10
+ config.proto_package_name = "souls"
11
+ end
@@ -0,0 +1,39 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: souls_service
5
+ annotations:
6
+ cloud.google.com/neg: '{"exposed_ports":{"8080":{}}}'
7
+ spec:
8
+ ports:
9
+ - port: 8080
10
+ name: souls_service
11
+ protocol: TCP
12
+ targetPort: 50051
13
+ selector:
14
+ run: souls_service
15
+ type: ClusterIP
16
+
17
+ ---
18
+ apiVersion: apps/v1
19
+ kind: Deployment
20
+ metadata:
21
+ labels:
22
+ run: souls_service
23
+ name: souls_service
24
+ spec:
25
+ selector:
26
+ matchLabels:
27
+ run: souls_service
28
+ replicas: 2
29
+ template:
30
+ metadata:
31
+ labels:
32
+ run: souls_service
33
+ spec:
34
+ containers:
35
+ - image: asia.gcr.io/elsoul2/souls_service:0.0.1
36
+ name: souls_service
37
+ ports:
38
+ - protocol: TCP
39
+ containerPort: 50051
@@ -0,0 +1,12 @@
1
+ require "./app"
2
+
3
+ def main
4
+ s = GRPC::RpcServer.new
5
+ s.add_http2_port("0.0.0.0:50051", :this_port_is_insecure)
6
+ s.handle(ApplicationController)
7
+ logger = Logger.new(STDOUT)
8
+ logger.info "Running Server! SOULs Ready on localhost:50051"
9
+ s.run_till_terminated_or_interrupted([1, "int", "SIGQUIT"])
10
+ end
11
+
12
+ main
@@ -0,0 +1,79 @@
1
+ syntax = "proto3";
2
+
3
+ package Souls;
4
+
5
+ import "google/protobuf/timestamp.proto";
6
+
7
+ service Blog {
8
+ // Sends a greeting
9
+ rpc SayHello (HelloRequest) returns (HelloReply) {}
10
+ // Sends another greeting
11
+ rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}
12
+
13
+ // Blog Service Sample
14
+ rpc GetArticle(GetArticlRequest) returns (GetArticleReply) {}
15
+ rpc GetArticles(GetArticlesRequest) returns (stream Article) {}
16
+ rpc CreateArticle(Article) returns (CreateArticleReply) {}
17
+ rpc UpdateArticles(stream Article) returns (UpdateArticlesReply) {}
18
+ rpc DeleteArticle(DeleteArticlRequest) returns (DeleteArticleReply) {}
19
+ rpc CreateArticlesInStream(stream Article) returns (stream Article) {}
20
+ }
21
+
22
+ // The request message containing the user's name.
23
+ message HelloRequest {
24
+ string name = 1;
25
+ }
26
+
27
+ // The response message containing the greetings
28
+ message HelloReply {
29
+ string message = 1;
30
+ }
31
+
32
+
33
+ // Blog Protos
34
+ message Article {
35
+ string id = 1;
36
+ string user_id = 2;
37
+ string title = 3;
38
+ string body = 4;
39
+ string thumnail_url = 5;
40
+ uint32 public_date = 6;
41
+ uint32 article_category_id = 7;
42
+ bool is_public = 8;
43
+ repeated string tag = 9;
44
+ bool has_series = 10;
45
+ uint32 series_id = 11;
46
+ uint32 episode_num = 12;
47
+ google.protobuf.Timestamp created_at = 13;
48
+ google.protobuf.Timestamp updated_at = 14;
49
+ }
50
+
51
+
52
+ message GetArticlRequest {
53
+ uint32 id = 1;
54
+ }
55
+
56
+ message GetArticleReply {
57
+ Article article = 1;
58
+ }
59
+
60
+ message GetArticlesRequest {
61
+ string search = 1;
62
+ uint32 limit = 2;
63
+ }
64
+
65
+ message UpdateArticlesReply {
66
+ repeated Article articles = 1;
67
+ }
68
+
69
+ message DeleteArticlRequest {
70
+ uint32 id = 1;
71
+ }
72
+
73
+ message DeleteArticleReply {
74
+ Article article = 1;
75
+ }
76
+
77
+ message CreateArticleReply {
78
+ Article article = 1;
79
+ }
Binary file
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.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - POPPIN-FUMI
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2021-01-08 00:00:00.000000000 Z
12
+ date: 2021-01-17 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: SOULS is a Web Application Framework for Microservices on Multi Cloud
15
15
  Platform such as Google Cloud Platform, Amazon Web Services, and Alibaba Cloud.
@@ -45,6 +45,27 @@ files:
45
45
  - lib/souls/version.rb
46
46
  - rbs/init.rbs
47
47
  - souls.gemspec
48
+ - souls_service-0.0.8/.env.sample
49
+ - souls_service-0.0.8/.gitignore
50
+ - souls_service-0.0.8/.irbrc
51
+ - souls_service-0.0.8/.rubocop.yml
52
+ - souls_service-0.0.8/.ruby-version
53
+ - souls_service-0.0.8/.ruby_version
54
+ - souls_service-0.0.8/Dockerfile
55
+ - souls_service-0.0.8/Gemfile
56
+ - souls_service-0.0.8/Gemfile.lock
57
+ - souls_service-0.0.8/README.md
58
+ - souls_service-0.0.8/Rakefile
59
+ - souls_service-0.0.8/app.rb
60
+ - souls_service-0.0.8/app/controllers/application_controller.rb
61
+ - souls_service-0.0.8/app/controllers/article_method.rb
62
+ - souls_service-0.0.8/app/controllers/hello_method.rb
63
+ - souls_service-0.0.8/app/services/blog_pb.rb
64
+ - souls_service-0.0.8/app/services/souls.rb
65
+ - souls_service-0.0.8/config/initializers/souls.rb
66
+ - souls_service-0.0.8/deployment.yml
67
+ - souls_service-0.0.8/grpc_server.rb
68
+ - souls_service-0.0.8/protos/blog.proto
48
69
  - v0.0.8.tar.gz
49
70
  homepage: https://github.com/elsoul/souls
50
71
  licenses:
@@ -68,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
89
  - !ruby/object:Gem::Version
69
90
  version: '0'
70
91
  requirements: []
71
- rubygems_version: 3.2.3
92
+ rubygems_version: 3.2.4
72
93
  signing_key:
73
94
  specification_version: 4
74
95
  summary: SOULS is a Web Application Framework for Microservices on Multi Cloud Platform