ratalada 3.0.0 → 3.1.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: 8d0e58c60b99a4b05777a6089c484f2104f85924694cfe0b5c0ef543a03634c7
4
- data.tar.gz: d04a10b62a3f33a00489234bbb0db780517a54c7569c83dfd098cee69a3b2f5f
3
+ metadata.gz: '079378d0ea4867145471fa730a8d2eb6ec20513d50e7bfcb52b643cd99bbf6e2'
4
+ data.tar.gz: 228276a9a88b32c152a4e84eb12f267f62b8cde567d7d9dab9fae4734e207ab9
5
5
  SHA512:
6
- metadata.gz: 616cb51549da081369ce6df606e8c9188900b20fc7dc5344b045eaf8ab0618edc8f1cba92fd21be24c59cae0370b2fdfe6729e56e1bf93562b118ebd2f75f4e4
7
- data.tar.gz: f834abb138626a902d8c4947183bca135d0ddf6ab9c8ed92a68b6ba08cc45666edb5f9f55611b50f365e4adbb23c20d621c8fdab2a532a1721c0d0e06e0642e3
6
+ metadata.gz: 5fa8af50cdf2da52fcc5e35d4a8f9acdd97307a6b1c5a7afd09d2971889331ec7af9f16a9472991db768fc71bb195174bf7c77e45fec50dded0b7696eef37c03
7
+ data.tar.gz: 939a4d0b6d7f9b1434561607ba7d02e44ab93a471abb8d7565e223a2b103434177648d648901fa65a75b001ced4a926aef14f95478cffeb1c1c1c885dbcfbb84
data/README.md CHANGED
@@ -253,6 +253,11 @@ gem kit changelog --write --gem ratalada-roda
253
253
  gem kit release --gem ratalada-roda # gate, build, push, tag
254
254
  ```
255
255
 
256
+ ## Why
257
+
258
+ Spurred on by things like [this post](https://blainsmith.com/articles/just-fucking-use-go/), and just how easy it is to create servers with [hono](https://hono.dev/) or agents with [volt](https://github.com/voltagent/voltagent), which makes me irrationally angry that ruby hasn't more libraries like this considering it's WELL beyond javascript in it's flexibility as a language.
259
+ [This post is great](https://www.toptal.com/developers/ruby/api-with-sinatra-and-sequel-ruby-tutorial), but it shuold be even simpler.
260
+
256
261
  ## License
257
262
 
258
263
  [MIT](LICENSE)
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "async/http/server"
4
+ require "async/http/endpoint"
5
+ require "protocol/rack/adapter"
6
+ require_relative "../ratalada"
7
+
8
+ module Ratalada
9
+ module Backends
10
+ # Falcon without falcon: one Async::HTTP::Server in this process, no
11
+ # container, no supervision, no restarts. Use ratalada/falcon when you
12
+ # want those; this is the fiber-based server on its own.
13
+ module Async
14
+ module_function
15
+
16
+ def run(app, host:, port:, count: 1)
17
+ if count > 1
18
+ warn "ratalada: async backend ignores count: (single process — use ratalada/falcon)"
19
+ end
20
+
21
+ endpoint = ::Async::HTTP::Endpoint.parse("http://#{host}:#{port}")
22
+ server = ::Async::HTTP::Server.new(::Protocol::Rack::Adapter.new(app), endpoint)
23
+
24
+ warn "ratalada: async listening on http://#{host}:#{port}"
25
+ # #run wraps itself in Async{}, which outside a reactor starts one and
26
+ # blocks until the accept loop ends.
27
+ server.run
28
+ rescue Interrupt
29
+ # clean shutdown
30
+ end
31
+ end
32
+ end
33
+
34
+ config.backend = Backends::Async
35
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ratalada
4
- VERSION = "3.0.0"
4
+ VERSION = "3.1.0"
5
5
  end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rackup/handler/webrick"
4
+ require_relative "../ratalada"
5
+
6
+ module Ratalada
7
+ module Backends
8
+ # Stdlib WEBrick via rackup's handler, which already does the rack env
9
+ # translation. Single process, one thread per connection — fine for
10
+ # development and tests, not what you ship.
11
+ module Webrick
12
+ module_function
13
+
14
+ def run(app, host:, port:, count: 1)
15
+ if count > 1
16
+ warn "ratalada: webrick backend ignores count: (single process)"
17
+ end
18
+
19
+ warn "ratalada: webrick listening on http://#{host}:#{port}"
20
+ ::Rackup::Handler::WEBrick.run(app, Host: host, Port: port)
21
+ rescue Interrupt
22
+ ::Rackup::Handler::WEBrick.shutdown
23
+ end
24
+ end
25
+ end
26
+
27
+ config.backend = Backends::Webrick
28
+ end
data/lib/ratalada.rb CHANGED
@@ -18,8 +18,10 @@ module Ratalada
18
18
  super(msg || <<~MSG)
19
19
  No server backend selected. Require one before calling Server.run:
20
20
 
21
- require "ratalada/puma" # or
22
- require "ratalada/falcon"
21
+ require "ratalada/puma" # or
22
+ require "ratalada/falcon" # or
23
+ require "ratalada/async" # or
24
+ require "ratalada/webrick"
23
25
  MSG
24
26
  end
25
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratalada
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K
@@ -107,6 +107,20 @@ dependencies:
107
107
  - - ">="
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: webrick
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
110
124
  - !ruby/object:Gem::Dependency
111
125
  name: lefthook
112
126
  requirement: !ruby/object:Gem::Requirement
@@ -135,10 +149,12 @@ files:
135
149
  - README.md
136
150
  - exe/ratalada
137
151
  - lib/ratalada.rb
152
+ - lib/ratalada/async.rb
138
153
  - lib/ratalada/builder.rb
139
154
  - lib/ratalada/falcon.rb
140
155
  - lib/ratalada/puma.rb
141
156
  - lib/ratalada/version.rb
157
+ - lib/ratalada/webrick.rb
142
158
  homepage: https://github.com/n-at-han-k/ratalada
143
159
  licenses:
144
160
  - MIT