itsi 0.1.11 → 0.1.12

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.
Files changed (293) hide show
  1. checksums.yaml +4 -4
  2. data/Cargo.lock +1535 -45
  3. data/{sandbox/itsi_itsi_file/Itsi.rb → Itsi.rb} +19 -13
  4. data/Rakefile +8 -7
  5. data/crates/itsi_error/src/lib.rs +9 -0
  6. data/crates/itsi_rb_helpers/Cargo.toml +1 -0
  7. data/crates/itsi_rb_helpers/src/heap_value.rs +18 -0
  8. data/crates/itsi_rb_helpers/src/lib.rs +34 -7
  9. data/crates/itsi_server/Cargo.toml +69 -30
  10. data/crates/itsi_server/src/lib.rs +79 -147
  11. data/crates/itsi_server/src/{body_proxy → ruby_types/itsi_body_proxy}/big_bytes.rs +10 -5
  12. data/crates/itsi_server/src/{body_proxy/itsi_body_proxy.rs → ruby_types/itsi_body_proxy/mod.rs} +22 -3
  13. data/crates/itsi_server/src/ruby_types/itsi_grpc_request.rs +147 -0
  14. data/crates/itsi_server/src/ruby_types/itsi_grpc_response.rs +19 -0
  15. data/crates/itsi_server/src/ruby_types/itsi_grpc_stream/mod.rs +216 -0
  16. data/{gems/server/ext/itsi_server/src/request/itsi_request.rs → crates/itsi_server/src/ruby_types/itsi_http_request.rs} +101 -117
  17. data/crates/itsi_server/src/{response/itsi_response.rs → ruby_types/itsi_http_response.rs} +72 -41
  18. data/crates/itsi_server/src/ruby_types/itsi_server/file_watcher.rs +225 -0
  19. data/crates/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +355 -0
  20. data/crates/itsi_server/src/ruby_types/itsi_server.rs +82 -0
  21. data/crates/itsi_server/src/ruby_types/mod.rs +55 -0
  22. data/crates/itsi_server/src/server/bind.rs +13 -5
  23. data/crates/itsi_server/src/server/byte_frame.rs +32 -0
  24. data/crates/itsi_server/src/server/cache_store.rs +74 -0
  25. data/crates/itsi_server/src/server/itsi_service.rs +172 -0
  26. data/crates/itsi_server/src/server/lifecycle_event.rs +3 -0
  27. data/crates/itsi_server/src/server/listener.rs +102 -2
  28. data/crates/itsi_server/src/server/middleware_stack/middleware.rs +153 -0
  29. data/crates/itsi_server/src/server/middleware_stack/middlewares/allow_list.rs +47 -0
  30. data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_api_key.rs +58 -0
  31. data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_basic.rs +82 -0
  32. data/crates/itsi_server/src/server/middleware_stack/middlewares/auth_jwt.rs +321 -0
  33. data/crates/itsi_server/src/server/middleware_stack/middlewares/cache_control.rs +139 -0
  34. data/crates/itsi_server/src/server/middleware_stack/middlewares/compression.rs +300 -0
  35. data/crates/itsi_server/src/server/middleware_stack/middlewares/cors.rs +287 -0
  36. data/crates/itsi_server/src/server/middleware_stack/middlewares/deny_list.rs +48 -0
  37. data/crates/itsi_server/src/server/middleware_stack/middlewares/error_response.rs +127 -0
  38. data/crates/itsi_server/src/server/middleware_stack/middlewares/etag.rs +191 -0
  39. data/crates/itsi_server/src/server/middleware_stack/middlewares/grpc_service.rs +72 -0
  40. data/crates/itsi_server/src/server/middleware_stack/middlewares/header_interpretation.rs +85 -0
  41. data/crates/itsi_server/src/server/middleware_stack/middlewares/intrusion_protection.rs +195 -0
  42. data/crates/itsi_server/src/server/middleware_stack/middlewares/log_requests.rs +82 -0
  43. data/crates/itsi_server/src/server/middleware_stack/middlewares/mod.rs +82 -0
  44. data/crates/itsi_server/src/server/middleware_stack/middlewares/proxy.rs +216 -0
  45. data/crates/itsi_server/src/server/middleware_stack/middlewares/rate_limit.rs +124 -0
  46. data/crates/itsi_server/src/server/middleware_stack/middlewares/redirect.rs +76 -0
  47. data/crates/itsi_server/src/server/middleware_stack/middlewares/request_headers.rs +43 -0
  48. data/crates/itsi_server/src/server/middleware_stack/middlewares/response_headers.rs +34 -0
  49. data/crates/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs +93 -0
  50. data/crates/itsi_server/src/server/middleware_stack/middlewares/static_assets.rs +162 -0
  51. data/crates/itsi_server/src/server/middleware_stack/middlewares/string_rewrite.rs +158 -0
  52. data/crates/itsi_server/src/server/middleware_stack/middlewares/token_source.rs +12 -0
  53. data/crates/itsi_server/src/server/middleware_stack/mod.rs +315 -0
  54. data/crates/itsi_server/src/server/mod.rs +8 -1
  55. data/crates/itsi_server/src/server/process_worker.rs +38 -12
  56. data/crates/itsi_server/src/server/rate_limiter.rs +565 -0
  57. data/crates/itsi_server/src/server/request_job.rs +11 -0
  58. data/crates/itsi_server/src/server/serve_strategy/cluster_mode.rs +119 -42
  59. data/crates/itsi_server/src/server/serve_strategy/mod.rs +9 -6
  60. data/crates/itsi_server/src/server/serve_strategy/single_mode.rs +256 -111
  61. data/crates/itsi_server/src/server/signal.rs +19 -0
  62. data/crates/itsi_server/src/server/static_file_server.rs +984 -0
  63. data/crates/itsi_server/src/server/thread_worker.rs +139 -94
  64. data/crates/itsi_server/src/server/types.rs +43 -0
  65. data/crates/itsi_server/test.md +14 -0
  66. data/crates/itsi_tracing/Cargo.toml +1 -0
  67. data/crates/itsi_tracing/src/lib.rs +216 -45
  68. data/docs/.gitignore +7 -0
  69. data/docs/.gitpod.yml +15 -0
  70. data/docs/Itsi.rb +17 -0
  71. data/docs/content/_index.md +17 -0
  72. data/docs/content/about.md +6 -0
  73. data/docs/content/docs/_index.md +18 -0
  74. data/docs/content/docs/first-page.md +9 -0
  75. data/docs/content/docs/folder/_index.md +10 -0
  76. data/docs/content/docs/folder/leaf.md +7 -0
  77. data/docs/go.mod +5 -0
  78. data/docs/go.sum +2 -0
  79. data/docs/hugo.yaml +77 -0
  80. data/examples/static_assets_example.rb +83 -0
  81. data/gems/_index.md +18 -0
  82. data/gems/scheduler/CODE_OF_CONDUCT.md +7 -0
  83. data/gems/scheduler/Cargo.lock +75 -14
  84. data/gems/scheduler/README.md +5 -0
  85. data/gems/scheduler/_index.md +7 -0
  86. data/gems/scheduler/itsi-scheduler.gemspec +4 -1
  87. data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
  88. data/gems/scheduler/lib/itsi/scheduler.rb +2 -2
  89. data/gems/scheduler/test/test_file_io.rb +0 -1
  90. data/gems/scheduler/test/test_itsi_scheduler.rb +1 -1
  91. data/gems/server/CHANGELOG.md +5 -0
  92. data/gems/server/CODE_OF_CONDUCT.md +7 -0
  93. data/gems/server/Cargo.lock +1536 -45
  94. data/gems/server/README.md +4 -0
  95. data/gems/server/_index.md +6 -0
  96. data/gems/server/exe/itsi +33 -74
  97. data/gems/server/itsi-server.gemspec +3 -2
  98. data/gems/server/lib/itsi/{request.rb → http_request.rb} +29 -5
  99. data/gems/server/lib/itsi/http_response.rb +39 -0
  100. data/gems/server/lib/itsi/server/Itsi.rb +11 -19
  101. data/gems/server/lib/itsi/server/config/dsl.rb +506 -0
  102. data/gems/server/lib/itsi/server/config.rb +103 -8
  103. data/gems/server/lib/itsi/server/default_app/default_app.rb +38 -0
  104. data/gems/server/lib/itsi/server/grpc_interface.rb +213 -0
  105. data/gems/server/lib/itsi/server/rack/handler/itsi.rb +8 -17
  106. data/gems/server/lib/itsi/server/rack_interface.rb +23 -4
  107. data/gems/server/lib/itsi/server/scheduler_interface.rb +1 -1
  108. data/gems/server/lib/itsi/server/scheduler_mode.rb +4 -0
  109. data/gems/server/lib/itsi/server/signal_trap.rb +7 -1
  110. data/gems/server/lib/itsi/server/version.rb +1 -1
  111. data/gems/server/lib/itsi/server.rb +74 -63
  112. data/gems/server/lib/itsi/standard_headers.rb +86 -0
  113. data/gems/server/test/helpers/test_helper.rb +12 -12
  114. data/gems/server/test/test_itsi_server.rb +2 -2
  115. data/lib/itsi/version.rb +1 -1
  116. data/sandbox/itsi_file/Gemfile +11 -0
  117. data/sandbox/itsi_file/Gemfile.lock +69 -0
  118. data/sandbox/itsi_file/Itsi.rb +276 -0
  119. data/sandbox/itsi_file/error.html +2 -0
  120. data/sandbox/itsi_file/organisations_controller.rb +20 -0
  121. data/sandbox/itsi_file/public/assets/image.png +0 -0
  122. data/sandbox/itsi_file/public/assets/index.html +1 -0
  123. data/sandbox/itsi_sandbox_hanami/Gemfile.lock +2 -2
  124. data/sandbox/itsi_sandbox_rack/Gemfile.lock +2 -2
  125. data/sandbox/itsi_sandbox_rack/config.ru +2 -15
  126. data/sandbox/itsi_sandbox_rails/.dockerignore +2 -5
  127. data/sandbox/itsi_sandbox_rails/.github/workflows/ci.yml +1 -1
  128. data/sandbox/itsi_sandbox_rails/.gitignore +2 -1
  129. data/sandbox/itsi_sandbox_rails/Dockerfile +6 -9
  130. data/sandbox/itsi_sandbox_rails/Gemfile +16 -22
  131. data/sandbox/itsi_sandbox_rails/Gemfile.lock +100 -225
  132. data/sandbox/itsi_sandbox_rails/app/assets/config/manifest.js +4 -0
  133. data/sandbox/itsi_sandbox_rails/app/assets/stylesheets/application.css +11 -6
  134. data/sandbox/itsi_sandbox_rails/app/channels/application_cable/channel.rb +4 -0
  135. data/sandbox/itsi_sandbox_rails/app/channels/application_cable/connection.rb +4 -0
  136. data/sandbox/itsi_sandbox_rails/app/controllers/live_controller.rb +7 -8
  137. data/sandbox/itsi_sandbox_rails/app/controllers/uploads_controller.rb +0 -3
  138. data/sandbox/itsi_sandbox_rails/app/views/layouts/application.html.erb +2 -7
  139. data/sandbox/itsi_sandbox_rails/bin/docker-entrypoint +3 -4
  140. data/sandbox/itsi_sandbox_rails/bin/setup +8 -5
  141. data/sandbox/itsi_sandbox_rails/config/application.rb +1 -35
  142. data/sandbox/itsi_sandbox_rails/config/cable.yml +3 -10
  143. data/sandbox/itsi_sandbox_rails/config/credentials.yml.enc +1 -1
  144. data/sandbox/itsi_sandbox_rails/config/database.yml +9 -19
  145. data/sandbox/itsi_sandbox_rails/config/environment.rb +1 -1
  146. data/sandbox/itsi_sandbox_rails/config/environments/development.rb +21 -12
  147. data/sandbox/itsi_sandbox_rails/config/environments/production.rb +49 -34
  148. data/sandbox/itsi_sandbox_rails/config/environments/test.rb +19 -5
  149. data/sandbox/itsi_sandbox_rails/config/initializers/assets.rb +5 -0
  150. data/sandbox/itsi_sandbox_rails/config/initializers/filter_parameter_logging.rb +1 -1
  151. data/sandbox/itsi_sandbox_rails/config/initializers/permissions_policy.rb +13 -0
  152. data/sandbox/itsi_sandbox_rails/config/puma.rb +2 -9
  153. data/sandbox/itsi_sandbox_rails/config.ru +0 -1
  154. data/sandbox/itsi_sandbox_rails/db/migrate/20250301041554_create_posts.rb +1 -1
  155. data/sandbox/itsi_sandbox_rails/db/schema.rb +2 -2
  156. data/sandbox/itsi_sandbox_rails/lib/assets/.keep +0 -0
  157. data/sandbox/itsi_sandbox_rails/public/404.html +66 -113
  158. data/sandbox/itsi_sandbox_rails/public/406-unsupported-browser.html +65 -113
  159. data/sandbox/itsi_sandbox_rails/public/422.html +66 -113
  160. data/sandbox/itsi_sandbox_rails/public/500.html +65 -113
  161. data/sandbox/itsi_sandbox_rails/public/icon.png +0 -0
  162. data/sandbox/itsi_sandbox_rails/public/icon.svg +2 -2
  163. data/sandbox/itsi_sandbox_rails/test/channels/application_cable/connection_test.rb +13 -0
  164. data/sandbox/itsi_sandbox_roda/Gemfile.lock +3 -10
  165. data/tasks.txt +72 -35
  166. metadata +89 -139
  167. data/crates/itsi_server/src/body_proxy/mod.rs +0 -2
  168. data/crates/itsi_server/src/request/itsi_request.rs +0 -298
  169. data/crates/itsi_server/src/request/mod.rs +0 -1
  170. data/crates/itsi_server/src/response/mod.rs +0 -1
  171. data/crates/itsi_server/src/server/itsi_server.rs +0 -288
  172. data/gems/scheduler/ext/itsi_error/Cargo.lock +0 -368
  173. data/gems/scheduler/ext/itsi_error/Cargo.toml +0 -11
  174. data/gems/scheduler/ext/itsi_error/src/from.rs +0 -68
  175. data/gems/scheduler/ext/itsi_error/src/lib.rs +0 -24
  176. data/gems/scheduler/ext/itsi_instrument_entry/Cargo.toml +0 -15
  177. data/gems/scheduler/ext/itsi_instrument_entry/src/lib.rs +0 -31
  178. data/gems/scheduler/ext/itsi_rb_helpers/Cargo.lock +0 -355
  179. data/gems/scheduler/ext/itsi_rb_helpers/Cargo.toml +0 -10
  180. data/gems/scheduler/ext/itsi_rb_helpers/src/heap_value.rs +0 -121
  181. data/gems/scheduler/ext/itsi_rb_helpers/src/lib.rs +0 -201
  182. data/gems/scheduler/ext/itsi_scheduler/Cargo.toml +0 -24
  183. data/gems/scheduler/ext/itsi_scheduler/extconf.rb +0 -6
  184. data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler/io_helpers.rs +0 -56
  185. data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler/io_waiter.rs +0 -44
  186. data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler/timer.rs +0 -44
  187. data/gems/scheduler/ext/itsi_scheduler/src/itsi_scheduler.rs +0 -308
  188. data/gems/scheduler/ext/itsi_scheduler/src/lib.rs +0 -38
  189. data/gems/scheduler/ext/itsi_server/Cargo.lock +0 -2956
  190. data/gems/scheduler/ext/itsi_server/Cargo.toml +0 -50
  191. data/gems/scheduler/ext/itsi_server/extconf.rb +0 -6
  192. data/gems/scheduler/ext/itsi_server/src/body_proxy/big_bytes.rs +0 -104
  193. data/gems/scheduler/ext/itsi_server/src/body_proxy/itsi_body_proxy.rs +0 -122
  194. data/gems/scheduler/ext/itsi_server/src/body_proxy/mod.rs +0 -2
  195. data/gems/scheduler/ext/itsi_server/src/env.rs +0 -43
  196. data/gems/scheduler/ext/itsi_server/src/lib.rs +0 -180
  197. data/gems/scheduler/ext/itsi_server/src/request/itsi_request.rs +0 -298
  198. data/gems/scheduler/ext/itsi_server/src/request/mod.rs +0 -1
  199. data/gems/scheduler/ext/itsi_server/src/response/itsi_response.rs +0 -357
  200. data/gems/scheduler/ext/itsi_server/src/response/mod.rs +0 -1
  201. data/gems/scheduler/ext/itsi_server/src/server/bind.rs +0 -174
  202. data/gems/scheduler/ext/itsi_server/src/server/bind_protocol.rs +0 -37
  203. data/gems/scheduler/ext/itsi_server/src/server/io_stream.rs +0 -104
  204. data/gems/scheduler/ext/itsi_server/src/server/itsi_server.rs +0 -288
  205. data/gems/scheduler/ext/itsi_server/src/server/lifecycle_event.rs +0 -9
  206. data/gems/scheduler/ext/itsi_server/src/server/listener.rs +0 -318
  207. data/gems/scheduler/ext/itsi_server/src/server/mod.rs +0 -11
  208. data/gems/scheduler/ext/itsi_server/src/server/process_worker.rs +0 -203
  209. data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/cluster_mode.rs +0 -260
  210. data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/mod.rs +0 -27
  211. data/gems/scheduler/ext/itsi_server/src/server/serve_strategy/single_mode.rs +0 -276
  212. data/gems/scheduler/ext/itsi_server/src/server/signal.rs +0 -74
  213. data/gems/scheduler/ext/itsi_server/src/server/thread_worker.rs +0 -399
  214. data/gems/scheduler/ext/itsi_server/src/server/tls/locked_dir_cache.rs +0 -132
  215. data/gems/scheduler/ext/itsi_server/src/server/tls.rs +0 -265
  216. data/gems/scheduler/ext/itsi_tracing/Cargo.lock +0 -274
  217. data/gems/scheduler/ext/itsi_tracing/Cargo.toml +0 -16
  218. data/gems/scheduler/ext/itsi_tracing/src/lib.rs +0 -58
  219. data/gems/server/ext/itsi_error/Cargo.lock +0 -368
  220. data/gems/server/ext/itsi_error/Cargo.toml +0 -11
  221. data/gems/server/ext/itsi_error/src/from.rs +0 -68
  222. data/gems/server/ext/itsi_error/src/lib.rs +0 -24
  223. data/gems/server/ext/itsi_instrument_entry/Cargo.toml +0 -15
  224. data/gems/server/ext/itsi_instrument_entry/src/lib.rs +0 -31
  225. data/gems/server/ext/itsi_rb_helpers/Cargo.lock +0 -355
  226. data/gems/server/ext/itsi_rb_helpers/Cargo.toml +0 -10
  227. data/gems/server/ext/itsi_rb_helpers/src/heap_value.rs +0 -121
  228. data/gems/server/ext/itsi_rb_helpers/src/lib.rs +0 -201
  229. data/gems/server/ext/itsi_scheduler/Cargo.toml +0 -24
  230. data/gems/server/ext/itsi_scheduler/extconf.rb +0 -6
  231. data/gems/server/ext/itsi_scheduler/src/itsi_scheduler/io_helpers.rs +0 -56
  232. data/gems/server/ext/itsi_scheduler/src/itsi_scheduler/io_waiter.rs +0 -44
  233. data/gems/server/ext/itsi_scheduler/src/itsi_scheduler/timer.rs +0 -44
  234. data/gems/server/ext/itsi_scheduler/src/itsi_scheduler.rs +0 -308
  235. data/gems/server/ext/itsi_scheduler/src/lib.rs +0 -38
  236. data/gems/server/ext/itsi_server/Cargo.lock +0 -2956
  237. data/gems/server/ext/itsi_server/Cargo.toml +0 -50
  238. data/gems/server/ext/itsi_server/extconf.rb +0 -6
  239. data/gems/server/ext/itsi_server/src/body_proxy/big_bytes.rs +0 -104
  240. data/gems/server/ext/itsi_server/src/body_proxy/itsi_body_proxy.rs +0 -122
  241. data/gems/server/ext/itsi_server/src/body_proxy/mod.rs +0 -2
  242. data/gems/server/ext/itsi_server/src/env.rs +0 -43
  243. data/gems/server/ext/itsi_server/src/lib.rs +0 -180
  244. data/gems/server/ext/itsi_server/src/request/mod.rs +0 -1
  245. data/gems/server/ext/itsi_server/src/response/itsi_response.rs +0 -357
  246. data/gems/server/ext/itsi_server/src/response/mod.rs +0 -1
  247. data/gems/server/ext/itsi_server/src/server/bind.rs +0 -174
  248. data/gems/server/ext/itsi_server/src/server/bind_protocol.rs +0 -37
  249. data/gems/server/ext/itsi_server/src/server/io_stream.rs +0 -104
  250. data/gems/server/ext/itsi_server/src/server/itsi_server.rs +0 -288
  251. data/gems/server/ext/itsi_server/src/server/lifecycle_event.rs +0 -9
  252. data/gems/server/ext/itsi_server/src/server/listener.rs +0 -318
  253. data/gems/server/ext/itsi_server/src/server/mod.rs +0 -11
  254. data/gems/server/ext/itsi_server/src/server/process_worker.rs +0 -203
  255. data/gems/server/ext/itsi_server/src/server/serve_strategy/cluster_mode.rs +0 -260
  256. data/gems/server/ext/itsi_server/src/server/serve_strategy/mod.rs +0 -27
  257. data/gems/server/ext/itsi_server/src/server/serve_strategy/single_mode.rs +0 -276
  258. data/gems/server/ext/itsi_server/src/server/signal.rs +0 -74
  259. data/gems/server/ext/itsi_server/src/server/thread_worker.rs +0 -399
  260. data/gems/server/ext/itsi_server/src/server/tls/locked_dir_cache.rs +0 -132
  261. data/gems/server/ext/itsi_server/src/server/tls.rs +0 -265
  262. data/gems/server/ext/itsi_tracing/Cargo.lock +0 -274
  263. data/gems/server/ext/itsi_tracing/Cargo.toml +0 -16
  264. data/gems/server/ext/itsi_tracing/src/lib.rs +0 -58
  265. data/gems/server/lib/itsi/server/options_dsl.rb +0 -401
  266. data/gems/server/lib/itsi/stream_io.rb +0 -38
  267. data/location_dsl.rb +0 -381
  268. data/sandbox/itsi_sandbox_rails/.kamal/hooks/docker-setup.sample +0 -3
  269. data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-app-boot.sample +0 -3
  270. data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-deploy.sample +0 -14
  271. data/sandbox/itsi_sandbox_rails/.kamal/hooks/post-proxy-reboot.sample +0 -3
  272. data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-app-boot.sample +0 -3
  273. data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-build.sample +0 -51
  274. data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-connect.sample +0 -47
  275. data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-deploy.sample +0 -109
  276. data/sandbox/itsi_sandbox_rails/.kamal/hooks/pre-proxy-reboot.sample +0 -3
  277. data/sandbox/itsi_sandbox_rails/.kamal/secrets +0 -17
  278. data/sandbox/itsi_sandbox_rails/bin/dev +0 -2
  279. data/sandbox/itsi_sandbox_rails/bin/jobs +0 -6
  280. data/sandbox/itsi_sandbox_rails/bin/kamal +0 -27
  281. data/sandbox/itsi_sandbox_rails/bin/thrust +0 -5
  282. data/sandbox/itsi_sandbox_rails/config/cache.yml +0 -16
  283. data/sandbox/itsi_sandbox_rails/config/deploy.yml +0 -116
  284. data/sandbox/itsi_sandbox_rails/config/queue.yml +0 -18
  285. data/sandbox/itsi_sandbox_rails/config/recurring.yml +0 -10
  286. data/sandbox/itsi_sandbox_rails/db/cable_schema.rb +0 -11
  287. data/sandbox/itsi_sandbox_rails/db/cache_schema.rb +0 -14
  288. data/sandbox/itsi_sandbox_rails/db/queue_schema.rb +0 -129
  289. data/sandbox/itsi_sandbox_rails/public/400.html +0 -114
  290. data/sandbox/itsi_sandbox_rails/test/fixtures/posts.yml +0 -9
  291. data/sandbox/itsi_sandbox_rails/test/models/post_test.rb +0 -7
  292. /data/{sandbox/itsi_sandbox_rails/script/.keep → crates/_index.md} +0 -0
  293. /data/gems/server/lib/itsi/{index.html → server/default_app/index.html} +0 -0
