ksql 0.1.0.beta → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2cd9a1d71cc892172f660cee8406014672b19bc7a510cf6897194201ab9fbf76
4
- data.tar.gz: acef9c5aca159a91667816ef3b6c53c54bfa432e141bdff755cbad7ea7a3e986
3
+ metadata.gz: 13cc776919dbadd0408486e4063dd2f86e80ff57fdc7ef5494b35022689265f9
4
+ data.tar.gz: 0f11121ecebae6db4a5a0c30d0d5a826cf2023364080dcc31523fed23417184b
5
5
  SHA512:
6
- metadata.gz: 603741e0d00a8bc9c8193473600b2314c9cebb4fbbf0de321127ce52d91d78cfe70710a45d6ec1721e80109811645f207186b2c3aedab967c5485771e822bac6
7
- data.tar.gz: 3e50792e2df0bca4ccf27fb8991ff727099d761284bff71303390fdaa23233ea12756dc92fda170d72ddcdfb4bb3112360c88658ca90a8a4f8f97ddbda58b5ea
6
+ metadata.gz: 4583d9d6ae7c273369ed0a5b2b3dfbd2bdf427bedd548008ef11b36e9daaaa739acc21642aa5bc3496d370eab46142fa0b87fc9fa679857e3c5dcf0a77f7959b
7
+ data.tar.gz: 8128a30f0aacb1909b6f740c930727ee26a2b74c6481544d3ae18690c3466ab94d0e054c769e38ff0100fce3e58d280e5578d14c76f9263fb9158534da6beb7e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  ## [Releases]
2
2
 
3
+ ## [0.1.2] - 2022-05-15
4
+
5
+ ### Fixed
6
+
7
+ - Missing cluster_status require.
8
+
9
+ ## [0.1.1] - 2022-05-05
10
+
11
+ ### Fixed
12
+
13
+ - Typo on Stream closing error message. ( Thanks to @ook )
14
+
15
+ ## [0.1.0] - 2022-05-05
16
+
17
+ - Yanked
18
+
19
+ ## [0.1.0.beta.1] - 2022-03-17
20
+
21
+ ### Added
22
+
23
+ - `/clusterStatus` endpoint support
24
+ - `/healthcheck` endpoint support
25
+ - `/info` endpoint support
26
+ - `/terminate` endpoint support
27
+
3
28
  ## [0.1.0.beta] - 2022-02-24
4
29
 
5
30
  - Beta 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 lapoelisacci@gmail.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 CHANGED
@@ -5,10 +5,10 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in ksql.gemspec
6
6
  gemspec
7
7
 
8
- gem 'byebug', '~> 11'
9
-
10
8
  gem 'rake', '~> 13'
11
9
 
12
10
  gem 'rspec', '~> 3'
13
11
 
14
12
  gem 'rubocop', '~> 1'
13
+
14
+ gem 'simplecov', require: false, group: :test
data/Gemfile.lock CHANGED
@@ -1,31 +1,24 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ksql (0.1.0)
4
+ ksql (0.1.2)
5
5
  activesupport (>= 5)
6
- hashie (~> 4)
7
6
  net-http2 (~> 0)
8
7
 
9
8
  GEM
10
9
  remote: https://rubygems.org/
11
10
  specs:
12
- activesupport (7.0.1)
11
+ activesupport (7.0.3)
13
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
14
13
  i18n (>= 1.6, < 2)
15
14
  minitest (>= 5.1)
16
15
  tzinfo (~> 2.0)
17
- addressable (2.8.0)
18
- public_suffix (>= 2.0.2, < 5.0)
19
16
  ast (2.4.2)
20
- byebug (11.1.3)
21
- concurrent-ruby (1.1.9)
22
- crack (0.4.5)
23
- rexml
17
+ concurrent-ruby (1.1.10)
24
18
  diff-lcs (1.5.0)
25
- hashdiff (1.0.1)
26
- hashie (4.1.0)
19
+ docile (1.4.0)
27
20
  http-2 (0.11.0)
28
- i18n (1.9.1)
21
+ i18n (1.10.0)
29
22
  concurrent-ruby (~> 1.0)
30
23
  minitest (5.15.0)
31
24
  net-http2 (0.18.4)
