runways 0.1.6 → 0.1.7
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/Gemfile.lock +3 -3
- data/README.md +6 -3
- data/exe/runways +1 -1
- data/lib/runways.rb +3 -0
- data/lib/runways/cli.rb +10 -0
- data/lib/runways/generators/app_structure_generator.rb +160 -53
- data/lib/runways/generators/templates/{application_record.tt → app/models/application_record.tt} +0 -0
- data/lib/runways/generators/templates/{application_config.tt → config/application.tt} +0 -0
- data/lib/runways/generators/templates/{db_config.tt → config/db_config.tt} +0 -0
- data/lib/runways/generators/templates/{service.tt → lib/service.tt} +0 -0
- data/lib/runways/generators/templates/{db_rake.tt → lib/tasks/db.tt} +0 -0
- data/lib/runways/generators/templates/{protobuf_rake.tt → lib/tasks/generate_protobuf_files.tt} +0 -0
- data/lib/runways/generators/templates/{proto.tt → proto/proto.tt} +0 -0
- data/lib/runways/generators/templates/server.tt +7 -3
- data/lib/runways/generators/templates/{test_client.tt → test/test_client.tt} +0 -0
- data/lib/runways/interceptors/base_interceptor.rb +23 -0
- data/lib/runways/interceptors/benchmark_interceptor.rb +11 -0
- data/lib/runways/version.rb +1 -1
- metadata +13 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 38f45a3b612a1641cfbef86e72e0521c7f6488473724aa94df6b9740ce329d54
|
4
|
+
data.tar.gz: 1f768cc190fe9ce380e63a72dd4720556c96e1bd94c3adde4d01111af7b0b699
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1b07e2162af7aeca9d6fc378b2534a58959fe4668356095e3a656c1a27357f22be74d9b8fdcb5c79ae3aa2384d1477de7c698b6086eb0411b5bb89bac2a69f
|
7
|
+
data.tar.gz: '083596ed81e0dd1486782ac3b61c17f7a2a23933d84cfbf7b359a79cb0b081f711776a2d70d976b0eb12e755a310b747a9ced7a2c01c0fc5fcd4697ab78839e9'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
runways (0.1.
|
4
|
+
runways (0.1.7)
|
5
5
|
activerecord (~> 5.2)
|
6
6
|
grpc (~> 1.16)
|
7
7
|
grpc-tools (~> 1.16)
|
@@ -23,10 +23,10 @@ GEM
|
|
23
23
|
tzinfo (~> 1.1)
|
24
24
|
arel (9.0.0)
|
25
25
|
concurrent-ruby (1.1.3)
|
26
|
-
google-protobuf (3.6.1)
|
26
|
+
google-protobuf (3.6.1-universal-darwin)
|
27
27
|
googleapis-common-protos-types (1.0.2)
|
28
28
|
google-protobuf (~> 3.0)
|
29
|
-
grpc (1.16.0)
|
29
|
+
grpc (1.16.0-universal-darwin)
|
30
30
|
google-protobuf (~> 3.1)
|
31
31
|
googleapis-common-protos-types (~> 1.0.0)
|
32
32
|
grpc-tools (1.16.0)
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# Runways
|
2
|
-
|
3
2
|
Runways is a gRPC based ruby application. It will setup the basic project structure with active_record ORM.
|
4
3
|
|
5
4
|
## Installation
|
@@ -10,7 +9,7 @@ Install Runways at the command prompt:
|
|
10
9
|
|
11
10
|
Create a new runways application:
|
12
11
|
|
13
|
-
$ runways hello
|
12
|
+
$ runways new hello
|
14
13
|
|
15
14
|
Run the following rake task to update protobuf files:
|
16
15
|
|
@@ -48,7 +47,7 @@ Everyone interacting in the Runways project’s codebases, issue trackers, chat
|
|
48
47
|
- [ ] Setup logging
|
49
48
|
- [ ] Use ActiveRecord generators to handle ActiveRecord related tasks ( ex: generate migration, migrate, rollback )
|
50
49
|
- [ ] Create runways controller
|
51
|
-
- [
|
50
|
+
- [x] Refactor generator code
|
52
51
|
- [ ] Refactor code to generate protobuf files when the application is initialized
|
53
52
|
- [x] Handle loading the server without DbConfig setup
|
54
53
|
- [ ] Handle DbConfig in the ActiveRecord style
|
@@ -56,3 +55,7 @@ Everyone interacting in the Runways project’s codebases, issue trackers, chat
|
|
56
55
|
- [x] Handle file loading like how rails handles it
|
57
56
|
- [ ] Accept package name from command line
|
58
57
|
- [ ] Don't hard code port
|
58
|
+
- [ ] Figure out how to handle nil values in the GRPC request
|
59
|
+
- [ ] Add callbacks for RPC's
|
60
|
+
- [ ] Test for streaming rpcs
|
61
|
+
- [ ] How to generalize interceptors for simple & streaming rpcs
|
data/exe/runways
CHANGED
data/lib/runways.rb
CHANGED
@@ -3,6 +3,9 @@ require "active_record"
|
|
3
3
|
require "runways/version"
|
4
4
|
require "runways/generators/app_structure_generator"
|
5
5
|
require "runways/dependencies"
|
6
|
+
require "runways/cli"
|
7
|
+
require "runways/interceptors/base_interceptor"
|
8
|
+
require "runways/interceptors/benchmark_interceptor"
|
6
9
|
|
7
10
|
module Runways
|
8
11
|
# Your code goes here...
|
data/lib/runways/cli.rb
ADDED
@@ -9,91 +9,198 @@ class AppStructure < Thor::Group
|
|
9
9
|
File.dirname(__FILE__)
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
lib_directory
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
12
|
+
def root_directory
|
13
|
+
app_name = name.to_s
|
14
|
+
empty_directory(app_name)
|
15
|
+
path = app_name
|
16
|
+
|
17
|
+
app_directory(path)
|
18
|
+
db_directory(path)
|
19
|
+
lib_directory(path)
|
20
|
+
proto_directory(path)
|
21
|
+
config_directory(path)
|
22
|
+
test_directory(path)
|
23
|
+
|
24
|
+
generate_gemfile(path)
|
25
|
+
generate_rake_file(path)
|
26
|
+
generate_server_file(path)
|
27
|
+
|
28
|
+
run_protoc_cmd(path)
|
29
|
+
run_bundle_install(path)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
def app_directory(path)
|
34
|
+
path += "/app"
|
35
|
+
empty_directory(path)
|
24
36
|
|
25
|
-
|
26
|
-
root_directory, app_directory, config_directory,
|
27
|
-
lib_directory, lib_protos_directory, tasks_directory,
|
28
|
-
models_directory, controller_directory,
|
29
|
-
db_directory, migration_directory, test_directory,
|
30
|
-
])
|
37
|
+
models_directory(path)
|
31
38
|
end
|
32
39
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
40
|
+
def models_directory(path)
|
41
|
+
path += "/models"
|
42
|
+
empty_directory(path)
|
43
|
+
|
44
|
+
generate_application_record(path)
|
36
45
|
end
|
37
46
|
|
38
|
-
def
|
39
|
-
|
47
|
+
def generate_application_record(path)
|
48
|
+
path += "/"
|
49
|
+
template_name = "application_record"
|
50
|
+
generate_template(path: path, template_name: template_name, extenstion: 'rb')
|
40
51
|
end
|
41
52
|
|
42
|
-
def
|
43
|
-
|
53
|
+
def db_directory(path)
|
54
|
+
path += "/db"
|
55
|
+
empty_directory(path)
|
56
|
+
|
57
|
+
migration_directory(path)
|
44
58
|
end
|
45
59
|
|
46
|
-
def
|
47
|
-
|
60
|
+
def migration_directory(path)
|
61
|
+
path += "/migrate"
|
62
|
+
empty_directory(path)
|
48
63
|
end
|
49
64
|
|
50
|
-
def
|
51
|
-
|
52
|
-
|
53
|
-
|
65
|
+
def lib_directory(path)
|
66
|
+
path += "/lib"
|
67
|
+
empty_directory(path)
|
68
|
+
|
69
|
+
protos_directory(path)
|
70
|
+
tasks_directory(path)
|
71
|
+
|
72
|
+
generate_service_file(path)
|
73
|
+
end
|
74
|
+
|
75
|
+
def protos_directory(path)
|
76
|
+
path += "/protos"
|
77
|
+
empty_directory(path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def tasks_directory(path)
|
81
|
+
path += "/tasks"
|
82
|
+
empty_directory(path)
|
83
|
+
|
84
|
+
generate_db_rake_file(path)
|
85
|
+
generate_protofub_rake_file(path)
|
86
|
+
end
|
87
|
+
|
88
|
+
def generate_db_rake_file(path)
|
89
|
+
path += "/"
|
90
|
+
generate_template(
|
91
|
+
path: path, extenstion: 'rake', template_name: 'db'
|
54
92
|
)
|
55
93
|
end
|
56
94
|
|
57
|
-
def
|
58
|
-
|
59
|
-
|
60
|
-
|
95
|
+
def generate_protofub_rake_file(path)
|
96
|
+
path += "/"
|
97
|
+
generate_template(
|
98
|
+
path: path, extenstion: 'rake', template_name: 'generate_protobuf_files'
|
61
99
|
)
|
62
100
|
end
|
63
101
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
67
|
-
|
102
|
+
def generate_service_file(path)
|
103
|
+
path += "/"
|
104
|
+
file_name = "#{name.underscore}_service"
|
105
|
+
|
106
|
+
generate_template(
|
107
|
+
path: path, file_name: file_name,
|
108
|
+
extenstion: 'rb', template_name: "service"
|
68
109
|
)
|
69
110
|
end
|
70
111
|
|
71
|
-
def
|
72
|
-
|
112
|
+
def proto_directory(path)
|
113
|
+
path += "/proto"
|
114
|
+
empty_directory(path)
|
115
|
+
|
116
|
+
generate_proto_file(path)
|
73
117
|
end
|
74
118
|
|
75
|
-
def
|
76
|
-
|
119
|
+
def generate_proto_file(path)
|
120
|
+
path += "/"
|
121
|
+
generate_template(
|
122
|
+
path: path, extenstion: 'proto', template_name: 'proto', file_name: name
|
123
|
+
)
|
77
124
|
end
|
78
125
|
|
79
|
-
def
|
80
|
-
|
126
|
+
def config_directory(path)
|
127
|
+
path += "/config"
|
128
|
+
empty_directory(path)
|
129
|
+
|
130
|
+
generate_db_config_file(path)
|
131
|
+
generate_application_config_file(path)
|
81
132
|
end
|
82
133
|
|
83
|
-
def
|
84
|
-
|
134
|
+
def generate_db_config_file(path)
|
135
|
+
path += "/"
|
136
|
+
generate_template(
|
137
|
+
path: path, extenstion: 'rb', template_name: 'db_config'
|
138
|
+
)
|
85
139
|
end
|
86
140
|
|
87
|
-
def
|
88
|
-
|
141
|
+
def generate_application_config_file(path)
|
142
|
+
path += "/"
|
143
|
+
generate_template(
|
144
|
+
path: path, extenstion: 'rb', template_name: 'application'
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
def test_directory(path)
|
149
|
+
path += "/test"
|
150
|
+
empty_directory(path)
|
151
|
+
|
152
|
+
generate_test_client_file(path)
|
153
|
+
end
|
154
|
+
|
155
|
+
def generate_test_client_file(path)
|
156
|
+
path += "/"
|
157
|
+
generate_template(
|
158
|
+
path: path, extenstion: 'rb', template_name: 'test_client'
|
159
|
+
)
|
160
|
+
end
|
161
|
+
|
162
|
+
def generate_gemfile(path)
|
163
|
+
path += "/"
|
164
|
+
generate_template(
|
165
|
+
path: path, template_name: 'Gemfile'
|
166
|
+
)
|
167
|
+
end
|
168
|
+
|
169
|
+
def generate_rake_file(path)
|
170
|
+
path += "/"
|
171
|
+
generate_template(
|
172
|
+
path: path, template_name: 'Rakefile'
|
173
|
+
)
|
174
|
+
end
|
175
|
+
|
176
|
+
def generate_server_file(path)
|
177
|
+
path += "/"
|
178
|
+
generate_template(
|
179
|
+
path: path, template_name: 'server',
|
180
|
+
file_name: name + "_server", extenstion: 'rb'
|
181
|
+
)
|
182
|
+
end
|
183
|
+
|
184
|
+
def run_protoc_cmd(path)
|
185
|
+
inside(path) do
|
89
186
|
run ("grpc_tools_ruby_protoc -I proto --ruby_out=lib/protos --grpc_out=lib/protos proto/#{name.underscore}.proto")
|
90
187
|
end
|
91
188
|
end
|
92
189
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
empty_directory(dir_path)
|
190
|
+
def run_bundle_install(path)
|
191
|
+
inside(path) do
|
192
|
+
run ("bundle install")
|
97
193
|
end
|
98
194
|
end
|
195
|
+
|
196
|
+
def templates_directory
|
197
|
+
"templates"
|
198
|
+
end
|
199
|
+
|
200
|
+
def generate_template(path:, template_name:, extenstion: '', file_name: nil)
|
201
|
+
template(
|
202
|
+
path.sub(name, templates_directory) + template_name + ".tt",
|
203
|
+
path + ( file_name ? file_name : template_name ) + ( extenstion.present? ? '.' + extenstion : extenstion )
|
204
|
+
)
|
205
|
+
end
|
99
206
|
end
|
data/lib/runways/generators/templates/{application_record.tt → app/models/application_record.tt}
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/runways/generators/templates/{protobuf_rake.tt → lib/tasks/generate_protobuf_files.tt}
RENAMED
File without changes
|
File without changes
|
@@ -14,10 +14,14 @@ class <%= name.camelize %>Server
|
|
14
14
|
private
|
15
15
|
|
16
16
|
def start_grpc_server
|
17
|
-
|
17
|
+
# Available interceptors Runways::BenchmarkInterceptor
|
18
|
+
@server = GRPC::RpcServer.new(
|
19
|
+
pool_size: 5,
|
20
|
+
interceptors: []
|
21
|
+
)
|
18
22
|
@server.add_http2_port('0.0.0.0:50052', :this_port_is_insecure)
|
19
|
-
|
20
|
-
|
23
|
+
@server.handle(<%= name.camelize %>Service)
|
24
|
+
@server.run_till_terminated
|
21
25
|
end
|
22
26
|
end
|
23
27
|
end
|
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Runways
|
2
|
+
class BaseInterceptor < ::GRPC::ServerInterceptor
|
3
|
+
def all_request_responses(request: nil, call: nil, method: nil)
|
4
|
+
yield
|
5
|
+
end
|
6
|
+
|
7
|
+
def request_response(request: nil, call: nil, method: nil, &block)
|
8
|
+
all_request_responses(request: request, call: call, method: method, &block)
|
9
|
+
end
|
10
|
+
|
11
|
+
def client_streamer(request: nil, call: nil, method: nil, &block)
|
12
|
+
all_request_responses(request: request, call: call, method: method, &block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def server_streamer(request: nil, call: nil, method: nil, &block)
|
16
|
+
all_request_responses(request: request, call: call, method: method, &block)
|
17
|
+
end
|
18
|
+
|
19
|
+
def bidi_streamer(request: nil, call: nil, method: nil, &block)
|
20
|
+
all_request_responses(request: request, call: call, method: method, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/runways/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runways
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NG
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -115,19 +115,22 @@ files:
|
|
115
115
|
- bin/setup
|
116
116
|
- exe/runways
|
117
117
|
- lib/runways.rb
|
118
|
+
- lib/runways/cli.rb
|
118
119
|
- lib/runways/dependencies.rb
|
119
120
|
- lib/runways/generators/app_structure_generator.rb
|
120
|
-
- lib/runways/generators/templates/
|
121
|
-
- lib/runways/generators/templates/
|
122
|
-
- lib/runways/generators/templates/db_config.tt
|
123
|
-
- lib/runways/generators/templates/db_rake.tt
|
121
|
+
- lib/runways/generators/templates/app/models/application_record.tt
|
122
|
+
- lib/runways/generators/templates/config/application.tt
|
123
|
+
- lib/runways/generators/templates/config/db_config.tt
|
124
124
|
- lib/runways/generators/templates/gemfile.tt
|
125
|
-
- lib/runways/generators/templates/
|
126
|
-
- lib/runways/generators/templates/
|
125
|
+
- lib/runways/generators/templates/lib/service.tt
|
126
|
+
- lib/runways/generators/templates/lib/tasks/db.tt
|
127
|
+
- lib/runways/generators/templates/lib/tasks/generate_protobuf_files.tt
|
128
|
+
- lib/runways/generators/templates/proto/proto.tt
|
127
129
|
- lib/runways/generators/templates/rakefile.tt
|
128
130
|
- lib/runways/generators/templates/server.tt
|
129
|
-
- lib/runways/generators/templates/
|
130
|
-
- lib/runways/
|
131
|
+
- lib/runways/generators/templates/test/test_client.tt
|
132
|
+
- lib/runways/interceptors/base_interceptor.rb
|
133
|
+
- lib/runways/interceptors/benchmark_interceptor.rb
|
131
134
|
- lib/runways/version.rb
|
132
135
|
- runways.gemspec
|
133
136
|
homepage: https://github.com
|