@@ -1,3 +1,7 @@
1
+ ---
2
+ type: docs
3
+ ---
4
+
1
5
  # ItsiServer
2
6
 
3
7
  TODO: Delete this and the text below, and describe your gem
@@ -0,0 +1,6 @@
1
+ ---
2
+ title: Itsi Server
3
+ type: docs
4
+ ---
5
+
6
+ ## Foo
data/gems/server/exe/itsi CHANGED
@@ -1,33 +1,13 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
+ require "itsi/server"
4
5
  require "optparse"
5
6
 
6
- # Default options used when starting Osprey from the CLI using `osprey`
7
- DEFAULT_OPTIONS = {
8
- # Number of workers
9
- workers: 1,
10
- # Number of threads per worker
11
- threads: 1,
12
- # Graceful shutdown timeout
13
- shutdown_timeout: 5,
14
- # Binds
15
- binds: ["http://0.0.0.0:3000"],
16
- # Preload
17
- preload: true,
18
- # Rackup file
19
- rackup_file: "config.ru",
20
- # Scheduler class
21
- scheduler_class: nil,
22
- # Whether to stream the body or not
23
- stream_body: false,
24
- # Config file
25
- config_file: nil
26
- }
27
-
28
- options = DEFAULT_OPTIONS.to_a.select(&:last).to_h
29
-
30
- # Define the option parser
7
+ Itsi::Server::Config.save_argv!
8
+
9
+ options = {}
10
+
31
11
  OptionParser.new do |opts|
