turbine_rb 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2723a945ce0de61011f1afebdd6ba874a76ab666454c611dfb36573ca546a160
4
+ data.tar.gz: 63b28bd099bcafa485e4d2db7f995b45defd32a110ed9cec5a543f6507f87da0
5
+ SHA512:
6
+ metadata.gz: 530bb168de0ccbaa8c2eb83751268b45d5762ff662cbf63c74416eca9d5e49d5a4c4ccc30498f31fcc3b820504a387daead10d5dfad51f70d8e945f7af1bdb86
7
+ data.tar.gz: 62f1b54f0cca2abbf11e712563202ece58e41c4945ff0a6571d449b7b684b3dae066d687cd6e479924c03eaca5fa5f9cae1d208df543de98490d6d824d2be56b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,38 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.6
7
+ Exclude:
8
+ - lib/service_services_pb.rb
9
+ - lib/service_pb.rb
10
+ - lib/turbine_services_pb.rb
11
+ - lib/validate/validate_pb.rb
12
+ - lib/turbine_pb.rb
13
+ Style/Documentation:
14
+ Enabled: false
15
+
16
+ Style/StringLiterals:
17
+ Enabled: true
18
+ EnforcedStyle: double_quotes
19
+
20
+ Style/StringLiteralsInInterpolation:
21
+ Enabled: true
22
+ EnforcedStyle: double_quotes
23
+
24
+ Layout/LineLength:
25
+ Max: 120
26
+
27
+ Metrics/MethodLength:
28
+ Max: 20
29
+
30
+ RSpec/MultipleExpectations:
31
+ Max: 20
32
+
33
+ RSpec/ExampleLength:
34
+ Max: 20
35
+
36
+ # Enable this after refactoring spec/
37
+ RSpec/MultipleDescribes:
38
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## [0.1.0] - 2022-11-30
2
+
3
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 57750952+ahmeroxa@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in turbine_rb.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ group :development, :test do
11
+ gem "pry"
12
+ gem "rubocop", "~> 1.21", require: false
13
+ gem "rubocop-rake", "~> 0.6.0"
14
+ gem "rubocop-rspec", "~> 2.15"
15
+ end
16
+
17
+ group :test do
18
+ gem "guard-rspec"
19
+ gem "mocktail"
20
+ gem "rspec", "~> 3.0"
21
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,121 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ turbine_rb (0.1.0)
5
+ grpc (~> 1.48)
6
+ hash_dot (~> 2.5.0)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.5.0)
14
+ ffi (1.15.5)
15
+ formatador (1.1.0)
16
+ google-protobuf (3.21.9)
17
+ google-protobuf (3.21.9-x86_64-darwin)
18
+ google-protobuf (3.21.9-x86_64-linux)
19
+ googleapis-common-protos-types (1.4.0)
20
+ google-protobuf (~> 3.14)
21
+ grpc (1.50.0)
22
+ google-protobuf (~> 3.21)
23
+ googleapis-common-protos-types (~> 1.0)
24
+ grpc (1.50.0-x86_64-darwin)
25
+ google-protobuf (~> 3.21)
26
+ googleapis-common-protos-types (~> 1.0)
27
+ grpc (1.50.0-x86_64-linux)
28
+ google-protobuf (~> 3.21)
29
+ googleapis-common-protos-types (~> 1.0)
30
+ guard (2.18.0)
31
+ formatador (>= 0.2.4)
32
+ listen (>= 2.7, < 4.0)
33
+ lumberjack (>= 1.0.12, < 2.0)
34
+ nenv (~> 0.1)
35
+ notiffany (~> 0.0)
36
+ pry (>= 0.13.0)
37
+ shellany (~> 0.0)
38
+ thor (>= 0.18.1)
39
+ guard-compat (1.2.1)
40
+ guard-rspec (4.7.3)
41
+ guard (~> 2.1)
42
+ guard-compat (~> 1.1)
43
+ rspec (>= 2.99.0, < 4.0)
44
+ hash_dot (2.5.0)
45
+ json (2.6.2)
46
+ listen (3.7.1)
47
+ rb-fsevent (~> 0.10, >= 0.10.3)
48
+ rb-inotify (~> 0.9, >= 0.9.10)
49
+ lumberjack (1.2.8)
50
+ method_source (1.0.0)
51
+ mocktail (1.2.0)
52
+ nenv (0.3.0)
53
+ notiffany (0.1.3)
54
+ nenv (~> 0.1)
55
+ shellany (~> 0.0)
56
+ parallel (1.22.1)
57
+ parser (3.1.2.1)
58
+ ast (~> 2.4.1)
59
+ pry (0.14.1)
60
+ coderay (~> 1.1)
61
+ method_source (~> 1.0)
62
+ rainbow (3.1.1)
63
+ rake (13.0.6)
64
+ rb-fsevent (0.11.2)
65
+ rb-inotify (0.10.1)
66
+ ffi (~> 1.0)
67
+ regexp_parser (2.6.0)
68
+ rexml (3.2.5)
69
+ rspec (3.12.0)
70
+ rspec-core (~> 3.12.0)
71
+ rspec-expectations (~> 3.12.0)
72
+ rspec-mocks (~> 3.12.0)
73
+ rspec-core (3.12.0)
74
+ rspec-support (~> 3.12.0)
75
+ rspec-expectations (3.12.0)
76
+ diff-lcs (>= 1.2.0, < 2.0)
77
+ rspec-support (~> 3.12.0)
78
+ rspec-mocks (3.12.0)
79
+ diff-lcs (>= 1.2.0, < 2.0)
80
+ rspec-support (~> 3.12.0)
81
+ rspec-support (3.12.0)
82
+ rubocop (1.38.0)
83
+ json (~> 2.3)
84
+ parallel (~> 1.10)
85
+ parser (>= 3.1.2.1)
86
+ rainbow (>= 2.2.2, < 4.0)
87
+ regexp_parser (>= 1.8, < 3.0)
88
+ rexml (>= 3.2.5, < 4.0)
89
+ rubocop-ast (>= 1.23.0, < 2.0)
90
+ ruby-progressbar (~> 1.7)
91
+ unicode-display_width (>= 1.4.0, < 3.0)
92
+ rubocop-ast (1.23.0)
93
+ parser (>= 3.1.1.0)
94
+ rubocop-rake (0.6.0)
95
+ rubocop (~> 1.0)
96
+ rubocop-rspec (2.15.0)
97
+ rubocop (~> 1.33)
98
+ ruby-progressbar (1.11.0)
99
+ shellany (0.0.1)
100
+ thor (1.2.1)
101
+ unicode-display_width (2.3.0)
102
+
103
+ PLATFORMS
104
+ arm64-darwin-22
105
+ x86_64-darwin-20
106
+ x86_64-darwin-22
107
+ x86_64-linux
108
+
109
+ DEPENDENCIES
110
+ guard-rspec
111
+ mocktail
112
+ pry
113
+ rake (~> 13.0)
114
+ rspec (~> 3.0)
115
+ rubocop (~> 1.21)
116
+ rubocop-rake (~> 0.6.0)
117
+ rubocop-rspec (~> 2.15)
118
+ turbine_rb!
119
+
120
+ BUNDLED WITH
121
+ 2.3.7
data/Guardfile ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
+ watch(%r{^spec/.+_spec\.rb$})
5
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
+ watch("spec/spec_helper.rb") { "spec" }
7
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,3 @@
1
+ Copyright Ⓒ 2022 Meroxa Inc.
2
+
3
+ All code in this repository is copyrighted and proprietary. It is not licensed for usage, distribution and/or modification of any kind.
data/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # TurbineRb
2
+ > PLEASE NOTE: TurbineRB is currently a work in progress, and the following features may or may not be ready
3
+
4
+ Turbine is a data application framework for building server-side applications that are event-driven, respond to data in real-time, and scale using cloud-native best practices
5
+
6
+ The benefits of using Turbine include:
7
+
8
+ * **Native Developer Tooling:** Turbine doesn't come with any bespoke DSL or patterns. Write software like you normally would!
9
+
10
+ * **Fits into Existing DevOps Workflows:** Build, test, and deploy. Turbine encourages best practices from the start. Don't test your data app in production ever again.
11
+
12
+ * **Local Development mirrors Production:** When running locally, you'll immediately see how your app reacts to data. What you get there will be exactly what happens in production but with _scale_ and _speed_.
13
+
14
+ * **Available in many different programming langauages:** Turbine started out in Go but is available in other languages too:
15
+ * [Go](https://github.com/meroxa/turbine-go)
16
+ * [Javascript](https://github.com/meroxa/turbine-js)
17
+ * [Python](https://github.com/meroxa/turbine-py)
18
+ * [Ruby](https://github.com/meroxa/turbine-core/tree/main/lib/ruby/turbine_rb)
19
+
20
+
21
+ ## Getting Started
22
+ > PLEASE NOTE: This Meroxa CLI `init` command is not yet implemented for ruby apps, coming soon!
23
+
24
+ To get started, you'll need to [download the Meroxa CLI](https://github.com/meroxa/cli#installation-guide). Once downloaded and installed, you'll need to back to your terminal and initialize a new project:
25
+
26
+ ```bash
27
+ $ meroxa apps init testapp --lang ruby
28
+ ```
29
+
30
+ The CLI will create a new folder called `testapp` located in the directory where the command was issued. If you want to initialize the app somewhere else, you can append the `--path` flag to the command (`meroxa apps init testapp --lang ruby --path ~/anotherdir`). Once you enter the `testapp` directory, the contents will look like this:
31
+
32
+ ```bash
33
+ $ tree testapp/
34
+ testapp
35
+ ├── app.rb
36
+ ├── Gemfile
37
+ ├── Gemfile.lock
38
+ └── fixtures
39
+ └── demo.json
40
+ ```
41
+
42
+ This will be a full-fledged Turbine app that can run. It provides just enough to show you what you need to get started.
43
+
44
+ ### `app.rb`
45
+
46
+ This configuration file is where you begin your Turbine journey. Any time a Turbine app runs, this is the entry point for the entire application. When the project is created, the file will look like this:
47
+
48
+ ```rb
49
+ # frozen_string_literal: true
50
+ require 'rubygems'
51
+ require 'bundler/setup'
52
+ require 'turbine_rb'
53
+
54
+ # Define your function
55
+ class Passthrough < TurbineRb::Process
56
+ def call(records:)
57
+ records.each do |record|
58
+ puts record.get("message")
59
+ end
60
+
61
+ records
62
+ end
63
+ end
64
+
65
+ # Define your app configuration with your function
66
+ class MyApp
67
+ def call(app)
68
+ database = app.resource(name: 'demopg')
69
+
70
+ # procedural API
71
+ records = database.records(collection: 'events')
72
+
73
+ # This register the secret to be available in the turbine application
74
+ app.register_secrets("MY_ENV_TEST")
75
+
76
+ # you can also register several secrets at once
77
+ # app.register_secrets(["MY_ENV_TEST", "MY_OTHER_ENV_TEST"])
78
+
79
+ processed_records = app.process(records: records, process: Passthrough.new) # Passthrough just has to match the signature
80
+ database.write(records: processed_records, collection: "events_copy")
81
+ end
82
+ end
83
+
84
+
85
+ # Register your app with Turbine
86
+ TurbineRb.register(MyApp.new)
87
+ ```
88
+
89
+ Let's talk about the important parts of this code. Turbine apps have five methods that comprise the entire DSL. Outside of these methods, you can write whatever code you want to accomplish your tasks:
90
+
91
+ ```rb
92
+ call(app)
93
+ ```
94
+
95
+ `call` is the main entry point for the application. This is where you can initialize the Turbine framework. This is also the place where, when you deploy your Turbine app to Meroxa, Meroxa will use this as the place to boot up the application.
96
+
97
+ ```rb
98
+ database = app.resource(name: 'demopg')
99
+ ```
100
+
101
+ The `resource` method identifies the upstream or downstream system that you want your code to work with. The `name` is the string identifier of the particular system. The string should map to an associated identifier in your `app.json` to configure what's being connected to. For more details, see the `app.json` section.
102
+
103
+ ```rb
104
+ records = database.records(collection: 'events')
105
+ ```
106
+
107
+ Once you've got `resource` set up, you can now stream records from it, but you need to identify what records you want. The `records` method identifies the records or events that you want to stream into your data app.
108
+
109
+ ```rb
110
+ processed_records = app.process(records: records, process: Passthrough.new)
111
+ ```
112
+
113
+ The `process` method is Turbine's way of saying, for the records that are coming in, I want you to process these records against a function. Once your app is deployed on Meroxa, Meroxa will do the work to take each record or event that does get streamed to your app and then run your code against it. This allows Meroxa to scale out your processing relative to the velocity of the records streaming in.
114
+
115
+ ```rb
116
+ database.write(records: processed_records, collection: "events_copy")
117
+ ```
118
+
119
+ The `write` method is optional. It takes any records given to it and streams them to the downstream system. In many cases, you might not need to stream data to another system, but this gives you an easy way to do so.
120
+
121
+
122
+ #### Function API
123
+ The function passed to `process` is defined by the user with the following signature
124
+ ```rb
125
+ class Passthrough < TurbineRb::Process
126
+ def call(records:)
127
+ records
128
+ end
129
+ end
130
+ ```
131
+
132
+ The `records` parameter is an array of records that can be iterated on. Each `record` in the `records` array comes with some handy methods for reading from/writing to the record's data as it passes through the function.
133
+
134
+ These methods are the preferred way for accessing data. They will work regardless if the data is CDC formatted or not (as long as the actual payload data is a valid JSON object)
135
+
136
+
137
+ ```rb
138
+ record.get('key') # Will retrieve the value at `key`
139
+ ```
140
+
141
+
142
+
143
+ ```rb
144
+ record.set('key', 'some value') # Will set `some_value` at `key`
145
+ ```
146
+
147
+
148
+ The `records` parameter itself comes with an optional but important method
149
+
150
+ ```rb
151
+ records.unwrap!;
152
+ ```
153
+
154
+ A user can optionally use this transform in their data app function to unwrap CDC formatted records into the right format that destinations expect. Currently, most destinations will not accept CDC formatted data. **_(s3 being an exception)_**
155
+
156
+ A user **_will_** want to call this when records are going to any destination (usually at the end of the data app function).
157
+
158
+ A user **_will not_** want to call this when the records are going to an s3 destination AND they need the CDC format preserved
159
+
160
+ Note that this function only operates on CDC formatted data, and no ops otherwise.
161
+
162
+ ### `app.json`
163
+
164
+ This file contains all of the options for configuring a Turbine app. Upon initialization of an app, the CLI will scaffold the file for you with available options:
165
+
166
+ ```
167
+ {
168
+ "name": "testapp",
169
+ "language": "ruby",
170
+ "environment": "common",
171
+ "resources": {
172
+ "source_name": "fixtures/path"
173
+ }
174
+ }
175
+ ```
176
+
177
+ * `name` - The name of your application. This should not change after app initialization.
178
+ * `language` - Tells Meroxa what language the app is upon deployment.
179
+ * `environment` - "common" is the only available environment. Meroxa does have the ability to create isolated environments but this feature is currently in beta.
180
+ * `resources` - These are the named integrations that you'll use in your application. The `source_name` needs to match the name of the resource that you'll set up in Meroxa using the `meroxa resources create` command or via the Dashboard. You can point to the path in the fixtures that'll be used to mock the resource when you run `meroxa apps run`.
181
+
182
+ ### Fixtures
183
+
184
+ Fixtures are JSON-formatted samples of data records you can use while locally developing your Turbine app. Whether CDC or non-CDC-formatted data records, fixtures adhere to the following structure:
185
+
186
+ ```json
187
+ {
188
+ "collection_name": [
189
+ {
190
+ "key": "1",
191
+ "value": {
192
+ "schema": {
193
+ //...
194
+ },
195
+ "payload": {
196
+ //...
197
+ }
198
+ }
199
+ }
200
+ ]
201
+ ```
202
+ * `collection_name` — Identifies the name of the records or events you are streaming to your data app.
203
+ * `key` — Denotes one or more sample records within a fixture file. `key` is always a string.
204
+ * `value` — Holds the `schema` and `payload` of the sample data record.
205
+ * `schema` — Comes as part of your sample data record. `schema` describes the record or event structure.
206
+ * `payload` — Comes as part of your sample data record. `payload` describes what about the record or event changed.
207
+
208
+ Your newly created data app should have a `demo-cdc.json` and `demo-non-cdc.json` in the `/fixtures` directory as examples to follow.
209
+
210
+ ## Documentation && Reference
211
+
212
+ The most comprehensive documentation for Turbine and how to work with Turbine apps is on the Meroxa site: [https://docs.meroxa.com/](https://docs.meroxa.com)
213
+
214
+
215
+ ## Development
216
+
217
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
218
+
219
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
220
+
221
+ ## Contributing
222
+
223
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/turbine_rb.
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/bin/turbine-build ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "turbine_rb"
5
+ require File.join(Dir.getwd, "app")
6
+
7
+ TurbineRb.build
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "turbine_rb"
5
+ require File.join(Dir.getwd, "app")
6
+
7
+ TurbineRb.serve
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "turbine_rb"
5
+ require File.join(Dir.getwd, "app")
6
+
7
+ TurbineRb.record
data/bin/turbine-run ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "turbine_rb"
5
+ require File.join(Dir.getwd, "app")
6
+
7
+ TurbineRb.run
data/lib/service_pb.rb ADDED
@@ -0,0 +1,33 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: service.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/protobuf/struct_pb'
7
+
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("service.proto", :syntax => :proto3) do
10
+ add_message "io.meroxa.funtime.ProcessRecordRequest" do
11
+ repeated :records, :message, 1, "io.meroxa.funtime.Record"
12
+ end
13
+ add_message "io.meroxa.funtime.ProcessRecordResponse" do
14
+ repeated :records, :message, 1, "io.meroxa.funtime.Record"
15
+ end
16
+ add_message "io.meroxa.funtime.Record" do
17
+ optional :key, :string, 1
18
+ optional :value, :string, 2
19
+ optional :timestamp, :int64, 3
20
+ optional :structured, :message, 4, "google.protobuf.Struct"
21
+ end
22
+ end
23
+ end
24
+
25
+ module Io
26
+ module Meroxa
27
+ module Funtime
28
+ ProcessRecordRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("io.meroxa.funtime.ProcessRecordRequest").msgclass
29
+ ProcessRecordResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("io.meroxa.funtime.ProcessRecordResponse").msgclass
30
+ Record = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("io.meroxa.funtime.Record").msgclass
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,26 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: service.proto for package 'io.meroxa.funtime'
3
+
4
+ require 'grpc'
5
+ require 'service_pb'
6
+
7
+ module Io
8
+ module Meroxa
9
+ module Funtime
10
+ module Function
11
+ class Service
12
+
13
+ include ::GRPC::GenericService
14
+
15
+ self.marshal_class_method = :encode
16
+ self.unmarshal_class_method = :decode
17
+ self.service_name = 'io.meroxa.funtime.Function'
18
+
19
+ rpc :Process, ::Io::Meroxa::Funtime::ProcessRecordRequest, ::Io::Meroxa::Funtime::ProcessRecordResponse
20
+ end
21
+
22
+ Stub = Service.rpc_stub_class
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,6 @@
1
+ FROM ruby:3.1.2
2
+ WORKDIR /app
3
+ COPY . .
4
+ RUN bundle install
5
+ USER nobody
6
+ ENTRYPOINT ["bundle exec turbine-function"]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "turbine_rb"
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "ruby-example",
3
+ "language": "ruby",
4
+ "environment": "common",
5
+ "resources": {
6
+ "demopg": "fixtures/demo.json"
7
+ }
8
+ }