teneo_microservice 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 18cb01bcee051c684f6526d7ebad58897f65350fa6cbf1cb88ed8d401a9750ee
4
+ data.tar.gz: 578d8002f4d79b85d6494a729a426a2351b3b64688cf0887b96abf319c7a902d
5
+ SHA512:
6
+ metadata.gz: 456e6546a5060982d17daba9c04d0051340cbaeaae005a4b73c375b963df3d6f804c0f28c7b72a125cfc825a5c2201d784f00d7dea2aa9f910f4242c65ce4d6e
7
+ data.tar.gz: ba90af2daa768b9b74eff78d686bd76b3da30ab5f475b631406a1423a571c20d622e65fc7b6e0a0f8af5f716241b2652a88be70c64a71b5bd89be73913975acf
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2025-01-21
4
+
5
+ - Initial release
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 'dotenv', groups: %i[development test]
7
+ gem 'grpc'
8
+ gem 'grpc-tools'
9
+ gem 'protobuf'
10
+ gem 'rake', '~> 13.0'
11
+ gem 'rspec', '~> 3.0'
12
+ gem 'rubocop', '~> 1.21'
13
+ gem 'rubocop-rake', require: false
14
+ gem 'securerandom'
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
+ dotenv (3.1.7)
29
+ drb (2.2.1)
30
+ google-protobuf (4.29.3)
31
+ bigdecimal
32
+ rake (>= 13)
33
+ google-protobuf (4.29.3-x86_64-linux)
34
+ bigdecimal
35
+ rake (>= 13)
36
+ googleapis-common-protos-types (1.18.0)
37
+ google-protobuf (>= 3.18, < 5.a)
38
+ grpc (1.69.0)
39
+ google-protobuf (>= 3.25, < 5.0)
40
+ googleapis-common-protos-types (~> 1.0)
41
+ grpc (1.69.0-x86_64-linux)
42
+ google-protobuf (>= 3.25, < 5.0)
43
+ googleapis-common-protos-types (~> 1.0)
44
+ grpc-tools (1.69.0)
45
+ i18n (1.14.7)
46
+ concurrent-ruby (~> 1.0)
47
+ io-console (0.8.0)
48
+ irb (1.14.3)
49
+ rdoc (>= 4.0.0)
50
+ reline (>= 0.4.2)
51
+ json (2.9.1)
52
+ language_server-protocol (3.17.0.3)
53
+ logger (1.6.5)
54
+ middleware (0.1.0)
55
+ minitest (5.25.4)
56
+ mutex_m (0.3.0)
57
+ parallel (1.26.3)
58
+ parser (3.3.7.0)
59
+ ast (~> 2.4.1)
60
+ racc
61
+ protobuf (3.10.9)
62
+ activesupport (>= 3.2)
63
+ middleware
64
+ thor
65
+ thread_safe
66
+ psych (5.2.3)
67
+ date
68
+ stringio
69
+ racc (1.8.1)
70
+ rainbow (3.1.1)
71
+ rake (13.2.1)
72
+ rdoc (6.11.0)
73
+ psych (>= 4.0.0)
74
+ regexp_parser (2.10.0)
75
+ reline (0.6.0)
76
+ io-console (~> 0.5)
77
+ rspec (3.13.0)
78
+ rspec-core (~> 3.13.0)
79
+ rspec-expectations (~> 3.13.0)
80
+ rspec-mocks (~> 3.13.0)
81
+ rspec-core (3.13.2)
82
+ rspec-support (~> 3.13.0)
83
+ rspec-expectations (3.13.3)
84
+ diff-lcs (>= 1.2.0, < 2.0)
85
+ rspec-support (~> 3.13.0)
86
+ rspec-mocks (3.13.2)
87
+ diff-lcs (>= 1.2.0, < 2.0)
88
+ rspec-support (~> 3.13.0)
89
+ rspec-support (3.13.2)
90
+ rubocop (1.70.0)
91
+ json (~> 2.3)
92
+ language_server-protocol (>= 3.17.0)
93
+ parallel (~> 1.10)
94
+ parser (>= 3.3.0.2)
95
+ rainbow (>= 2.2.2, < 4.0)
96
+ regexp_parser (>= 2.9.3, < 3.0)
97
+ rubocop-ast (>= 1.36.2, < 2.0)
98
+ ruby-progressbar (~> 1.7)
99
+ unicode-display_width (>= 2.4.0, < 4.0)
100
+ rubocop-ast (1.37.0)
101
+ parser (>= 3.3.1.0)
102
+ rubocop-rake (0.6.0)
103
+ rubocop (~> 1.0)
104
+ ruby-progressbar (1.13.0)
105
+ securerandom (0.3.2)
106
+ stringio (3.1.2)
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
+ dotenv
122
+ grpc
123
+ grpc-tools
124
+ protobuf
125
+ rake (~> 13.0)
126
+ rspec (~> 3.0)
127
+ rubocop (~> 1.21)
128
+ rubocop-rake
129
+ securerandom
130
+
131
+ BUNDLED WITH
132
+ 2.5.23
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # Teneo Microservice Base for Ruby Projects
data/Rakefile ADDED
@@ -0,0 +1,17 @@
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]
14
+
15
+ task :proto do
16
+ sh 'grpc_tools_ruby_protoc -I proto --ruby_out=lib/teneo/proto --grpc_out=lib/teneo/proto proto/*.proto'
17
+ end
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/microservice_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__)
data/bin/dotenv 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 'dotenv' 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("dotenv", "dotenv")
@@ -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")
@@ -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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
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,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'util/env'
4
+ require_relative 'util/convert'
5
+ require_relative 'grpc_services/cloud_event_enum'
6
+ require_relative 'proto/cloud_event_services_pb'
7
+
8
+ # Sends data to gRPC services
9
+ class Client
10
+ attr_accessor :socket, :stub
11
+
12
+ def initialize(socket:)
13
+ Env.valid_settings?
14
+
15
+ @socket = socket
16
+ @stub = CloudEvents::Stub.new(@socket, :this_channel_is_insecure)
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This error should get raised when the environment does not provide
4
+ # the required attributes.
5
+ class EnvSettingsError < StandardError
6
+ def initialize(msg = 'ERROR: invalid settings in .env file')
7
+ super(msg)
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This error should get raised when a socket string has an invalid format
4
+ class SocketFormatError < StandardError
5
+ def initialize(msg = 'invalid socket')
6
+ super(msg)
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ require_relative '../util/convert'
6
+
7
+ # CloudEventEnum provides an Enumerator of cloud events
8
+ class CloudEventEnum
9
+ def initialize(array:)
10
+ @array = array
11
+ end
12
+
13
+ def each
14
+ return enum_for(:each) unless block_given?
15
+
16
+ @array.each do |element|
17
+ yield Convert.json_to_cloudevent(data: element)
18
+ end
19
+ end
20
+ 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,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'client'
4
+ require_relative 'service_orchestrator'
5
+ require_relative 'util/env'
6
+
7
+ # Encapsulating class for all gRPC communication
8
+ class Server
9
+ attr_accessor :socket, :remote_hosts, :clients
10
+
11
+ def initialize
12
+ Env.valid_settings?
13
+
14
+ @socket = "#{ENV["LISTEN_ADDRESS"]}:#{ENV["PORT"]}"
15
+ @remote_hosts = ENV['REMOTE_HOSTS'].split('|') unless ENV['REMOTE_HOSTS'].nil?
16
+
17
+ @clients = []
18
+ @remote_hosts&.each do |remote|
19
+ client = Client.new(socket: remote)
20
+ @clients.push(client)
21
+ end
22
+
23
+ @orchestrator = ServiceOrchestrator.new(socket: @socket)
24
+ @orchestrator.initialize_listener
25
+ end
26
+
27
+ def register_service(service:)
28
+ @orchestrator.add(service)
29
+ end
30
+
31
+ def start_listening_for_data
32
+ @orchestrator.start
33
+ end
34
+ 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
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'securerandom'
5
+
6
+ require_relative '../proto/cloud_event_services_pb'
7
+ require_relative '../grpc_services/cloud_event_enum'
8
+
9
+ # The Convert module provides functionality on custom data conversion operations.
10
+ module Convert
11
+ def self.json_to_cloudevent(data:)
12
+ raise JSON::ParserError, "invalid JSON: '#{data}'" unless valid_json?(json: data)
13
+
14
+ source = ENV['CLOUDEVENTS_SOURCE']
15
+ source = "#{ENV["LISTEN_ADDRESS"]}:#{ENV["PORT"]}" if source.nil?
16
+
17
+ CloudEvent.new(
18
+ id: SecureRandom.uuid,
19
+ source: source,
20
+ spec_version: ENV['CLOUDEVENTS_SPEC_VERSION'],
21
+ type: ENV['CLOUDEVENTS_TYPE_PREFIX'],
22
+ text_data: data,
23
+ attributes: generate_attributes,
24
+ )
25
+ end
26
+
27
+ def self.generate_attributes
28
+ now = Time.now
29
+
30
+ {
31
+ datacontenttype: {
32
+ ce_string: "application/json"
33
+ },
34
+ time: {
35
+ ce_timestamp: {
36
+ seconds: now.to_i,
37
+ nanos: now.nsec
38
+ }
39
+ }
40
+ }
41
+ end
42
+
43
+ def self.array_to_cloudevent_enum(array:)
44
+ CloudEventEnum.new(array: array)
45
+ end
46
+
47
+ def self.valid_json?(json:)
48
+ JSON.parse(json)
49
+ true
50
+ rescue JSON::ParserError, TypeError
51
+ false
52
+ end
53
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'securerandom'
4
+
5
+ require_relative '../error_classes/env_settings_error'
6
+ require_relative '../error_classes/socket_format_error'
7
+
8
+ # The Env module provides functionality for env variable settings.
9
+ module Env
10
+ def self.valid_settings?
11
+ mandatory_settings = %w[LISTEN_ADDRESS PORT CLOUDEVENTS_SPEC_VERSION CLOUDEVENTS_TYPE_PREFIX]
12
+ mandatory_settings.each do |setting|
13
+ raise EnvSettingsError, "environment variable '#{setting}' not found" if ENV[setting].nil?
14
+ end
15
+
16
+ socket = "#{ENV["LISTEN_ADDRESS"]}:#{ENV["PORT"]}"
17
+ raise SocketFormatError unless socket =~ /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}:\d{1,5}$/
18
+ end
19
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'teneo_microservice/client'
4
+ require_relative 'teneo_microservice/server'
metadata ADDED
@@ -0,0 +1,95 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: teneo_microservice
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ruben Vanoverschelde
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2025-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: grpc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description: This gem can be used to implement gRPC and CloudEvents communication
28
+ between microservices.
29
+ email:
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - CHANGELOG.md
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - README.md
38
+ - Rakefile
39
+ - bin/bundle
40
+ - bin/console
41
+ - bin/dotenv
42
+ - bin/grpc_tools_ruby_protoc
43
+ - bin/grpc_tools_ruby_protoc_plugin
44
+ - bin/htmldiff
45
+ - bin/irb
46
+ - bin/ldiff
47
+ - bin/protoc-gen-ruby
48
+ - bin/racc
49
+ - bin/rake
50
+ - bin/rdbg
51
+ - bin/rdoc
52
+ - bin/ri
53
+ - bin/rpc_server
54
+ - bin/rspec
55
+ - bin/rubocop
56
+ - bin/ruby-parse
57
+ - bin/ruby-rewrite
58
+ - bin/setup
59
+ - bin/thor
60
+ - lib/teneo_microservice.rb
61
+ - lib/teneo_microservice/client.rb
62
+ - lib/teneo_microservice/error_classes/env_settings_error.rb
63
+ - lib/teneo_microservice/error_classes/socket_format_error.rb
64
+ - lib/teneo_microservice/grpc_services/cloud_event_enum.rb
65
+ - lib/teneo_microservice/proto/cloud_event_pb.rb
66
+ - lib/teneo_microservice/proto/cloud_event_services_pb.rb
67
+ - lib/teneo_microservice/server.rb
68
+ - lib/teneo_microservice/service_orchestrator.rb
69
+ - lib/teneo_microservice/util/convert.rb
70
+ - lib/teneo_microservice/util/env.rb
71
+ homepage: https://github.com/libis/teneo-microservice-ruby
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ source_code_uri: https://github.com/libis/teneo-microservice-ruby
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '3.0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubygems_version: 3.3.5
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: Provides communication logic using the gRPC protocol and CloudEvents format.
95
+ test_files: []