32
12
  opts.banner = "Usage: itsi [options]"
33
13
 
@@ -35,20 +15,25 @@ OptionParser.new do |opts|
35
15
  options[:config_file] = config_file
36
16
  end
37
17
 
38
- opts.on("-w", "--workers WORKERS", Integer, "Number of workers (default: #{options[:workers]})") do |w|
18
+ opts.on("-w", "--workers WORKERS", Integer, "Number of workers (default: #{Etc.nprocessors})") do |w|
39
19
  options[:workers] = w
40
20
  end
41
21
 
42
- opts.on("-t", "--threads THREADS", Integer, "Number of threads (default: #{options[:threads]})") do |t|
22
+ opts.on("-t", "--threads THREADS", Integer, "Number of threads (default: 1)") do |t|
43
23
  options[:threads] = t
44
24
  end
45
25
 
46
- opts.on("-r", "--rackup_file FILE", String, "Rackup file to use (default: #{options[:rackup_file]})") do |rf|
26
+ opts.on("-mtr", "--multithreaded-reactor true/false", String,
27
+ "Use a multithreaded reactor (default: true)") do |mtr|
28
+ options[:multithreaded_reactor] = mtr.to_s == "true"
29
+ end
30
+
31
+ opts.on("-r", "--rackup_file FILE", String, "Rackup file to use (default: config.ru)") do |rf|
47
32
  options[:rackup_file] = rf