@@ -33,7 +26,6 @@ GEM
33
26
  parallel (1.21.0)
34
27
  parser (3.0.3.2)
35
28
  ast (~> 2.4.1)
36
- public_suffix (4.0.6)
37
29
  rainbow (3.0.0)
38
30
  rake (13.0.6)
39
31
  regexp_parser (2.2.0)
@@ -63,26 +55,27 @@ GEM
63
55
  rubocop-ast (1.15.0)
64
56
  parser (>= 3.0.1.1)
65
57
  ruby-progressbar (1.11.0)
58
+ simplecov (0.21.2)
59
+ docile (~> 1.1)
60
+ simplecov-html (~> 0.11)
61
+ simplecov_json_formatter (~> 0.1)
62
+ simplecov-html (0.12.3)
63
+ simplecov_json_formatter (0.1.4)
66
64
  tzinfo (2.0.4)
67
65
  concurrent-ruby (~> 1.0)
68
66
  unicode-display_width (2.1.0)
69
- vcr (6.0.0)
70
- webmock (3.14.0)
71
- addressable (>= 2.8.0)
72
- crack (>= 0.3.2)
73
- hashdiff (>= 0.4.0, < 2.0.0)
74
67
 
75
68
  PLATFORMS
69
+ arm64-darwin-21
76
70
  x86_64-darwin-20
71
+ x86_64-linux
77
72
 
78
73
  DEPENDENCIES
79
- byebug (~> 11)
80
74
  ksql!
81
75
  rake (~> 13)
82
76
  rspec (~> 3)
83
77
  rubocop (~> 1)
84
- vcr (~> 6)
85
- webmock (~> 3)
78
+ simplecov
86
79
 
87
80
  BUNDLED WITH
