teneo_grpc 0.1.3
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 +7 -0
- data/CHANGELOG.md +5 -0
- data/Dockerfile +16 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +132 -0
- data/README.md +2 -0
- data/Rakefile +25 -0
- data/bin/app.rb +27 -0
- data/bin/bundle +109 -0
- data/bin/console +11 -0
- data/bin/grpc_tools_ruby_protoc +27 -0
- data/bin/grpc_tools_ruby_protoc_plugin +27 -0
- data/bin/htmldiff +27 -0
- data/bin/irb +27 -0
- data/bin/ldiff +27 -0
- data/bin/protoc-gen-ruby +27 -0
- data/bin/racc +27 -0
- data/bin/rake +27 -0
- data/bin/rdbg +27 -0
- data/bin/rdoc +27 -0
- data/bin/ri +27 -0
- data/bin/rpc_server +27 -0
- data/bin/rspec +27 -0
- data/bin/rubocop +27 -0
- data/bin/ruby-parse +27 -0
- data/bin/ruby-rewrite +27 -0
- data/bin/setup +8 -0
- data/bin/thor +27 -0
- data/lib/teneo_grpc/client.rb +80 -0
- data/lib/teneo_grpc/cloud_event_helpers/cloud_event_helper.rb +18 -0
- data/lib/teneo_grpc/error_classes/socket_format_error.rb +8 -0
- data/lib/teneo_grpc/grpc_services/cloud_event_chat_enum.rb +22 -0
- data/lib/teneo_grpc/grpc_services/cloud_event_enum.rb +25 -0
- data/lib/teneo_grpc/grpc_services/cloud_events_service.rb +74 -0
- data/lib/teneo_grpc/proto/cloud_event_pb.rb +18 -0
- data/lib/teneo_grpc/proto/cloud_event_services_pb.rb +27 -0
- data/lib/teneo_grpc/server.rb +29 -0
- data/lib/teneo_grpc/service_orchestrator.rb +46 -0
- data/lib/teneo_grpc.rb +4 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 38bbb7d751a6eaa5997333b428b30de4e446134742d4010375fedfd2f9df6f4c
|
4
|
+
data.tar.gz: b441b1ac6ce34b77b833d79b450986bad6268e9ecb97c8ce1efe1865fa86b267
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7cf11c23a9903e292428a7d664990338c67d968cb838b69a2bf3274361aa2032e2b8e912e18a7faafb0033ad6d0b3bd32a852886b0db78f7425df90a734e3f83
|
7
|
+
data.tar.gz: ad1e5349a16266fbc86f5a2eafa390ce4c52d10a3d3e1d9872debf42f6e5118994478e1282034c8cd5196933f0d2e2909f29ab956e17279957dc20c7c37c9c2d
|
data/CHANGELOG.md
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
ARG RUBY_VERSION=3.1
|
2
|
+
ARG RUBY_IMAGE_VARIANT=slim-bookworm
|
3
|
+
|
4
|
+
FROM docker.io/ruby:${RUBY_VERSION}-${RUBY_IMAGE_VARIANT}
|
5
|
+
|
6
|
+
RUN apt-get update -qq && apt-get install -y build-essential
|
7
|
+
RUN mkdir /app
|
8
|
+
WORKDIR /app
|
9
|
+
COPY Gemfile /app/Gemfile
|
10
|
+
COPY Gemfile.lock /app/Gemfile.lock
|
11
|
+
|
12
|
+
RUN bundle install
|
13
|
+
|
14
|
+
COPY . /app
|
15
|
+
|
16
|
+
CMD [ "/app/start.sh" ]
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "debug", require: false # requires libyaml-dev to be installed on system (Ubuntu)
|
6
|
+
gem "grpc"
|
7
|
+
gem "grpc-tools"
|
8
|
+
gem "protobuf"
|
9
|
+
gem "rake", "~> 13.0"
|
10
|
+
gem "rspec", "~> 3.0"
|
11
|
+
gem "rubocop", "~> 1.21"
|
12
|
+
gem "rubocop-rake", require: false
|
13
|
+
gem "securerandom"
|
14
|
+
gem "teneo-grpc"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
GEM
|
2
|
+
remote: https://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (7.1.5.1)
|
5
|
+
base64
|
6
|
+
benchmark (>= 0.3)
|
7
|
+
bigdecimal
|
8
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
9
|
+
connection_pool (>= 2.2.5)
|
10
|
+
drb
|
11
|
+
i18n (>= 1.6, < 2)
|
12
|
+
logger (>= 1.4.2)
|
13
|
+
minitest (>= 5.1)
|
14
|
+
mutex_m
|
15
|
+
securerandom (>= 0.3)
|
16
|
+
tzinfo (~> 2.0)
|
17
|
+
ast (2.4.2)
|
18
|
+
base64 (0.2.0)
|
19
|
+
benchmark (0.4.0)
|
20
|
+
bigdecimal (3.1.9)
|
21
|
+
concurrent-ruby (1.3.5)
|
22
|
+
connection_pool (2.5.0)
|
23
|
+
date (3.4.1)
|
24
|
+
debug (1.10.0)
|
25
|
+
irb (~> 1.10)
|
26
|
+
reline (>= 0.3.8)
|
27
|
+
diff-lcs (1.5.1)
|
28
|
+
drb (2.2.1)
|
29
|
+
google-protobuf (4.29.3)
|
30
|
+
bigdecimal
|
31
|
+
rake (>= 13)
|
32
|
+
google-protobuf (4.29.3-x86_64-linux)
|
33
|
+
bigdecimal
|
34
|
+
rake (>= 13)
|
35
|
+
googleapis-common-protos-types (1.18.0)
|
36
|
+
google-protobuf (>= 3.18, < 5.a)
|
37
|
+
grpc (1.69.0)
|
38
|
+
google-protobuf (>= 3.25, < 5.0)
|
39
|
+
googleapis-common-protos-types (~> 1.0)
|
40
|
+
grpc (1.69.0-x86_64-linux)
|
41
|
+
google-protobuf (>= 3.25, < 5.0)
|
42
|
+
googleapis-common-protos-types (~> 1.0)
|
43
|
+
grpc-tools (1.69.0)
|
44
|
+
i18n (1.14.7)
|
45
|
+
concurrent-ruby (~> 1.0)
|
46
|
+
io-console (0.8.0)
|
47
|
+
irb (1.14.3)
|
48
|
+
rdoc (>= 4.0.0)
|
49
|
+
reline (>= 0.4.2)
|
50
|
+
json (2.9.1)
|
51
|
+
language_server-protocol (3.17.0.3)
|
52
|
+
logger (1.6.5)
|
53
|
+
middleware (0.1.0)
|
54
|
+
minitest (5.25.4)
|
55
|
+
mutex_m (0.3.0)
|
56
|
+
parallel (1.26.3)
|
57
|
+
parser (3.3.7.0)
|
58
|
+
ast (~> 2.4.1)
|
59
|
+
racc
|
60
|
+
protobuf (3.10.9)
|
61
|
+
activesupport (>= 3.2)
|
62
|
+
middleware
|
63
|
+
thor
|
64
|
+
thread_safe
|
65
|
+
psych (5.2.3)
|
66
|
+
date
|
67
|
+
stringio
|
68
|
+
racc (1.8.1)
|
69
|
+
rainbow (3.1.1)
|
70
|
+
rake (13.2.1)
|
71
|
+
rdoc (6.11.0)
|
72
|
+
psych (>= 4.0.0)
|
73
|
+
regexp_parser (2.10.0)
|
74
|
+
reline (0.6.0)
|
75
|
+
io-console (~> 0.5)
|
76
|
+
rspec (3.13.0)
|
77
|
+
rspec-core (~> 3.13.0)
|
78
|
+
rspec-expectations (~> 3.13.0)
|
79
|
+
rspec-mocks (~> 3.13.0)
|
80
|
+
rspec-core (3.13.2)
|
81
|
+
rspec-support (~> 3.13.0)
|
82
|
+
rspec-expectations (3.13.3)
|
83
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
84
|
+
rspec-support (~> 3.13.0)
|
85
|
+
rspec-mocks (3.13.2)
|
86
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
87
|
+
rspec-support (~> 3.13.0)
|
88
|
+
rspec-support (3.13.2)
|
89
|
+
rubocop (1.70.0)
|
90
|
+
json (~> 2.3)
|
91
|
+
language_server-protocol (>= 3.17.0)
|
92
|
+
parallel (~> 1.10)
|
93
|
+
parser (>= 3.3.0.2)
|
94
|
+
rainbow (>= 2.2.2, < 4.0)
|
95
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
96
|
+
rubocop-ast (>= 1.36.2, < 2.0)
|
97
|
+
ruby-progressbar (~> 1.7)
|
98
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
99
|
+
rubocop-ast (1.37.0)
|
100
|
+
parser (>= 3.3.1.0)
|
101
|
+
rubocop-rake (0.6.0)
|
102
|
+
rubocop (~> 1.0)
|
103
|
+
ruby-progressbar (1.13.0)
|
104
|
+
securerandom (0.3.2)
|
105
|
+
stringio (3.1.2)
|
106
|
+
teneo-grpc (0.1.0)
|
107
|
+
thor (1.3.2)
|
108
|
+
thread_safe (0.3.6)
|
109
|
+
tzinfo (2.0.6)
|
110
|
+
concurrent-ruby (~> 1.0)
|
111
|
+
unicode-display_width (3.1.4)
|
112
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
113
|
+
unicode-emoji (4.0.4)
|
114
|
+
|
115
|
+
PLATFORMS
|
116
|
+
ruby
|
117
|
+
x86_64-linux
|
118
|
+
|
119
|
+
DEPENDENCIES
|
120
|
+
debug
|
121
|
+
grpc
|
122
|
+
grpc-tools
|
123
|
+
protobuf
|
124
|
+
rake (~> 13.0)
|
125
|
+
rspec (~> 3.0)
|
126
|
+
rubocop (~> 1.21)
|
127
|
+
rubocop-rake
|
128
|
+
securerandom
|
129
|
+
teneo-grpc
|
130
|
+
|
131
|
+
BUNDLED WITH
|
132
|
+
2.5.23
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/setup' # Required to use gems from local vendor dir
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
require 'rubocop/rake_task'
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
10
|
+
|
11
|
+
RuboCop::RakeTask.new
|
12
|
+
|
13
|
+
task default: %w[spec rubocop run]
|
14
|
+
|
15
|
+
task :setup do
|
16
|
+
sh 'bundle install'
|
17
|
+
end
|
18
|
+
|
19
|
+
task :proto do
|
20
|
+
sh 'grpc_tools_ruby_protoc -I proto --ruby_out=lib/teneo/proto --grpc_out=lib/teneo/proto proto/*.proto'
|
21
|
+
end
|
22
|
+
|
23
|
+
task :run do
|
24
|
+
ruby 'bin/app.rb'
|
25
|
+
end
|
data/bin/app.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "yaml"
|
5
|
+
|
6
|
+
require_relative "../lib/teneo_grpc"
|
7
|
+
|
8
|
+
begin
|
9
|
+
puts "loading config"
|
10
|
+
c = YAML.load_file(ENV["TENEO_GRPC_CONFIG"])
|
11
|
+
rescue TypeError
|
12
|
+
abort("ERROR: config file not specified. use environment variable 'TENEO_GRPC_CONFIG' for this")
|
13
|
+
rescue Errno::ENOENT
|
14
|
+
abort("ERROR: no such file or directory - '#{ENV["TENEO_GRPC_CONFIG"]}'")
|
15
|
+
rescue Errno::EACCES
|
16
|
+
abort("ERROR: permission denied - '#{ENV["TENEO_GRPC_CONFIG"]}'")
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "starting application"
|
20
|
+
|
21
|
+
host = c["host"]
|
22
|
+
|
23
|
+
server = Server.new(
|
24
|
+
socket: "#{host["listen_address"]}:#{host["port"]}",
|
25
|
+
remote_hosts: c["remote_hosts"]
|
26
|
+
)
|
27
|
+
server.start_listening_for_data
|
data/bin/bundle
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'bundle' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "rubygems"
|
12
|
+
|
13
|
+
m = Module.new do
|
14
|
+
module_function
|
15
|
+
|
16
|
+
def invoked_as_script?
|
17
|
+
File.expand_path($0) == File.expand_path(__FILE__)
|
18
|
+
end
|
19
|
+
|
20
|
+
def env_var_version
|
21
|
+
ENV["BUNDLER_VERSION"]
|
22
|
+
end
|
23
|
+
|
24
|
+
def cli_arg_version
|
25
|
+
return unless invoked_as_script? # don't want to hijack other binstubs
|
26
|
+
return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
|
27
|
+
bundler_version = nil
|
28
|
+
update_index = nil
|
29
|
+
ARGV.each_with_index do |a, i|
|
30
|
+
if update_index && update_index.succ == i && a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
|
31
|
+
bundler_version = a
|
32
|
+
end
|
33
|
+
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
34
|
+
bundler_version = $1
|
35
|
+
update_index = i
|
36
|
+
end
|
37
|
+
bundler_version
|
38
|
+
end
|
39
|
+
|
40
|
+
def gemfile
|
41
|
+
gemfile = ENV["BUNDLE_GEMFILE"]
|
42
|
+
return gemfile if gemfile && !gemfile.empty?
|
43
|
+
|
44
|
+
File.expand_path("../Gemfile", __dir__)
|
45
|
+
end
|
46
|
+
|
47
|
+
def lockfile
|
48
|
+
lockfile =
|
49
|
+
case File.basename(gemfile)
|
50
|
+
when "gems.rb" then gemfile.sub(/\.rb$/, ".locked")
|
51
|
+
else "#{gemfile}.lock"
|
52
|
+
end
|
53
|
+
File.expand_path(lockfile)
|
54
|
+
end
|
55
|
+
|
56
|
+
def lockfile_version
|
57
|
+
return unless File.file?(lockfile)
|
58
|
+
lockfile_contents = File.read(lockfile)
|
59
|
+
return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
|
60
|
+
Regexp.last_match(1)
|
61
|
+
end
|
62
|
+
|
63
|
+
def bundler_requirement
|
64
|
+
@bundler_requirement ||=
|
65
|
+
env_var_version ||
|
66
|
+
cli_arg_version ||
|
67
|
+
bundler_requirement_for(lockfile_version)
|
68
|
+
end
|
69
|
+
|
70
|
+
def bundler_requirement_for(version)
|
71
|
+
return "#{Gem::Requirement.default}.a" unless version
|
72
|
+
|
73
|
+
bundler_gem_version = Gem::Version.new(version)
|
74
|
+
|
75
|
+
bundler_gem_version.approximate_recommendation
|
76
|
+
end
|
77
|
+
|
78
|
+
def load_bundler!
|
79
|
+
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
80
|
+
|
81
|
+
activate_bundler
|
82
|
+
end
|
83
|
+
|
84
|
+
def activate_bundler
|
85
|
+
gem_error = activation_error_handling do
|
86
|
+
gem "bundler", bundler_requirement
|
87
|
+
end
|
88
|
+
return if gem_error.nil?
|
89
|
+
require_error = activation_error_handling do
|
90
|
+
require "bundler/version"
|
91
|
+
end
|
92
|
+
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
93
|
+
warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
|
94
|
+
exit 42
|
95
|
+
end
|
96
|
+
|
97
|
+
def activation_error_handling
|
98
|
+
yield
|
99
|
+
nil
|
100
|
+
rescue StandardError, LoadError => e
|
101
|
+
e
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
m.load_bundler!
|
106
|
+
|
107
|
+
if m.invoked_as_script?
|
108
|
+
load Gem.bin_path("bundler", "bundle")
|
109
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "teneo/grpc_skeleton_ruby"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'grpc_tools_ruby_protoc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("grpc-tools", "grpc_tools_ruby_protoc")
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'grpc_tools_ruby_protoc_plugin' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("grpc-tools", "grpc_tools_ruby_protoc_plugin")
|
data/bin/htmldiff
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'htmldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("diff-lcs", "htmldiff")
|
data/bin/irb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'irb' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("irb", "irb")
|
data/bin/ldiff
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ldiff' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("diff-lcs", "ldiff")
|
data/bin/protoc-gen-ruby
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'protoc-gen-ruby' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("protobuf", "protoc-gen-ruby")
|
data/bin/racc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'racc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("racc", "racc")
|
data/bin/rake
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rake' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rake", "rake")
|
data/bin/rdbg
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rdbg' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("debug", "rdbg")
|
data/bin/rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rdoc' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rdoc", "rdoc")
|
data/bin/ri
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ri' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rdoc", "ri")
|
data/bin/rpc_server
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rpc_server' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("protobuf", "rpc_server")
|
data/bin/rspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rspec' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/rubocop
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/bin/ruby-parse
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-parse' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("parser", "ruby-parse")
|
data/bin/ruby-rewrite
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'ruby-rewrite' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("parser", "ruby-rewrite")
|
data/bin/setup
ADDED
data/bin/thor
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby3.0
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'thor' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
|
12
|
+
|
13
|
+
bundle_binstub = File.expand_path("bundle", __dir__)
|
14
|
+
|
15
|
+
if File.file?(bundle_binstub)
|
16
|
+
if File.read(bundle_binstub, 300).include?("This file was generated by Bundler")
|
17
|
+
load(bundle_binstub)
|
18
|
+
else
|
19
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
20
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
require "rubygems"
|
25
|
+
require "bundler/setup"
|
26
|
+
|
27
|
+
load Gem.bin_path("thor", "thor")
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'cloud_event_helpers/cloud_event_helper'
|
4
|
+
require_relative 'grpc_services/cloud_event_enum'
|
5
|
+
require_relative 'proto/cloud_event_services_pb'
|
6
|
+
|
7
|
+
# Sends data to gRPC services
|
8
|
+
class Client
|
9
|
+
attr_accessor :socket
|
10
|
+
|
11
|
+
def initialize(socket:)
|
12
|
+
@socket = socket
|
13
|
+
@stub = CloudEvents::Stub.new(@socket, :this_channel_is_insecure)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Example function that sends 1 request and receives 1 response
|
17
|
+
def send_1req_1resp(data:)
|
18
|
+
puts "sending to socket #{@socket}"
|
19
|
+
|
20
|
+
begin
|
21
|
+
event = CloudEventHelper.convert(text_data: data)
|
22
|
+
response = @stub.get_cloud_event(event)
|
23
|
+
rescue GRPC::Unavailable
|
24
|
+
puts "ERROR: failed to connect to host '#{@socket}'"
|
25
|
+
rescue StandardError => e
|
26
|
+
p e
|
27
|
+
end
|
28
|
+
|
29
|
+
response
|
30
|
+
end
|
31
|
+
|
32
|
+
# Example function that sends 1 request and receives a stream of responses
|
33
|
+
def send_1req_streamresp(data:)
|
34
|
+
puts "sending to socket #{@socket}"
|
35
|
+
|
36
|
+
begin
|
37
|
+
event = CloudEventHelper.convert(text_data: data)
|
38
|
+
responses = @stub.send_cloud_events(event)
|
39
|
+
rescue GRPC::Unavailable
|
40
|
+
puts "ERROR: failed to connect to host '#{@socket}'"
|
41
|
+
rescue StandardError => e
|
42
|
+
p e
|
43
|
+
end
|
44
|
+
|
45
|
+
responses
|
46
|
+
end
|
47
|
+
|
48
|
+
# Example function that sends a stream of requests and receives 1 response
|
49
|
+
def send_streamreq_1resp(data:)
|
50
|
+
puts "sending to socket #{@socket}"
|
51
|
+
|
52
|
+
begin
|
53
|
+
requests = CloudEventEnum.new(data: data, amount: 3)
|
54
|
+
response = @stub.get_cloud_events(requests.each)
|
55
|
+
rescue GRPC::Unavailable
|
56
|
+
puts "ERROR: failed to connect to host '#{@socket}'"
|
57
|
+
rescue StandardError => e
|
58
|
+
p e
|
59
|
+
end
|
60
|
+
|
61
|
+
response
|
62
|
+
end
|
63
|
+
|
64
|
+
# Example function that sends a stream of requests
|
65
|
+
# and receives a stream of responses
|
66
|
+
def send_streamreq_streamresp(data:)
|
67
|
+
puts "sending to socket #{@socket}"
|
68
|
+
|
69
|
+
begin
|
70
|
+
requests = CloudEventEnum.new(data: data, amount: 3)
|
71
|
+
responses = @stub.chat(requests.each)
|
72
|
+
rescue GRPC::Unavailable
|
73
|
+
puts "ERROR: failed to connect to host '#{@socket}'"
|
74
|
+
rescue StandardError => e
|
75
|
+
p e
|
76
|
+
end
|
77
|
+
|
78
|
+
responses
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
require_relative '../proto/cloud_event_services_pb'
|
6
|
+
|
7
|
+
# Helper module for all thing CloudEvent related
|
8
|
+
module CloudEventHelper
|
9
|
+
def self.convert(text_data:)
|
10
|
+
CloudEvent.new(
|
11
|
+
id: SecureRandom.uuid,
|
12
|
+
source: '/context',
|
13
|
+
spec_version: '1.0',
|
14
|
+
type: 'com.example.event',
|
15
|
+
text_data: text_data
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../cloud_event_helpers/cloud_event_helper'
|
4
|
+
|
5
|
+
# CloudEventChatEnum provides an Enumerator for bidirectional communication
|
6
|
+
class CloudEventChatEnum
|
7
|
+
def initialize(requests:, default_response:)
|
8
|
+
@requests = requests
|
9
|
+
@default_response = default_response
|
10
|
+
end
|
11
|
+
|
12
|
+
def each
|
13
|
+
return enum_for(:each) unless block_given?
|
14
|
+
|
15
|
+
@requests.each do |request|
|
16
|
+
puts "Received request: '#{request}'"
|
17
|
+
yield CloudEventHelper.convert(text_data: @default_response)
|
18
|
+
# Pause 1 second between messages to show how the messages get exchanged
|
19
|
+
sleep 1
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'securerandom'
|
4
|
+
|
5
|
+
# CloudEventEnum provides an Enumerator of cloud events
|
6
|
+
class CloudEventEnum
|
7
|
+
def initialize(data:, amount:)
|
8
|
+
@data = data
|
9
|
+
@amount = amount
|
10
|
+
end
|
11
|
+
|
12
|
+
def each
|
13
|
+
return enum_for(:each) unless block_given?
|
14
|
+
|
15
|
+
(1..@amount).each do
|
16
|
+
yield CloudEvent.new(
|
17
|
+
id: SecureRandom.uuid,
|
18
|
+
source: '/server-context',
|
19
|
+
spec_version: '1.0',
|
20
|
+
type: 'com.example.server-event',
|
21
|
+
text_data: @data
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../cloud_event_helpers/cloud_event_helper'
|
4
|
+
require_relative '../proto/cloud_event_services_pb'
|
5
|
+
require_relative 'cloud_event_chat_enum'
|
6
|
+
require_relative 'cloud_event_enum'
|
7
|
+
|
8
|
+
# Implements the CloudEvents service defined in proto/cloud_event.proto
|
9
|
+
class CloudEventsService < CloudEvents::Service
|
10
|
+
def initialize(socket:, clients:) # rubocop:disable Lint/MissingSuper
|
11
|
+
@socket = socket
|
12
|
+
@message = "ping from #{@socket}"
|
13
|
+
@clients = clients
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_cloud_event(request, _call)
|
17
|
+
puts "Received request: '#{request}'"
|
18
|
+
|
19
|
+
# Forward request to other services if message equals "forward"
|
20
|
+
if request.text_data == 'forward'
|
21
|
+
@clients.each do |client|
|
22
|
+
response = client.send_1req_1resp(data: @message)
|
23
|
+
puts "Reply from: '#{response}'"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
CloudEventHelper.convert(text_data: @message)
|
28
|
+
end
|
29
|
+
|
30
|
+
def send_cloud_events(request, _call)
|
31
|
+
puts "Received request: '#{request}'"
|
32
|
+
|
33
|
+
# Forward request to other services if message equals "forward"
|
34
|
+
if request.text_data == 'forward'
|
35
|
+
@clients.each do |client|
|
36
|
+
responses = client.send_1req_streamresp(data: @message)
|
37
|
+
|
38
|
+
responses.each do |response|
|
39
|
+
puts "Reply from: '#{response}'"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
CloudEventEnum.new(data: @message, amount: 3).each
|
45
|
+
end
|
46
|
+
|
47
|
+
def forward_to_services?(call)
|
48
|
+
forward = true
|
49
|
+
call.each_remote_read do |request|
|
50
|
+
puts "Received request: '#{request}'"
|
51
|
+
forward = false unless request.text_data == 'forward'
|
52
|
+
end
|
53
|
+
|
54
|
+
forward
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_cloud_events(call)
|
58
|
+
forward = forward_to_services?(call)
|
59
|
+
|
60
|
+
# Forward request to other services if message equals "forward"
|
61
|
+
if forward
|
62
|
+
@clients.each do |client|
|
63
|
+
response = client.send_streamreq_1resp(data: @message)
|
64
|
+
puts "Reply from: '#{response}'"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
CloudEventHelper.convert(text_data: @message)
|
69
|
+
end
|
70
|
+
|
71
|
+
def chat(call)
|
72
|
+
CloudEventChatEnum.new(requests: call, default_response: @message).each
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
3
|
+
# source: cloud_event.proto
|
4
|
+
|
5
|
+
require 'google/protobuf'
|
6
|
+
|
7
|
+
require 'google/protobuf/any_pb'
|
8
|
+
require 'google/protobuf/timestamp_pb'
|
9
|
+
|
10
|
+
|
11
|
+
descriptor_data = "\n\x11\x63loud_event.proto\x1a\x19google/protobuf/any.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x8c\x04\n\nCloudEvent\x12\n\n\x02id\x18\x01 \x02(\t\x12\x0e\n\x06source\x18\x02 \x02(\t\x12\x14\n\x0cspec_version\x18\x03 \x02(\t\x12\x0c\n\x04type\x18\x04 \x02(\t\x12/\n\nattributes\x18\x05 \x03(\x0b\x32\x1b.CloudEvent.AttributesEntry\x12\x15\n\x0b\x62inary_data\x18\x06 \x01(\x0cH\x00\x12\x13\n\ttext_data\x18\x07 \x01(\tH\x00\x12*\n\nproto_data\x18\x08 \x01(\x0b\x32\x14.google.protobuf.AnyH\x00\x1aW\n\x0f\x41ttributesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x33\n\x05value\x18\x02 \x01(\x0b\x32$.CloudEvent.CloudEventAttributeValue:\x02\x38\x01\x1a\xd3\x01\n\x18\x43loudEventAttributeValue\x12\x14\n\nce_boolean\x18\x01 \x01(\x08H\x00\x12\x14\n\nce_integer\x18\x02 \x01(\x05H\x00\x12\x13\n\tce_string\x18\x03 \x01(\tH\x00\x12\x12\n\x08\x63\x65_bytes\x18\x04 \x01(\x0cH\x00\x12\x10\n\x06\x63\x65_uri\x18\x05 \x01(\tH\x00\x12\x14\n\nce_uri_ref\x18\x06 \x01(\tH\x00\x12\x32\n\x0c\x63\x65_timestamp\x18\x07 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x42\x06\n\x04\x61ttrB\x06\n\x04\x64\x61ta\".\n\x0f\x43loudEventBatch\x12\x1b\n\x06\x65vents\x18\x01 \x03(\x0b\x32\x0b.CloudEvent2\xc3\x01\n\x0b\x43loudEvents\x12+\n\rGetCloudEvent\x12\x0b.CloudEvent\x1a\x0b.CloudEvent\"\x00\x12.\n\x0eGetCloudEvents\x12\x0b.CloudEvent\x1a\x0b.CloudEvent\"\x00(\x01\x12/\n\x0fSendCloudEvents\x12\x0b.CloudEvent\x1a\x0b.CloudEvent\"\x00\x30\x01\x12&\n\x04\x43hat\x12\x0b.CloudEvent\x1a\x0b.CloudEvent\"\x00(\x01\x30\x01"
|
12
|
+
|
13
|
+
pool = Google::Protobuf::DescriptorPool.generated_pool
|
14
|
+
pool.add_serialized_file(descriptor_data)
|
15
|
+
|
16
|
+
CloudEvent = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("CloudEvent").msgclass
|
17
|
+
CloudEvent::CloudEventAttributeValue = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("CloudEvent.CloudEventAttributeValue").msgclass
|
18
|
+
CloudEventBatch = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("CloudEventBatch").msgclass
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
2
|
+
# Source: cloud_event.proto for package ''
|
3
|
+
|
4
|
+
require 'grpc'
|
5
|
+
require_relative 'cloud_event_pb'
|
6
|
+
|
7
|
+
module CloudEvents
|
8
|
+
class Service
|
9
|
+
|
10
|
+
include ::GRPC::GenericService
|
11
|
+
|
12
|
+
self.marshal_class_method = :encode
|
13
|
+
self.unmarshal_class_method = :decode
|
14
|
+
self.service_name = 'CloudEvents'
|
15
|
+
|
16
|
+
# Obtains a cloud event
|
17
|
+
rpc :GetCloudEvent, ::CloudEvent, ::CloudEvent
|
18
|
+
# Obtains a series of cloud events
|
19
|
+
rpc :GetCloudEvents, stream(::CloudEvent), ::CloudEvent
|
20
|
+
# Sends a series of cloud events
|
21
|
+
rpc :SendCloudEvents, ::CloudEvent, stream(::CloudEvent)
|
22
|
+
# Send and receive cloud events
|
23
|
+
rpc :Chat, stream(::CloudEvent), stream(::CloudEvent)
|
24
|
+
end
|
25
|
+
|
26
|
+
Stub = Service.rpc_stub_class
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'client'
|
4
|
+
require_relative 'service_orchestrator'
|
5
|
+
require_relative 'grpc_services/cloud_events_service'
|
6
|
+
|
7
|
+
# Encapsulating class for all gRPC communication
|
8
|
+
class Server
|
9
|
+
attr_accessor :socket, :remote_hosts, :clients
|
10
|
+
|
11
|
+
def initialize(socket:, remote_hosts:)
|
12
|
+
@socket = socket
|
13
|
+
@remote_hosts = remote_hosts
|
14
|
+
|
15
|
+
@clients = []
|
16
|
+
@remote_hosts&.each do |remote|
|
17
|
+
client = Client.new(socket: remote)
|
18
|
+
@clients.push(client)
|
19
|
+
end
|
20
|
+
|
21
|
+
@orchestrator = ServiceOrchestrator.new(socket: @socket)
|
22
|
+
@orchestrator.initialize_listener
|
23
|
+
@orchestrator.add(CloudEventsService.new(socket: @socket, clients: @clients))
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_listening_for_data
|
27
|
+
@orchestrator.start
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'grpc'
|
4
|
+
|
5
|
+
require_relative 'error_classes/socket_format_error'
|
6
|
+
|
7
|
+
# Listener for gRPC data
|
8
|
+
class ServiceOrchestrator
|
9
|
+
attr_accessor :socket
|
10
|
+
|
11
|
+
def initialize(socket:)
|
12
|
+
@socket = socket
|
13
|
+
end
|
14
|
+
|
15
|
+
def initialize_listener
|
16
|
+
puts 'initializing gRPC service'
|
17
|
+
|
18
|
+
raise SocketFormatError unless @socket =~ /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}:\d{1,5}$/
|
19
|
+
|
20
|
+
@listener = GRPC::RpcServer.new
|
21
|
+
@listener.add_http2_port(@socket, :this_port_is_insecure)
|
22
|
+
GRPC.logger.info("... running insecurely on #{@socket}")
|
23
|
+
end
|
24
|
+
|
25
|
+
def add(service)
|
26
|
+
@listener.handle(service)
|
27
|
+
end
|
28
|
+
|
29
|
+
def start
|
30
|
+
puts "listening insecurely on #{@socket}"
|
31
|
+
@listener.run_till_terminated_or_interrupted([1, 'int', 'SIGQUIT'])
|
32
|
+
end
|
33
|
+
|
34
|
+
def wait_till_running
|
35
|
+
@listener.wait_till_running
|
36
|
+
end
|
37
|
+
|
38
|
+
def running?
|
39
|
+
@listener.running?
|
40
|
+
end
|
41
|
+
|
42
|
+
def stop
|
43
|
+
puts 'shutting down gRPC server'
|
44
|
+
@listener.stop if running?
|
45
|
+
end
|
46
|
+
end
|
data/lib/teneo_grpc.rb
ADDED
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: teneo_grpc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ruben Vanoverschelde
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Microservices communication with gRPC and CloudEvents.
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- CHANGELOG.md
|
20
|
+
- Dockerfile
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- bin/app.rb
|
26
|
+
- bin/bundle
|
27
|
+
- bin/console
|
28
|
+
- bin/grpc_tools_ruby_protoc
|
29
|
+
- bin/grpc_tools_ruby_protoc_plugin
|
30
|
+
- bin/htmldiff
|
31
|
+
- bin/irb
|
32
|
+
- bin/ldiff
|
33
|
+
- bin/protoc-gen-ruby
|
34
|
+
- bin/racc
|
35
|
+
- bin/rake
|
36
|
+
- bin/rdbg
|
37
|
+
- bin/rdoc
|
38
|
+
- bin/ri
|
39
|
+
- bin/rpc_server
|
40
|
+
- bin/rspec
|
41
|
+
- bin/rubocop
|
42
|
+
- bin/ruby-parse
|
43
|
+
- bin/ruby-rewrite
|
44
|
+
- bin/setup
|
45
|
+
- bin/thor
|
46
|
+
- lib/teneo_grpc.rb
|
47
|
+
- lib/teneo_grpc/client.rb
|
48
|
+
- lib/teneo_grpc/cloud_event_helpers/cloud_event_helper.rb
|
49
|
+
- lib/teneo_grpc/error_classes/socket_format_error.rb
|
50
|
+
- lib/teneo_grpc/grpc_services/cloud_event_chat_enum.rb
|
51
|
+
- lib/teneo_grpc/grpc_services/cloud_event_enum.rb
|
52
|
+
- lib/teneo_grpc/grpc_services/cloud_events_service.rb
|
53
|
+
- lib/teneo_grpc/proto/cloud_event_pb.rb
|
54
|
+
- lib/teneo_grpc/proto/cloud_event_services_pb.rb
|
55
|
+
- lib/teneo_grpc/server.rb
|
56
|
+
- lib/teneo_grpc/service_orchestrator.rb
|
57
|
+
homepage: https://github.com/libis/teneo-grpc_skeleton_ruby
|
58
|
+
licenses:
|
59
|
+
- MIT
|
60
|
+
metadata:
|
61
|
+
source_code_uri: https://github.com/libis/teneo-grpc_skeleton_ruby
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - "~>"
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '3.0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubygems_version: 3.3.5
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Microservices communication with gRPC and CloudEvents.
|
81
|
+
test_files: []
|