48
33
  end
49
34
 
50
35
  opts.on("--worker-memory-limit MEMORY_LIMIT", Integer,
51
- "Memory limit for each worker (default: #{options[:worker_memory_limit] || "None"}). If this limit is breached the worker is gracefully restarted") do |ml|
36
+ "Memory limit for each worker (default: None). If this limit is breached the worker is gracefully restarted") do |ml|
52
37
  options[:worker_memory_limit] = ml
53
38
  end
54
39
 
@@ -74,8 +59,8 @@ OptionParser.new do |opts|
74
59
  end
75
60
 
76
61
  opts.on("-b", "--bind BIND", String,
77
- "Bind address (default: #{options[:binds].join(", ")}). You can specify this flag multiple times to bind to multiple addresses.") do |bind|
78
- options[:binds].pop if options[:binds].first.frozen?
62
+ "Bind address (default: http://0.0.0.0:3000). You can specify this flag multiple times to bind to multiple addresses.") do |bind|
63
+ options[:binds] ||= []
79
64
  options[:binds] << bind
80
65
  end
81
66
 
@@ -124,51 +109,25 @@ OptionParser.new do |opts|
124
109
  puts opts
125
110
  exit
126
111
  end
127
- end.parse!
128
112
 
129
- require "itsi/server/config"
130
- if ARGV.pop == "init"
131
- Itsi::Server::Config.write_default
132
- exit(0)
133
- # Add initialization code here
134
- end
113
+ opts.on("--reexec PARAMS", String, "Reexec the server with the given parameters") do |params|
114
+ options[:reexec] = params
115
+ end
135
116
 