88
- 2.3.7
81
+ 2.3.9
data/README.md CHANGED
@@ -1,19 +1,22 @@
1
- ![][ruby-shield]
1
+ ## <img src="https://user-images.githubusercontent.com/50866745/156314925-b823bfe2-a9d4-4b83-8376-29a6a659b57f.png" width="48"> ksqlDB Client <!-- omit in toc -->
2
+ [![CircleCI](https://circleci.com/gh/LapoElisacci/Ksql/tree/main.svg?style=svg)](https://circleci.com/gh/LapoElisacci/Ksql/tree/main)
3
+ ![](https://img.shields.io/static/v1?label=Coverage&message=98.78%&color=brightgreen)
4
+ ![](https://img.shields.io/static/v1?label=Latest&message=0.1.1&color=blue)
5
+ ![](https://ruby-gem-downloads-badge.herokuapp.com/ksql?type=total&color=blue)
6
+ ![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)
2
7
 
3
- # ![ksql-rocket](https://user-images.githubusercontent.com/50866745/155471557-6fe01746-444f-4ff6-a164-eeeb3b4b53a1.png) Ruby ksqlDB Client (Under QA)
8
+ **KSQL** is a [ksqlDB](https://ksqldb.io/) Ruby client that focuses on ease of use. Supports all recent ksqlDB features and does not have any heavyweight dependencies.
4
9
 
5
- ![](https://img.shields.io/static/v1?label=Latest&message=0.1.0&color=blue)
6
- ![](https://img.shields.io/static/v1?label=Coverage&message=95%&color=green)
7
- ![](https://img.shields.io/static/v1?label=Documentation&message=98%&color=success)
8
- ![](https://img.shields.io/static/v1?label=Mantained?&message=Yes&color=success)
10
+ ## What is ksqlDB? <!-- omit in toc -->
9
11
 
10
- KSQL is a [ksqlDB](https://ksqldb.io/) Ruby client that focuses on ease of use. Supports all recent ksqlDB features and does not have any heavyweight dependencies.
12
+ ksqlDB is a database purpose-built for [Apache Kafka®](https://kafka.apache.org/) streams processing applications, more details [here](https://ksqldb.io/).
11
13
 
12
- ## What is ksqlDB?
14
+ **Official KLIP:** <!-- omit in toc -->
13
15
 
14
- ksqlDB is a database purpose-built for [Apache Kafka®](https://kafka.apache.org/) streams processing applications, more details [here](https://ksqldb.io/).
16
+ - https://github.com/confluentinc/ksql/pull/8794
17
+ - https://github.com/confluentinc/ksql/pull/8865
15
18
 
16
- ## Installation
19
+ ## Installation <!-- omit in toc -->
17
20
 
18
21
  Add this line to your application's Gemfile:
19
22
 
@@ -29,12 +32,32 @@ Or install it yourself as:
29
32
 
30
33
  $ gem install ksql
31
34
 
32
- ## Usage
35
+ ## Usage <!-- omit in toc -->
33
36
 
34
37
  The gem allows you to perform requests to ksqlDB REST API.
35
38
  Checkout the ksqlDB official documentation [here](https://docs.ksqldb.io/en/latest/developer-guide/api/).
36
39
 
37
- ### Configuration
40
+ ## Table of contents <!-- omit in toc -->
41
+
42
+ - [Configuration](#configuration)
43
+ - [Statements](#statements)
44
+ - [Queries](#queries)
45
+ - [Persistent Query](#persistent-query)
46
+ - [Push Query](#push-query)
47
+ - [Pull Query](#pull-query)
48
+ - [Cluster Status](#cluster-status)
49
+ - [Health Check](#health-check)
50
+ - [Info](#info)
51
+ - [Terminate](#terminate)
52
+ - [Example](#example)
53
+ - [Supported ksqlDB versions](#supported-ksqldb-versions)
54
+ - [Known issues](#known-issues)
55
+ - [ksqlDB close-query](#ksqldb-close-query)
56
+ - [Development](#development)
57
+ - [Contributing](#contributing)
58
+ - [License](#license)
59
+
60
+ ## Configuration
38
61
 
39
62
  The gem requires a minimum configuration to connect to ksqlDB, it is shipped with a built-in generator to create a Rails initializer.
40
63
 
@@ -48,9 +71,7 @@ Ksql.configure do |config|
48
71
  end
49
72
  ```
50
73
 
51
- **The Client supports Basic Authentication only**
52
-
53
- ### [Statements](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/ksql-endpoint/)
74
+ ## [Statements](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/ksql-endpoint/)
54
75
 
55
76
  All statements, except those starting with `SELECT` can be run with the `ksql` method:
56
77
 
@@ -185,6 +206,46 @@ end
185
206
  locations.count
186
207
  ```
187
208
 
209
+ ## [Cluster Status](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/cluster-status-endpoint/)
210
+
211
+ The client allows you to introspect the cluster status with the `cluster_status` method.
212
+
213
+ **Careful:** The `/clusterStatus` endpoint is not enabled by default, read more [here](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/cluster-status-endpoint/)
214
+
215
+ ```Ruby
216
+ Ksql::Client.cluster_status
217
+ ```
218
+
219
+ ## [Health Check](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/info-endpoint/)
220
+
221
+ You can also check the health of your ksqlDB server by calling the `health_check` method.
222
+
223
+ ```Ruby
224
+ Ksql::Client.health_check
225
+ ```
226
+
227
+ ## [Info](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/info-endpoint/)
228
+
229
+ To get information about the status of a ksqlDB Server call the `info` method.
230
+
231
+ ```Ruby
232
+ Ksql::Client.info
233
+ ```
234
+
235
+ ## [Terminate](https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-rest-api/terminate-endpoint/)
236
+
237
+ You can terminate the cluster and clean up the resources calling the `terminate` method.
238
+
239
+ ```Ruby
240
+ Ksql::Client.terminate
241
+ ```
242
+
243
+ You can provide a list of kafka topic names or regular expressions for Kafka topic names along to delete all topics with names that are in the list or that match any of the regular expressions in the list.
244
+
245
+ ```Ruby
246
+ Ksql::Client.terminate(delete_topic_list: ["FOO", "bar.*"])
247
+ ```
248
+
188
249
  ## Example
189
250
 
190
251
  The following example is from the official ksqlDB [Quickstart](https://ksqldb.io/quickstart.html):
@@ -278,17 +339,15 @@ Ksql::Client.ksql('DROP STREAM IF EXISTS riderLocations;')
278
339
 
279
340
  ```
280
341
 
342
+
281
343
  ## Supported ksqlDB versions
282
344
 
283
345
  | Version | |
284
346
  | ------ | -- |
285
- | 0.23.1 | :heavy_check_mark: Supported |
286
- | 0.22.0 | :heavy_check_mark: Supported |
287
- | 0.21.0 | :heavy_check_mark: Supported |
288
- | 0.20.0 | :heavy_check_mark: Supported |
289
- | 0.19.0 | :heavy_check_mark: Supported |
290
- | 0.18.0 | :heavy_check_mark: Supported |
291
- | 0.17.0 | :x: Untested |
347
+ | 0.25 | :heavy_check_mark: Supported |
348
+ | 0.24 | :heavy_check_mark: Supported |
349
+ | 0.23 | :heavy_check_mark: Supported |
350
+ | 0.22 | :heavy_check_mark: Supported |
292
351
  | Older | :x: Untested |
293
352
 
294
353
  ## Known issues
@@ -314,6 +373,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/LapoEl
314
373
 
315
374
  [![Licence](https://img.shields.io/github/license/Ileriayo/markdown-badges?style=for-the-badge)](https://opensource.org/licenses/MIT)
316
375
 
317
- <!--- MARKDOWN LINKS --->
318
-
319
- [ruby-shield]: https://img.shields.io/badge/Ruby-CC342D?style=for-the-badge&logo=ruby&logoColor=white
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ksql
4
+ module Api
5
+ class ClusterStatus
6
+ Headers = { 'Accept' => 'application/json' }.freeze
7
+
8
+ #
9
+ # Build the ksqlDB /clusterStatus request
10
+ #
11
+ # @param [Hash] headers Request headers
12
+ #
13
+ # @return [Ksql::Connection::Request] Request instance
14
+ #
15
+ def self.build(headers:)
16
+ ::Ksql::Connection::Request.new(
17
+ {},
18
+ '/clusterStatus',
19
+ Headers.merge(headers),
20
+ :get
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ksql
4
+ module Api
5
+ class HealthCheck
6
+ Headers = { 'Accept' => 'application/json' }.freeze
7
+
8
+ #
9
+ # Build the ksqlDB /healthcheck request
10
+ #
11
+ # @param [Hash] headers Request headers
12
+ #
13
+ # @return [Ksql::Connection::Request] Request instance
14
+ #
15
+ def self.build(headers:)
16
+ ::Ksql::Connection::Request.new(
17
+ {},
18
+ '/healthcheck',
19
+ Headers.merge(headers),
20
+ :get
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ksql
4
+ module Api
5
+ class Info
6
+ Headers = { 'Accept' => 'application/json' }.freeze
7
+
8
+ #
9
+ # Build the ksqlDB /info request
10
+ #
11
+ # @param [Hash] headers Request headers
12
+ #
13
+ # @return [Ksql::Connection::Request] Request instance
14
+ #
15
+ def self.build(headers:)
16
+ ::Ksql::Connection::Request.new(
17
+ {},
18
+ '/info',
19
+ Headers.merge(headers),
20
+ :get
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Ksql
4
+ module Api
5
+ class Terminate
6
+ Headers = { 'Accept' => 'application/json' }.freeze
7
+
8
+ #
9
+ # Build the ksqlDB /ksql/terminate request
10
+ #
11
+ # @param [Array<String>] delete_topic_list Kafka topic names or regular expressions
12
+ # @param [Hash] headers Request headers
13
+ #
14
+ # @return [Ksql::Connection::Request] Request instance
15
+ #
16
+ def self.build(delete_topic_list = null, headers:)
17
+ ::Ksql::Connection::Request.new(
18
+ { deleteTopicList: delete_topic_list }.compact,
19
+ '/ksql/terminate',
20
+ Headers.merge(headers),
21
+ :post
22
+ )
23
+ end
24
+ end
25
+ end
26
+ end
data/lib/ksql/client.rb CHANGED
@@ -17,6 +17,42 @@ module Ksql
17
17
  Handlers::Raw.handle(result)
18
18
  end
19
19
 
20
+ #
21
+ # Request /clusterStatus endpoint synchronously
22
+ #
23
+ # @param [Hash] headers Request headers
24
+ #
25
+ # @return [JSON] Request response
26
+ #
27
+ def cluster_status(headers: {})
28
+ request = Api::ClusterStatus.build(headers: headers)
29
+ Connection::Client.call_sync(request)
30
+ end
31
+
32
+ #
33
+ # Request /healthcheck endpoint synchronously
34
+ #
35
+ # @param [Hash] headers Request headers
36
+ #
37
+ # @return [JSON] Request response
38
+ #
39
+ def health_check(headers: {})
40
+ request = Api::HealthCheck.build(headers: headers)
41
+ Connection::Client.call_sync(request)
42
+ end
43
+
44
+ #
45
+ # Request /info endpoint synchronously
46
+ #
47
+ # @param [Hash] headers Request headers
48
+ #
49
+ # @return [JSON] Request response
50
+ #
51
+ def info(headers: {})
52
+ request = Api::Info.build(headers: headers)
53
+ Connection::Client.call_sync(request)
54
+ end
55
+
20
56
  #
21
57
  # Request /ksql endpoint
22
58
  #
@@ -31,7 +67,7 @@ module Ksql
31
67
  def ksql(ksql, command_sequence_number: nil, headers: {}, session_variables: {}, streams_properties: {})
32
68
  request = Api::Ksql.build(ksql, command_sequence_number: command_sequence_number, headers: headers, session_variables: session_variables, streams_properties: streams_properties)
33
69
  result = Connection::Client.call_sync(request)
34
- Handlers::TypedRow.handle(result)
70
+ Handlers::TypedList.handle(result)
35
71
  end
36
72
 
37
73
  #
@@ -65,6 +101,18 @@ module Ksql
65
101
  client, prepared_request = Connection::Client.call_async(request)
66
102
  Handlers::Stream.handle(client, prepared_request)
67
103
  end
104
+
105
+ #
106
+ # Request /terminate endpoint synchronously
107
+ #
108
+ # @param [Array<String>] delete_topic_list Kafka topic names or regular expressions
109
+ #
110
+ # @return [JSON] Request response
111
+ #
112
+ def terminate(delete_topic_list: nil, headers: {})
113
+ request = Api::Terminate.build(delete_topic_list, headers: headers)
114
+ Connection::Client.call_sync(request)
115
+ end
68
116
  end
69
117
  end
70
118
  end
@@ -1,3 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Ksql::Configuration < OpenStruct; end
3
+ module Ksql
4
+ class ConfigurationError < StandardError; end
5
+
6
+ #
7
+ # Ksql configuration
8
+ #
9
+ class Configuration
10
+ REQUIRED_ATTRS = %i[host].freeze
11
+ OPTIONAL_ATTRS = %i[auth].freeze
12
+
13
+ attr_accessor(*REQUIRED_ATTRS + OPTIONAL_ATTRS)
14
+
15
+ #
16
+ # Ensure required attributes are properly configured
17
+ #
18
+ # @return [Boolean] true
19
+ #
20
+ def validate
21
+ REQUIRED_ATTRS.each do |attribute|
22
+ value = instance_variable_get("@#{attribute}")
23
+ raise ConfigurationError, "Ksql required #{attribute} missing!" if value.nil? || value.strip.empty?
24
+ end
25
+
26
+ true
27
+ end
28
+ end
29
+ end
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Ksql
4
4
  module Connection
5
- class Request < Struct.new(:body, :endpoint, :headers, :method)
5
+ class Request < Struct.new(:body, :path, :headers, :method)
6
6
  #
7
7
  # Returns the request params
8
8
  #
9
9
  # @return [Array] Request params
10
10
  #
11
11
  def to_params
12
- return method, endpoint, { body: body.to_json, headers: headers.merge(auth_headers) }
12
+ return method, path, { body: body.to_json, headers: headers.merge(auth_headers) }.compact
13
13
  end
14
14
 
15
15
  private
data/lib/ksql/error.rb CHANGED
@@ -2,6 +2,5 @@
2
2
 
3
3
  module Ksql
4
4
  class Error < OpenStruct
5
- # Description here
6
5
  end
7
6
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Ksql
4
4
  module Handlers
5
- class TypedRow
5
+ class TypedList
6
6
  #
7
7
  # Define and instanciate an OpenStruct to fit the typed request response
8
8
  #
data/lib/ksql/stream.rb CHANGED
@@ -15,7 +15,7 @@ module Ksql
15
15
  # Close the streaming connection
16
16
  #
17
17
  def close
18
- raise StreamError.new('The stream hasn\'t stared!') unless @id.present?
18
+ raise StreamError.new('The stream hasn\'t started!') unless @id.present?
19
19
 
20
20
  @client.close
21
21
  end
data/lib/ksql/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ksql
4
- VERSION = '0.1.0.beta'
4
+ VERSION = '0.1.2'
5
5
  end
data/lib/ksql.rb CHANGED
@@ -6,14 +6,18 @@ require 'json'
6
6
  require 'ostruct'
7
7
 
8
8
  require_relative 'ksql/api/close_query'
9
+ require_relative 'ksql/api/cluster_status'
10
+ require_relative 'ksql/api/health_check'
11
+ require_relative 'ksql/api/info'
9
12
  require_relative 'ksql/api/ksql'
10
13
  require_relative 'ksql/api/query'
11
14
  require_relative 'ksql/api/stream'
15
+ require_relative 'ksql/api/terminate'
12
16
 
13
17
  require_relative 'ksql/handlers/collection'
14
18
  require_relative 'ksql/handlers/raw'
15
19
  require_relative 'ksql/handlers/stream'
16
- require_relative 'ksql/handlers/typed_row'
20
+ require_relative 'ksql/handlers/typed_list'
17
21
 
18
22
  require_relative 'ksql/connection/client'
19
23
  require_relative 'ksql/connection/request'
@@ -28,11 +32,18 @@ require_relative 'ksql/stream'
28
32
  require_relative 'ksql/version'
29
33
 
30
34
  module Ksql
31
- def self.config
32
- @config ||= Ksql::Configuration.new
33
- end
34
-
35
- def self.configure
36
- yield(config)
35
+ class << self
36
+ attr_accessor :config
37
+
38
+ #
39
+ # Configure Ksql
40
+ #
41
+ # @return [Boolean] true
42
+ #
43
+ def configure
44
+ self.config = Ksql::Configuration.new
45
+ yield(config)
46
+ config.validate
47
+ end
37
48
  end
38
49
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ksql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.beta
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lapo Elisacci
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-24 00:00:00.000000000 Z
11
+ date: 2022-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '5'
27
- - !ruby/object:Gem::Dependency
28
- name: hashie
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '4'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '4'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: net-http2
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -62,6 +48,7 @@ files:
62
48
  - ".rspec"
63
49
  - ".rubocop.yml"
64
50
  - CHANGELOG.md
51
+ - CODE_OF_CONDUCT.md
65
52
  - Gemfile
66
53
  - Gemfile.lock
67
54
  - LICENSE.txt
@@ -72,9 +59,13 @@ files:
72
59
  - lib/generators/templates/initializer.rb
73
60
  - lib/ksql.rb
74
61
  - lib/ksql/api/close_query.rb
62
+ - lib/ksql/api/cluster_status.rb
63
+ - lib/ksql/api/health_check.rb
64
+ - lib/ksql/api/info.rb
75
65
  - lib/ksql/api/ksql.rb
76
66
  - lib/ksql/api/query.rb
77
67
  - lib/ksql/api/stream.rb
68
+ - lib/ksql/api/terminate.rb
78
69
  - lib/ksql/client.rb
79
70
  - lib/ksql/collection.rb
80
71
  - lib/ksql/configuration.rb
@@ -85,7 +76,7 @@ files:
85
76
  - lib/ksql/handlers/collection.rb
86
77
  - lib/ksql/handlers/raw.rb
87
78
  - lib/ksql/handlers/stream.rb
88
- - lib/ksql/handlers/typed_row.rb
79
+ - lib/ksql/handlers/typed_list.rb
89
80
  - lib/ksql/stream.rb
90
81
  - lib/ksql/version.rb
91
82
  - sig/ksql.rbs
@@ -107,9 +98,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
98
  version: 2.6.0
108
99
  required_rubygems_version: !ruby/object:Gem::Requirement
109
100
  requirements:
110
- - - ">"
101
+ - - ">="
111
102
  - !ruby/object:Gem::Version
112
- version: 1.3.1
103
+ version: '0'
113
104
  requirements: []
114
105
  rubygems_version: 3.2.22
115
106
  signing_key: