nonnative 3.14.0 → 3.15.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 802f0ee020ba8e7c6cef867895d30c6491ace313fec8103aa6b99726c8402666
4
- data.tar.gz: 70d522685a3c9cfbc872ee36549d9ba8274be60138a79db68e64c83115fd7cb5
3
+ metadata.gz: 8c6665f1bde87f38b1ba0622168efd569d1cce78df5773597984ab3eb07e07e6
4
+ data.tar.gz: 5662743abeb5f331675ef634754c024fed13f876664d5e0beccea21199c47f9a
5
5
  SHA512:
6
- metadata.gz: a0b3e8502437cfd6d3a556a8a6f10901a2a89d85a4689fbad3c68d6819e03b4cccf5a51de3cfd66b86827d66f768891f68ee41c91b3ea504345c7f25d22178c8
7
- data.tar.gz: b16ef6cfe6099e9a62be954178c71a743fb297ece661be2651239c8501707af30e1609e58abfe99bc58d007777a45c99505eb374484c0ba9788e886d0b876e42
6
+ metadata.gz: 1ec6d29ca79065600e123c9ec4e78d3d0b8ca76f06538b88c21b771f7be3ffce428f77949c80da574f7420826385e637de94f164711be82a5c7bc664a8ca9e41
7
+ data.tar.gz: 0aba7bdf975ef0f28ae9eb5f14ab4a78d8cf160ac09e63ebaff38d8edddbec8bb3fb94855dec864f18972771ad97076bcb0cfae2e5ad3713e6e0f87e65c38de6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nonnative (3.14.0)
4
+ nonnative (3.15.0)
5
5
  concurrent-ruby (>= 1, < 2)
6
6
  config (>= 5, < 6)
7
7
  cucumber (>= 7, < 12)
data/README.md CHANGED
@@ -410,7 +410,7 @@ Define your server:
410
410
  ```ruby
411
411
  module Nonnative
412
412
  module Features
413
- class Hello < Sinatra::Application
413
+ class HelloService < Nonnative::HTTPService
414
414
  get '/hello' do
415
415
  'Hello World!'
416
416
  end
@@ -418,7 +418,7 @@ module Nonnative
418
418
 
419
419
  class HTTPServer < Nonnative::HTTPServer
420
420
  def initialize(service)
421
- super(Sinatra.new(Hello), service)
421
+ super(HelloService.new, service)
422
422
  end
423
423
  end
424
424
  end
@@ -543,7 +543,7 @@ end
543
543
 
544
544
  Define your server:
545
545
 
546
- Assume the gRPC service base class and response types below come from your generated gRPC stubs.
546
+ Assume the gRPC service type and response types below come from your generated gRPC stubs.
547
547
 
548
548
  ```ruby
549
549
  module Nonnative
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- # Base class for all Nonnative errors.
4
+ # Parent error for all Nonnative errors.
5
5
  #
6
6
  # Catch this error type if you want to handle any exception raised by this gem.
7
7
  #
@@ -7,7 +7,7 @@
7
7
  #
8
8
  # This file defines two classes:
9
9
  #
10
- # - {Nonnative::HTTPProxy}: a Sinatra application that implements the proxying behavior.
10
+ # - {Nonnative::HTTPProxy}: an HTTP service that implements the proxying behavior.
11
11
  # - {Nonnative::HTTPProxyServer}: a {Nonnative::HTTPServer} wrapper that runs the proxy app under Puma.
12
12
  #
13
13
  # Notes:
@@ -17,12 +17,12 @@
17
17
  # @see Nonnative::HTTPServer
18
18
  # @see Nonnative::Server
19
19
  module Nonnative
20
- # Sinatra application implementing a simple forward proxy.
20
+ # HTTP service implementing a simple forward proxy.
21
21
  #
22
- # The upstream host is configured via Sinatra settings (see {Nonnative::HTTPProxyServer}).
22
+ # The upstream host is configured via service settings (see {Nonnative::HTTPProxyServer}).
23
23
  #
24
24
  # Supported HTTP verbs: GET, POST, PUT, PATCH, DELETE.