136
- options = Itsi::Server::Config.load(options)
137
- loader = nil
138
-
139
- if options[:app] || File.exist?(options[:rackup_file])
140
- loader ||= lambda do
141
- require "rack"
142
- require_relative "../lib/itsi/server/scheduler_mode" if options[:scheduler_class]
143
- require "itsi/scheduler" if [true, "Itsi::Scheduler"].include?(options[:scheduler_class])
144
- require "itsi/server"
145
- return options[:app] if options[:app]
146
- Array(Rack::Builder.parse_file(options[:rackup_file])).first
147
- end
148
-
149
- if options[:preload] == true
150
- # If preload is true, we'll invoke our loader now, and just return a no-op proc
151
- # which returns the app as loader. We still need to optionally load the scheduler class and rack
152
- # in case the app has been provided directly in Itsi.rb instead of in config.ru
153
- require "rack"
154
- require_relative "../lib/itsi/server/scheduler_mode" if options[:scheduler_class]
155
- require "itsi/scheduler" if [true, "Itsi::Scheduler"].include?(options[:scheduler_class])
156
- loader = (options[:app] || loader[]).method(:itself).to_proc
157
- elsif options[:preload]
158
- # If a group name is given, we'll stick to just loading the gem group by the same name from the Gemfile.
159
- # But we'll fall through to the default delayed loader for the full app.
160
- require "bundler"
161
- Bundler.setup
162
- Bundler.require(options[:preload])
163
- nil
117
+ opts.on("--listeners LISTENERS", String, "Listeners for reexec") do |listeners|
118
+ options[:listeners] = listeners
164
119
  end
165
- end
120
+ end.parse!
166
121
 
167
- # Make sure Itsi is loaded, if not already loaded by the rack_app above.
168
- # Start the Itsi server
169
- require "itsi/server"
170
122
 
171
- Itsi::Server.start(
172
- loader: loader,
173
- **options.except(:preload, :rackup_file)
174
- )
123
+ case (command = ARGV.pop)
124
+ when "init"
125
+ Itsi::Server::Config.write_default
126
+ exit(0)
127
+ when "reload", "restart", "down", "up", "add_worker", "remove_worker", "status"
128
+ Itsi::Server.send(command)
129
+ when nil, "start", "serve"
130
+ Itsi::Server.start(options)
131
+ else
132
+ puts "Invalid command #{command}"
133
+ end
@@ -27,7 +27,9 @@ Gem::Specification.new do |spec|
27
27
  (f == gemspec) ||
28
28
  f.start_with?(*%w[bin/ test/ spec/ features/ .git appveyor Gemfile])
29
29
  end
30
- end
30
+ end + Dir["../../crates/**/*.{toml,rs,lock}"].map do |ext_file|
31
+ "ext/#{ext_file[%r{.*crates/(.*?)$}, 1]}"
32
+ end.compact
31
33
 
32
34
  spec.bindir = "exe"