25
- class HTTPProxy < Sinatra::Application
25
+ class HTTPProxy < Nonnative::HTTPService
26
26
  NON_FORWARDABLE_HEADERS = %w[
27
27
  Host
28
28
  Accept-Encoding
@@ -135,13 +135,11 @@ module Nonnative
135
135
  # @param host [String] upstream host to proxy to (HTTPS)
136
136
  # @param service [Nonnative::ConfigurationServer] server configuration
137
137
  def initialize(host, service)
138
- app = Sinatra.new(Nonnative::HTTPProxy) do
139
- configure do
140
- set :host, host
141
- end
138
+ http_service = Class.new(Nonnative::HTTPProxy) do
139
+ set :host, host
142
140
  end
143
141
 
144
- super(app, service)
142
+ super(http_service.new, service)
145
143
  end
146
144
  end
147
145
  end
@@ -3,19 +3,19 @@
3
3
  module Nonnative
4
4
  # Puma-based HTTP server runner.
5
5
  #
6
- # This is a convenience server implementation for running a Rack/Sinatra application in-process
7
- # under Nonnative's server lifecycle. It binds to the configured server `host` and first `ports` entry.
6
+ # This is a convenience server implementation for running an HTTP service in-process under
7
+ # Nonnative's server lifecycle. It binds to the configured server `host` and first `ports` entry.
8
8
  #
9
9
  # The server is started and stopped by {Nonnative::Server} via {#perform_start} / {#perform_stop}.
10
10
  #
11
- # @example Running a Sinatra app
11
+ # @example Running an HTTP service
12
+ # class HelloHTTPService < Nonnative::HTTPService
13
+ # get('/hello') { 'Hello World!' }
14
+ # end
15
+ #
12
16
  # class HelloHTTPServer < Nonnative::HTTPServer
13
17
  # def initialize(service)
14
- # app = Sinatra.new do
15
- # get('/hello') { 'Hello World!' }
16
- # end
17
- #
18
- # super(app, service)
18
+ # super(HelloHTTPService.new, service)
19
19
  # end
20
20
  # end
21
21
  #
@@ -34,18 +34,18 @@ module Nonnative
34
34
  #
35
35
  # @see Nonnative::Server
36
36
  class HTTPServer < Nonnative::Server
37
- # Creates a Puma server for the given Rack app and runner configuration.
37
+ # Creates a Puma server for the given HTTP service and runner configuration.
38
38
  #
39
- # @param app [#call] a Rack-compatible application (e.g. Sinatra/Rack app)
39
+ # @param http_service [#call] an HTTP service instance
40
40
  # @param service [Nonnative::ConfigurationServer] server configuration
41
- def initialize(app, service)
41
+ def initialize(http_service, service)
42
42
  # Keep the log IO so the server lifecycle can release Puma's file handle on stop.
43
43
  @log = File.open(service.log, 'a')
44
44
  options = {
45
45
  log_writer: Puma::LogWriter.new(log, log),
46
46
  force_shutdown_after: service.timeout
47
47
  }
48
- @server = Puma::Server.new(app, Puma::Events.new, options)
48
+ @server = Puma::Server.new(http_service, Puma::Events.new, options)
49
49
 
50
50
  super(service)
51
51
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nonnative
4
+ # HTTP service run by {Nonnative::HTTPServer}.
5
+ #
6
+ # Subclass this instead of `Sinatra::Application` when defining an in-process HTTP server for
7
+ # Nonnative. {Nonnative::HTTPServer} accepts a service instance and runs it under Puma.
8
+ class HTTPService < Sinatra::Application
9
+ end
10
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nonnative
4
- # Base class for proxy implementations.
4
+ # Parent type for proxy implementations.
5
5
  #
6
6
  # A proxy is responsible for interposing behavior between a client and a target service.
7
7
  # Runtime services create a proxy instance via {Nonnative::ProxyFactory} based on `service.proxy.kind`.
@@ -4,5 +4,5 @@ module Nonnative
4
4
  # The current gem version.
5
5
  #
6
6
  # @return [String]
7
- VERSION = '3.14.0'
7
+ VERSION = '3.15.0'
8
8
  end
data/lib/nonnative.rb CHANGED
@@ -91,6 +91,7 @@ require 'nonnative/tcp_probe'
91
91
  require 'nonnative/http_probe'
92
92
  require 'nonnative/grpc_health'
93
93
  require 'nonnative/grpc_probe'
94
+ require 'nonnative/http_service'
94
95
  require 'nonnative/http_server'
95
96
  require 'nonnative/http_proxy_server'
96
97
  require 'nonnative/grpc_server'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nonnative
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.14.0
4
+ version: 3.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alejandro Falkowski
@@ -310,6 +310,7 @@ files:
310
310
  - lib/nonnative/http_probe.rb
311
311
  - lib/nonnative/http_proxy_server.rb
312
312
  - lib/nonnative/http_server.rb
313
+ - lib/nonnative/http_service.rb
313
314
  - lib/nonnative/invalid_data_socket_pair.rb
314
315
  - lib/nonnative/no_proxy.rb
315
316
  - lib/nonnative/not_found_error.rb