33
35
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
@@ -38,7 +40,6 @@ Gem::Specification.new do |spec|
38
40
  # spec.add_dependency "example-gem", "~> 1.0"
39
41
  spec.add_dependency "rack", ">= 1.6"
40
42
  spec.add_dependency "rb_sys", "~> 0.9.91"
41
-
42
43
  # For more information and examples about making a new gem, check out our
43
44
  # guide at: https://bundler.io/guides/creating_gem.html
44
45
  end
@@ -4,9 +4,23 @@ require "stringio"
4
4
  require "socket"
5
5
 
6
6
  module Itsi
7
- class Request
7
+ class HttpRequest
8
8
  attr_accessor :hijacked
9
9
 
10
+ EMPTY_IO = StringIO.new("").freeze
11
+ RACK_HEADER_MAP = StandardHeaders::ALL.map do |header|
12
+ rack_form = if header == "content-type"
13
+ "CONTENT_TYPE"
14
+ elsif header == "content-length"
15
+ "CONTENT_LENGTH"
16
+ else
17
+ "HTTP_#{header.upcase.gsub(/-/, "_")}"
18
+ end
19
+ [header, rack_form]
20
+ end.to_h.tap do |hm|
21
+ hm.default_proc = proc { |hsh, key| "HTTP_#{key.upcase.gsub(/-/, "_")}" }
22
+ end
23
+
10
24
  def to_rack_env
11
25
  path = self.path
12
26
  host = self.host
@@ -21,8 +35,8 @@ module Itsi
21
35
  "REMOTE_ADDR" => remote_addr,
22
36
  "SERVER_PORT" => port.to_s,
23
37
  "SERVER_NAME" => host,
24
- "HTTP_HOST" => host,
25
38
  "SERVER_PROTOCOL" => version,
39
+ "HTTP_HOST" => host,
26
40
  "HTTP_VERSION" => version,
27
41
  "itsi.request" => self,
28
42
  "itsi.response" => response,
@@ -36,17 +50,26 @@ module Itsi
36
50
  "rack.hijack?" => true,
37
51
  "rack.multipart.buffer_size" => 16_384,
38
52
  "rack.hijack" => build_hijack_proc
39
- }.tap { |r| headers.each { |(k, v)| r[k] = v } }
53
+ }.tap do |r|
54
+ headers.each do |(k, v)|
55
+ r[RACK_HEADER_MAP[k]] = v
56
+ end
57
+ end
58
+ end
59
+
60
+ def respond(_body = nil, _status = 200, _header = nil, status: _status, headers: _header, body: _body,
61
+ hijack: false, &blk)
62
+ response.respond(status: status, headers: headers, body: body, hijack: hijack, &blk)
40
63
  end
41
64
 
42
65
  def build_hijack_proc
43
66
  lambda do
44
67
  self.hijacked = true
45
68
  UNIXSocket.pair.yield_self do |(server_sock, app_sock)|
69
+ server_sock.autoclose = false
46
70
  response.hijack(server_sock.fileno)
47
71
  server_sock.sync = true
48
72
  app_sock.sync = true
49
- app_sock.instance_variable_set("@server_sock", server_sock)
50
73
  app_sock
51
74
  end
52
75
  end
@@ -54,8 +77,9 @@ module Itsi
54
77
 
55
78
  def build_input_io
56
79
  case body
57
- when Array then File.open(body.first, "rb")
80
+ when nil then StringIO.new("")
58
81
  when String then StringIO.new(body)
82
+ when Array then File.open(body.first, "rb")
59
83
  else body
60
84
  end
61
85
  end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ require 'forwardable'
3
+ require "stringio"
4
+ require "socket"
5
+
6
+ module Itsi
7
+
8
+ class HttpResponse
9
+
10
+ def respond _body=nil, _status=200, _header=nil, status: _status, headers: _header, body: _body, hijack: false, &blk
11
+ self.status = status
12
+
13
+ if headers
14
+ headers.each do |key, value|
15
+ if value.is_a?(Array)
16
+ value.each { |v| add_header(key, v) }
17
+ else
18
+ add_header(key, value)
19
+ end
20
+ end
21
+ end
22
+
23
+ if body
24
+ # Common case. Write a single string body.
25
+ send_and_close(body)
26
+ elsif block_given?
27
+
28
+ # If you call respond with a block, you get a handle to a stream that you can write to.
29
+ yield self
30
+
31
+ # If you hijack the connection, you are responsible for closing it.
32
+ # Otherwise, the response will be closed automatically.
33
+ self.close unless hijack
34
+ else
35
+ self.close
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- env = ENV.fetch('APP_ENV') { ENV.fetch('RACK_ENV', 'development') }
3
2
 
4
3
  # This is the default Itsi configuration file, installed when you run `itsi init`
5
4
  # It contains a sane starting point for configuring your Itsi server.
@@ -7,18 +6,20 @@ env = ENV.fetch('APP_ENV') { ENV.fetch('RACK_ENV', 'development') }
7
6
  # Most of the options in this file can be overridden by command line options.
8
7
  # Check out itsi -h to learn more about the command line options available to you.
9
8
 
9
+ env = ENV.fetch("APP_ENV") { ENV.fetch("RACK_ENV", "development") }
10
+
10
11
  # Number of worker processes to spawn
11
12
  # If more than 1, Itsi will be booted in Cluster mode
12
- workers ENV.fetch('ITSI_WORKERS') {
13
- require 'etc'
14
- env == 'development' ? 1 : Etc.nprocessors
13
+ workers ENV.fetch("ITSI_WORKERS") {
14
+ require "etc"
15
+ env == "development" ? 1 : Etc.nprocessors
15
16
  }
16
17
 
17
18
  # Number of threads to spawn per worker process
18
19
  # For pure CPU bound applicationss, you'll get the best results keeping this number low
19
20
  # Setting a value of 1 is great for superficial benchmarks, but in reality
20
21
  # it's better to set this a bit higher to allow expensive requests to get overtaken and minimize head-of-line blocking
21
- threads ENV.fetch('ITSI_THREADS', 3)
22
+ threads ENV.fetch("ITSI_THREADS", 3)
22
23
 
23
24
  # If your application is IO bound (e.g. performing a lot of proxied HTTP requests, or heavy queries etc)
24
25
  # you can see *substantial* benefits from enabling this option.
@@ -38,7 +39,7 @@ fiber_scheduler nil
38
39
  # use Rack::CommonLogger
39
40
  # run ->(env) { [200, { 'content-type' => 'text/plain' }, ['OK']] }
40
41
  # end)
41
- rackup_file 'config.ru'
42
+ rackup_file "config.ru"
42
43
 
43
44
  # If you bind to https, without specifying a certificate, Itsi will use a self-signed certificate.
44
45
  # The self-signed certificate will use a CA generated for your host and stored inside `ITSI_LOCAL_CA_DIR` (Defaults to ~/.itsi)
@@ -57,10 +58,10 @@ rackup_file 'config.ru'
57
58
  # bind "unix:///tmp/itsi.sock"
58
59
  # bind "tls:///tmp/itsi.secure.sock"
59
60
 
60
- if env == 'development'
61
- bind 'http://localhost:3000'
61
+ if env == "development"
62
+ bind "http://localhost:3000"
62
63
  else
63
- bind "https://0.0.0.0?domains=#{ENV['PRODUCTION_DOMAINS']}&cert=acme&acme_email=admin@itsi.fyi"
64
+ bind "https://0.0.0.0?domains=#{ENV["PRODUCTION_DOMAINS"]}&cert=acme&acme_email=admin@itsi.fyi"
64
65
  end
65
66
 
66
67
  # If you want to preload the application, set preload to true
@@ -80,7 +81,7 @@ preload true
80
81
  # When this limit is reached, the worker will be gracefully restarted.
81
82
  # Only one worker is restarted at a time to ensure we don't take down
82
83
  # all of them at once, if they reach the threshold simultaneously.
83
- worker_memory_limit 48 * 1024 * 1024
84
+ worker_memory_limit 1024 * 1024 * 1024
84
85
 
85
86
  # You can provide an optional block of code to run, when a worker hits its memory threshold (Use this to send yourself an alert,
86
87
  # write metrics to disk etc. etc.)
@@ -107,15 +108,6 @@ stream_body false
107
108
  # Setting this too low can substantially worsen performance
108
109
  oob_gc_responses_threshold 512
109
110
 
110
- # Set this to false for application environments that require rack.input to be a rewindable body
111
- # (like Rails). For rack applications that can stream inputs, you can set this to true for a more memory-efficient approach.
112
- stream_body false
113
-
114
- # OOB GC responses threshold
115
- # Specifies how frequently OOB gc should be triggered during periods where there is a gap in queued requests.
116
- # Setting this too low can substantially worsen performance
117
- oob_gc_responses_threshold 512
118
-
119
111
  # Log level
120
112
  # Set this to one of the following values: debug, info, warn, error, fatal
121
113
  # Can also be set using the ITSI_LOG environment variable