itsi-server 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 (123) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/CODE_OF_CONDUCT.md +7 -0
  4. data/Cargo.lock +1536 -45
  5. data/README.md +4 -0
  6. data/_index.md +6 -0
  7. data/exe/itsi +33 -74
  8. data/ext/itsi_error/src/lib.rs +9 -0
  9. data/ext/itsi_error/target/debug/build/clang-sys-da71b0344e568175/out/common.rs +355 -0
  10. data/ext/itsi_error/target/debug/build/clang-sys-da71b0344e568175/out/dynamic.rs +276 -0
  11. data/ext/itsi_error/target/debug/build/clang-sys-da71b0344e568175/out/macros.rs +49 -0
  12. data/ext/itsi_error/target/debug/build/rb-sys-49f554618693db24/out/bindings-0.9.110-mri-arm64-darwin23-3.4.2.rs +8865 -0
  13. data/ext/itsi_error/target/debug/incremental/itsi_error-1mmt5sux7jb0i/s-h510z7m8v9-0bxu7yd.lock +0 -0
  14. data/ext/itsi_error/target/debug/incremental/itsi_error-2vn3jey74oiw0/s-h5113n0e7e-1v5qzs6.lock +0 -0
  15. data/ext/itsi_error/target/debug/incremental/itsi_error-37uv9dicz7awp/s-h510ykifhe-0tbnep2.lock +0 -0
  16. data/ext/itsi_error/target/debug/incremental/itsi_error-37uv9dicz7awp/s-h510yyocpj-0tz7ug7.lock +0 -0
  17. data/ext/itsi_error/target/debug/incremental/itsi_error-37uv9dicz7awp/s-h510z0xc8g-14ol18k.lock +0 -0
  18. data/ext/itsi_error/target/debug/incremental/itsi_error-3g5qf4y7d54uj/s-h5113n0e7d-1trk8on.lock +0 -0
  19. data/ext/itsi_error/target/debug/incremental/itsi_error-3lpfftm45d3e2/s-h510z7m8r3-1pxp20o.lock +0 -0
  20. data/ext/itsi_error/target/debug/incremental/itsi_error-3o4qownhl3d7n/s-h510ykifek-1uxasnk.lock +0 -0
  21. data/ext/itsi_error/target/debug/incremental/itsi_error-3o4qownhl3d7n/s-h510yyocki-11u37qm.lock +0 -0
  22. data/ext/itsi_error/target/debug/incremental/itsi_error-3o4qownhl3d7n/s-h510z0xc93-0pmy0zm.lock +0 -0
  23. data/ext/itsi_rb_helpers/Cargo.toml +1 -0
  24. data/ext/itsi_rb_helpers/src/heap_value.rs +18 -0
  25. data/ext/itsi_rb_helpers/src/lib.rs +34 -7
  26. data/ext/itsi_rb_helpers/target/debug/build/clang-sys-da71b0344e568175/out/common.rs +355 -0
  27. data/ext/itsi_rb_helpers/target/debug/build/clang-sys-da71b0344e568175/out/dynamic.rs +276 -0
  28. data/ext/itsi_rb_helpers/target/debug/build/clang-sys-da71b0344e568175/out/macros.rs +49 -0
  29. data/ext/itsi_rb_helpers/target/debug/build/rb-sys-eb9ed4ff3a60f995/out/bindings-0.9.110-mri-arm64-darwin23-3.4.2.rs +8865 -0
  30. data/ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-040pxg6yhb3g3/s-h5113n7a1b-03bwlt4.lock +0 -0
  31. data/ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-131g1u4dzkt1a/s-h51113xnh3-1eik1ip.lock +0 -0
  32. data/ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-131g1u4dzkt1a/s-h5111704jj-0g4rj8x.lock +0 -0
  33. data/ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-1q2d3drtxrzs5/s-h5113n79yl-0bxcqc5.lock +0 -0
  34. data/ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-374a9h7ovycj0/s-h51113xoox-10de2hp.lock +0 -0
  35. data/ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-374a9h7ovycj0/s-h5111704w7-0vdq7gq.lock +0 -0
  36. data/ext/itsi_server/Cargo.toml +69 -30
  37. data/ext/itsi_server/src/lib.rs +79 -147
  38. data/ext/itsi_server/src/{body_proxy → ruby_types/itsi_body_proxy}/big_bytes.rs +10 -5
  39. data/ext/itsi_server/src/{body_proxy/itsi_body_proxy.rs → ruby_types/itsi_body_proxy/mod.rs} +22 -3
  40. data/ext/itsi_server/src/ruby_types/itsi_grpc_request.rs +147 -0
  41. data/ext/itsi_server/src/ruby_types/itsi_grpc_response.rs +19 -0
  42. data/ext/itsi_server/src/ruby_types/itsi_grpc_stream/mod.rs +216 -0
  43. data/ext/itsi_server/src/{request/itsi_request.rs → ruby_types/itsi_http_request.rs} +101 -117
  44. data/ext/itsi_server/src/{response/itsi_response.rs → ruby_types/itsi_http_response.rs} +72 -41
  45. data/ext/itsi_server/src/ruby_types/itsi_server/file_watcher.rs +225 -0
  46. data/ext/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +355 -0
  47. data/ext/itsi_server/src/ruby_types/itsi_server.rs +82 -0
  48. data/ext/itsi_server/src/ruby_types/mod.rs +55 -0
  49. data/ext/itsi_server/src/server/bind.rs +13 -5
  50. data/ext/itsi_server/src/server/byte_frame.rs +32 -0
  51. data/ext/itsi_server/src/server/cache_store.rs +74 -0
  52. data/ext/itsi_server/src/server/itsi_service.rs +172 -0
  53. data/ext/itsi_server/src/server/lifecycle_event.rs +3 -0
  54. data/ext/itsi_server/src/server/listener.rs +102 -2
  55. data/ext/itsi_server/src/server/middleware_stack/middleware.rs +153 -0
  56. data/ext/itsi_server/src/server/middleware_stack/middlewares/allow_list.rs +47 -0
  57. data/ext/itsi_server/src/server/middleware_stack/middlewares/auth_api_key.rs +58 -0
  58. data/ext/itsi_server/src/server/middleware_stack/middlewares/auth_basic.rs +82 -0
  59. data/ext/itsi_server/src/server/middleware_stack/middlewares/auth_jwt.rs +321 -0
  60. data/ext/itsi_server/src/server/middleware_stack/middlewares/cache_control.rs +139 -0
  61. data/ext/itsi_server/src/server/middleware_stack/middlewares/compression.rs +300 -0
  62. data/ext/itsi_server/src/server/middleware_stack/middlewares/cors.rs +287 -0
  63. data/ext/itsi_server/src/server/middleware_stack/middlewares/deny_list.rs +48 -0
  64. data/ext/itsi_server/src/server/middleware_stack/middlewares/error_response.rs +127 -0
  65. data/ext/itsi_server/src/server/middleware_stack/middlewares/etag.rs +191 -0
  66. data/ext/itsi_server/src/server/middleware_stack/middlewares/grpc_service.rs +72 -0
  67. data/ext/itsi_server/src/server/middleware_stack/middlewares/header_interpretation.rs +85 -0
  68. data/ext/itsi_server/src/server/middleware_stack/middlewares/intrusion_protection.rs +195 -0
  69. data/ext/itsi_server/src/server/middleware_stack/middlewares/log_requests.rs +82 -0
  70. data/ext/itsi_server/src/server/middleware_stack/middlewares/mod.rs +82 -0
  71. data/ext/itsi_server/src/server/middleware_stack/middlewares/proxy.rs +216 -0
  72. data/ext/itsi_server/src/server/middleware_stack/middlewares/rate_limit.rs +124 -0
  73. data/ext/itsi_server/src/server/middleware_stack/middlewares/redirect.rs +76 -0
  74. data/ext/itsi_server/src/server/middleware_stack/middlewares/request_headers.rs +43 -0
  75. data/ext/itsi_server/src/server/middleware_stack/middlewares/response_headers.rs +34 -0
  76. data/ext/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs +93 -0
  77. data/ext/itsi_server/src/server/middleware_stack/middlewares/static_assets.rs +162 -0
  78. data/ext/itsi_server/src/server/middleware_stack/middlewares/string_rewrite.rs +158 -0
  79. data/ext/itsi_server/src/server/middleware_stack/middlewares/token_source.rs +12 -0
  80. data/ext/itsi_server/src/server/middleware_stack/mod.rs +315 -0
  81. data/ext/itsi_server/src/server/mod.rs +8 -1
  82. data/ext/itsi_server/src/server/process_worker.rs +38 -12
  83. data/ext/itsi_server/src/server/rate_limiter.rs +565 -0
  84. data/ext/itsi_server/src/server/request_job.rs +11 -0
  85. data/ext/itsi_server/src/server/serve_strategy/cluster_mode.rs +119 -42
  86. data/ext/itsi_server/src/server/serve_strategy/mod.rs +9 -6
  87. data/ext/itsi_server/src/server/serve_strategy/single_mode.rs +256 -111
  88. data/ext/itsi_server/src/server/signal.rs +19 -0
  89. data/ext/itsi_server/src/server/static_file_server.rs +984 -0
  90. data/ext/itsi_server/src/server/thread_worker.rs +139 -94
  91. data/ext/itsi_server/src/server/types.rs +43 -0
  92. data/ext/itsi_tracing/Cargo.toml +1 -0
  93. data/ext/itsi_tracing/src/lib.rs +216 -45
  94. data/ext/itsi_tracing/target/debug/incremental/itsi_tracing-0994n8rpvvt9m/s-h510hfz1f6-1kbycmq.lock +0 -0
  95. data/ext/itsi_tracing/target/debug/incremental/itsi_tracing-0bob7bf4yq34i/s-h5113125h5-0lh4rag.lock +0 -0
  96. data/ext/itsi_tracing/target/debug/incremental/itsi_tracing-2fcodulrxbbxo/s-h510h2infk-0hp5kjw.lock +0 -0
  97. data/ext/itsi_tracing/target/debug/incremental/itsi_tracing-2iak63r1woi1l/s-h510h2in4q-0kxfzw1.lock +0 -0
  98. data/ext/itsi_tracing/target/debug/incremental/itsi_tracing-2kk4qj9gn5dg2/s-h5113124kv-0enwon2.lock +0 -0
  99. data/ext/itsi_tracing/target/debug/incremental/itsi_tracing-2mwo0yas7dtw4/s-h510hfz1ha-1udgpei.lock +0 -0
  100. data/lib/itsi/{request.rb → http_request.rb} +29 -5
  101. data/lib/itsi/http_response.rb +39 -0
  102. data/lib/itsi/server/Itsi.rb +11 -19
  103. data/lib/itsi/server/config/dsl.rb +506 -0
  104. data/lib/itsi/server/config.rb +103 -8
  105. data/lib/itsi/server/default_app/default_app.rb +38 -0
  106. data/lib/itsi/server/grpc_interface.rb +213 -0
  107. data/lib/itsi/server/rack/handler/itsi.rb +8 -17
  108. data/lib/itsi/server/rack_interface.rb +23 -4
  109. data/lib/itsi/server/scheduler_interface.rb +1 -1
  110. data/lib/itsi/server/scheduler_mode.rb +4 -0
  111. data/lib/itsi/server/signal_trap.rb +7 -1
  112. data/lib/itsi/server/version.rb +1 -1
  113. data/lib/itsi/server.rb +74 -63
  114. data/lib/itsi/standard_headers.rb +86 -0
  115. metadata +84 -15
  116. data/ext/itsi_scheduler/extconf.rb +0 -6
  117. data/ext/itsi_server/src/body_proxy/mod.rs +0 -2
  118. data/ext/itsi_server/src/request/mod.rs +0 -1
  119. data/ext/itsi_server/src/response/mod.rs +0 -1
  120. data/ext/itsi_server/src/server/itsi_server.rs +0 -288
  121. data/lib/itsi/server/options_dsl.rb +0 -401
  122. data/lib/itsi/stream_io.rb +0 -38
  123. /data/lib/itsi/{index.html → server/default_app/index.html} +0 -0
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itsi-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wouter Coppieters
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-03-17 00:00:00.000000000 Z
10
+ date: 2025-03-29 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rack
@@ -54,19 +54,43 @@ files:
54
54
  - LICENSE.txt
55
55
  - README.md
56
56
  - Rakefile
57
+ - _index.md
57
58
  - exe/itsi
58
59
  - ext/itsi_error/Cargo.lock
59
60
  - ext/itsi_error/Cargo.toml
60
61
  - ext/itsi_error/src/from.rs
61
62
  - ext/itsi_error/src/lib.rs
63
+ - ext/itsi_error/target/debug/build/clang-sys-da71b0344e568175/out/common.rs
64
+ - ext/itsi_error/target/debug/build/clang-sys-da71b0344e568175/out/dynamic.rs
65
+ - ext/itsi_error/target/debug/build/clang-sys-da71b0344e568175/out/macros.rs
66
+ - ext/itsi_error/target/debug/build/rb-sys-49f554618693db24/out/bindings-0.9.110-mri-arm64-darwin23-3.4.2.rs
67
+ - ext/itsi_error/target/debug/incremental/itsi_error-1mmt5sux7jb0i/s-h510z7m8v9-0bxu7yd.lock
68
+ - ext/itsi_error/target/debug/incremental/itsi_error-2vn3jey74oiw0/s-h5113n0e7e-1v5qzs6.lock
69
+ - ext/itsi_error/target/debug/incremental/itsi_error-37uv9dicz7awp/s-h510ykifhe-0tbnep2.lock
70
+ - ext/itsi_error/target/debug/incremental/itsi_error-37uv9dicz7awp/s-h510yyocpj-0tz7ug7.lock
71
+ - ext/itsi_error/target/debug/incremental/itsi_error-37uv9dicz7awp/s-h510z0xc8g-14ol18k.lock
72
+ - ext/itsi_error/target/debug/incremental/itsi_error-3g5qf4y7d54uj/s-h5113n0e7d-1trk8on.lock
73
+ - ext/itsi_error/target/debug/incremental/itsi_error-3lpfftm45d3e2/s-h510z7m8r3-1pxp20o.lock
74
+ - ext/itsi_error/target/debug/incremental/itsi_error-3o4qownhl3d7n/s-h510ykifek-1uxasnk.lock
75
+ - ext/itsi_error/target/debug/incremental/itsi_error-3o4qownhl3d7n/s-h510yyocki-11u37qm.lock
76
+ - ext/itsi_error/target/debug/incremental/itsi_error-3o4qownhl3d7n/s-h510z0xc93-0pmy0zm.lock
62
77
  - ext/itsi_instrument_entry/Cargo.toml
63
78
  - ext/itsi_instrument_entry/src/lib.rs
64
79
  - ext/itsi_rb_helpers/Cargo.lock
65
80
  - ext/itsi_rb_helpers/Cargo.toml
66
81
  - ext/itsi_rb_helpers/src/heap_value.rs
67
82
  - ext/itsi_rb_helpers/src/lib.rs
83
+ - ext/itsi_rb_helpers/target/debug/build/clang-sys-da71b0344e568175/out/common.rs
84
+ - ext/itsi_rb_helpers/target/debug/build/clang-sys-da71b0344e568175/out/dynamic.rs
85
+ - ext/itsi_rb_helpers/target/debug/build/clang-sys-da71b0344e568175/out/macros.rs
86
+ - ext/itsi_rb_helpers/target/debug/build/rb-sys-eb9ed4ff3a60f995/out/bindings-0.9.110-mri-arm64-darwin23-3.4.2.rs
87
+ - ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-040pxg6yhb3g3/s-h5113n7a1b-03bwlt4.lock
88
+ - ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-131g1u4dzkt1a/s-h51113xnh3-1eik1ip.lock
89
+ - ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-131g1u4dzkt1a/s-h5111704jj-0g4rj8x.lock
90
+ - ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-1q2d3drtxrzs5/s-h5113n79yl-0bxcqc5.lock
91
+ - ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-374a9h7ovycj0/s-h51113xoox-10de2hp.lock
92
+ - ext/itsi_rb_helpers/target/debug/incremental/itsi_rb_helpers-374a9h7ovycj0/s-h5111704w7-0vdq7gq.lock
68
93
  - ext/itsi_scheduler/Cargo.toml
69
- - ext/itsi_scheduler/extconf.rb
70
94
  - ext/itsi_scheduler/src/itsi_scheduler.rs
71
95
  - ext/itsi_scheduler/src/itsi_scheduler/io_helpers.rs
72
96
  - ext/itsi_scheduler/src/itsi_scheduler/io_waiter.rs
@@ -75,46 +99,91 @@ files:
75
99
  - ext/itsi_server/Cargo.lock
76
100
  - ext/itsi_server/Cargo.toml
77
101
  - ext/itsi_server/extconf.rb
78
- - ext/itsi_server/src/body_proxy/big_bytes.rs
79
- - ext/itsi_server/src/body_proxy/itsi_body_proxy.rs
80
- - ext/itsi_server/src/body_proxy/mod.rs
81
102
  - ext/itsi_server/src/env.rs
82
103
  - ext/itsi_server/src/lib.rs
83
- - ext/itsi_server/src/request/itsi_request.rs
84
- - ext/itsi_server/src/request/mod.rs
85
- - ext/itsi_server/src/response/itsi_response.rs
86
- - ext/itsi_server/src/response/mod.rs
104
+ - ext/itsi_server/src/ruby_types/itsi_body_proxy/big_bytes.rs
105
+ - ext/itsi_server/src/ruby_types/itsi_body_proxy/mod.rs
106
+ - ext/itsi_server/src/ruby_types/itsi_grpc_request.rs
107
+ - ext/itsi_server/src/ruby_types/itsi_grpc_response.rs
108
+ - ext/itsi_server/src/ruby_types/itsi_grpc_stream/mod.rs
109
+ - ext/itsi_server/src/ruby_types/itsi_http_request.rs
110
+ - ext/itsi_server/src/ruby_types/itsi_http_response.rs
111
+ - ext/itsi_server/src/ruby_types/itsi_server.rs
112
+ - ext/itsi_server/src/ruby_types/itsi_server/file_watcher.rs
113
+ - ext/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs
114
+ - ext/itsi_server/src/ruby_types/mod.rs
87
115
  - ext/itsi_server/src/server/bind.rs
88
116
  - ext/itsi_server/src/server/bind_protocol.rs
117
+ - ext/itsi_server/src/server/byte_frame.rs
118
+ - ext/itsi_server/src/server/cache_store.rs
89
119
  - ext/itsi_server/src/server/io_stream.rs
90
- - ext/itsi_server/src/server/itsi_server.rs
120
+ - ext/itsi_server/src/server/itsi_service.rs
91
121
  - ext/itsi_server/src/server/lifecycle_event.rs
92
122
  - ext/itsi_server/src/server/listener.rs
123
+ - ext/itsi_server/src/server/middleware_stack/middleware.rs
124
+ - ext/itsi_server/src/server/middleware_stack/middlewares/allow_list.rs
125
+ - ext/itsi_server/src/server/middleware_stack/middlewares/auth_api_key.rs
126
+ - ext/itsi_server/src/server/middleware_stack/middlewares/auth_basic.rs
127
+ - ext/itsi_server/src/server/middleware_stack/middlewares/auth_jwt.rs
128
+ - ext/itsi_server/src/server/middleware_stack/middlewares/cache_control.rs
129
+ - ext/itsi_server/src/server/middleware_stack/middlewares/compression.rs
130
+ - ext/itsi_server/src/server/middleware_stack/middlewares/cors.rs
131
+ - ext/itsi_server/src/server/middleware_stack/middlewares/deny_list.rs
132
+ - ext/itsi_server/src/server/middleware_stack/middlewares/error_response.rs
133
+ - ext/itsi_server/src/server/middleware_stack/middlewares/etag.rs
134
+ - ext/itsi_server/src/server/middleware_stack/middlewares/grpc_service.rs
135
+ - ext/itsi_server/src/server/middleware_stack/middlewares/header_interpretation.rs
136
+ - ext/itsi_server/src/server/middleware_stack/middlewares/intrusion_protection.rs
137
+ - ext/itsi_server/src/server/middleware_stack/middlewares/log_requests.rs
138
+ - ext/itsi_server/src/server/middleware_stack/middlewares/mod.rs
139
+ - ext/itsi_server/src/server/middleware_stack/middlewares/proxy.rs
140
+ - ext/itsi_server/src/server/middleware_stack/middlewares/rate_limit.rs
141
+ - ext/itsi_server/src/server/middleware_stack/middlewares/redirect.rs
142
+ - ext/itsi_server/src/server/middleware_stack/middlewares/request_headers.rs
143
+ - ext/itsi_server/src/server/middleware_stack/middlewares/response_headers.rs
144
+ - ext/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs
145
+ - ext/itsi_server/src/server/middleware_stack/middlewares/static_assets.rs
146
+ - ext/itsi_server/src/server/middleware_stack/middlewares/string_rewrite.rs
147
+ - ext/itsi_server/src/server/middleware_stack/middlewares/token_source.rs
148
+ - ext/itsi_server/src/server/middleware_stack/mod.rs
93
149
  - ext/itsi_server/src/server/mod.rs
94
150
  - ext/itsi_server/src/server/process_worker.rs
151
+ - ext/itsi_server/src/server/rate_limiter.rs
152
+ - ext/itsi_server/src/server/request_job.rs
95
153
  - ext/itsi_server/src/server/serve_strategy/cluster_mode.rs
96
154
  - ext/itsi_server/src/server/serve_strategy/mod.rs
97
155
  - ext/itsi_server/src/server/serve_strategy/single_mode.rs
98
156
  - ext/itsi_server/src/server/signal.rs
157
+ - ext/itsi_server/src/server/static_file_server.rs
99
158
  - ext/itsi_server/src/server/thread_worker.rs
100
159
  - ext/itsi_server/src/server/tls.rs
101
160
  - ext/itsi_server/src/server/tls/locked_dir_cache.rs
161
+ - ext/itsi_server/src/server/types.rs
102
162
  - ext/itsi_tracing/Cargo.lock
103
163
  - ext/itsi_tracing/Cargo.toml
104
164
  - ext/itsi_tracing/src/lib.rs
105
- - lib/itsi/index.html
106
- - lib/itsi/request.rb
165
+ - ext/itsi_tracing/target/debug/incremental/itsi_tracing-0994n8rpvvt9m/s-h510hfz1f6-1kbycmq.lock
166
+ - ext/itsi_tracing/target/debug/incremental/itsi_tracing-0bob7bf4yq34i/s-h5113125h5-0lh4rag.lock
167
+ - ext/itsi_tracing/target/debug/incremental/itsi_tracing-2fcodulrxbbxo/s-h510h2infk-0hp5kjw.lock
168
+ - ext/itsi_tracing/target/debug/incremental/itsi_tracing-2iak63r1woi1l/s-h510h2in4q-0kxfzw1.lock
169
+ - ext/itsi_tracing/target/debug/incremental/itsi_tracing-2kk4qj9gn5dg2/s-h5113124kv-0enwon2.lock
170
+ - ext/itsi_tracing/target/debug/incremental/itsi_tracing-2mwo0yas7dtw4/s-h510hfz1ha-1udgpei.lock
171
+ - lib/itsi/http_request.rb
172
+ - lib/itsi/http_response.rb
107
173
  - lib/itsi/server.rb
108
174
  - lib/itsi/server/Itsi.rb
109
175
  - lib/itsi/server/config.rb
110
- - lib/itsi/server/options_dsl.rb
176
+ - lib/itsi/server/config/dsl.rb
177
+ - lib/itsi/server/default_app/default_app.rb
178
+ - lib/itsi/server/default_app/index.html
179
+ - lib/itsi/server/grpc_interface.rb
111
180
  - lib/itsi/server/rack/handler/itsi.rb
112
181
  - lib/itsi/server/rack_interface.rb
113
182
  - lib/itsi/server/scheduler_interface.rb
114
183
  - lib/itsi/server/scheduler_mode.rb
115
184
  - lib/itsi/server/signal_trap.rb
116
185
  - lib/itsi/server/version.rb
117
- - lib/itsi/stream_io.rb
186
+ - lib/itsi/standard_headers.rb
118
187
  - sig/itsi_server.rbs
119
188
  homepage: https://itsi.fyi
120
189
  licenses:
@@ -1,6 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "mkmf"
4
- require "rb_sys/mkmf"
5
-
6
- create_rust_makefile("itsi/scheduler/itsi_scheduler")
@@ -1,2 +0,0 @@
1
- pub mod big_bytes;
2
- pub mod itsi_body_proxy;
@@ -1 +0,0 @@
1
- pub mod itsi_request;
@@ -1 +0,0 @@
1
- pub mod itsi_response;
@@ -1,288 +0,0 @@
1
- use super::{
2
- bind::Bind,
3
- listener::Listener,
4
- serve_strategy::{cluster_mode::ClusterMode, single_mode::SingleMode},
5
- signal::{
6
- clear_signal_handlers, reset_signal_handlers, send_shutdown_event, SIGNAL_HANDLER_CHANNEL,
7
- },
8
- };
9
- use crate::{request::itsi_request::ItsiRequest, server::serve_strategy::ServeStrategy};
10
- use derive_more::Debug;
11
- use itsi_rb_helpers::{call_without_gvl, HeapVal, HeapValue};
12
- use itsi_tracing::{error, run_silently};
13
- use magnus::{
14
- block::Proc,
15
- error::Result,
16
- scan_args::{get_kwargs, scan_args, Args, KwArgs, ScanArgsKw, ScanArgsOpt, ScanArgsRequired},
17
- value::ReprValue,
18
- ArgList, RArray, RHash, Ruby, Symbol, Value,
19
- };
20
- use parking_lot::{Mutex, RwLock};
21
- use std::{cmp::max, collections::HashMap, ops::Deref, sync::Arc};
22
- use tracing::{info, instrument};
23
-
24
- static DEFAULT_BIND: &str = "http://localhost:3000";
25
-
26
- #[magnus::wrap(class = "Itsi::Server", free_immediately, size)]
27
- #[derive(Clone)]
28
- pub struct Server {
29
- pub config: Arc<ServerConfig>,
30
- }
31
-
32
- impl Deref for Server {
33
- type Target = ServerConfig;
34
-
35
- fn deref(&self) -> &Self::Target {
36
- &self.config
37
- }
38
- }
39
-
40
- #[derive(Debug)]
41
- pub struct ServerConfig {
42
- #[debug(skip)]
43
- pub app: HeapVal,
44
- #[allow(unused)]
45
- pub workers: u8,
46
- #[allow(unused)]
47
- pub threads: u8,
48
- #[allow(unused)]
49
- pub shutdown_timeout: f64,
50
- pub script_name: String,
51
- pub(crate) binds: Mutex<Vec<Bind>>,
52
- #[debug(skip)]
53
- pub hooks: HashMap<String, HeapValue<Proc>>,
54
- pub scheduler_class: Option<String>,
55
- pub stream_body: Option<bool>,
56
- pub worker_memory_limit: Option<u64>,
57
- #[debug(skip)]
58
- pub(crate) strategy: RwLock<Option<ServeStrategy>>,
59
- pub silence: bool,
60
- pub oob_gc_responses_threshold: Option<u64>,
61
- }
62
-
63
- #[derive(Debug)]
64
- pub enum RequestJob {
65
- ProcessRequest(ItsiRequest),
66
- Shutdown,
67
- }
68
-
69
- fn extract_args<Req, Opt, Splat>(
70
- scan_args: &Args<(), (), (), (), RHash, ()>,
71
- primaries: &[&str],
72
- rest: &[&str],
73
- ) -> Result<KwArgs<Req, Opt, Splat>>
74
- where
75
- Req: ScanArgsRequired,
76
- Opt: ScanArgsOpt,
77
- Splat: ScanArgsKw,
78
- {
79
- let symbols: Vec<Symbol> = primaries
80
- .iter()
81
- .chain(rest.iter())
82
- .map(|&name| Symbol::new(name))
83
- .collect();
84
-
85
- let hash = scan_args
86
- .keywords
87
- .funcall::<_, _, RHash>("slice", symbols.into_arg_list_with(&Ruby::get().unwrap()))
88
- .unwrap();
89
-
90
- get_kwargs(hash, primaries, rest)
91
- }
92
-
93
- impl Server {
94
- #[instrument(
95
- name = "Itsi",
96
- parent=None,
97
- skip(args),
98
- fields(workers = 1, threads = 1, shutdown_timeout = 5)
99
- )]
100
- pub fn new(args: &[Value]) -> Result<Self> {
101
- let scan_args: Args<(), (), (), (), RHash, ()> = scan_args(args)?;
102
-
103
- type Args1 = KwArgs<
104
- (Value,),
105
- (
106
- // Workers
107
- Option<u8>,
108
- // Threads
109
- Option<u8>,
110
- // Shutdown Timeout
111
- Option<f64>,
112
- // Script Name
113
- Option<String>,
114
- // Binds
115
- Option<Vec<String>>,
116
- // Stream Body
117
- Option<bool>,
118
- ),
119
- (),
120
- >;
121
-
122
- type Args2 = KwArgs<
123
- (),
124
- (
125
- // Hooks
126
- Option<RHash>,
127
- // Scheduler Class
128
- Option<String>,
129
- // Worker Memory Limit
130
- Option<u64>,
131
- // Out-of-band GC Responses Threshold
132
- Option<u64>,
133
- // Silence
134
- Option<bool>,
135
- ),
136
- (),
137
- >;
138
-
139
- let args1: Args1 = extract_args(
140
- &scan_args,
141
- &["app"],
142
- &[
143
- "workers",
144
- "threads",
145
- "shutdown_timeout",
146
- "script_name",
147
- "binds",
148
- "stream_body",
149
- ],
150
- )?;
151
-
152
- let args2: Args2 = extract_args(
153
- &scan_args,
154
- &[],
155
- &[
156
- "hooks",
157
- "scheduler_class",
158
- "worker_memory_limit",
159
- "oob_gc_responses_threshold",
160
- "silence",
161
- ],
162
- )?;
163
-
164
- let hooks = args2
165
- .optional
166
- .0
167
- .map(|rhash| -> Result<HashMap<String, HeapValue<Proc>>> {
168
- let mut hook_map: HashMap<String, HeapValue<Proc>> = HashMap::new();
169
- for pair in rhash.enumeratorize::<_, ()>("each", ()) {
170
- if let Some(pair_value) = RArray::from_value(pair?) {
171
- if let (Ok(key), Ok(value)) =
172
- (pair_value.entry::<Value>(0), pair_value.entry::<Proc>(1))
173
- {
174
- hook_map.insert(key.to_string(), HeapValue::from(value));
175
- }
176
- }
177
- }
178
- Ok(hook_map)
179
- })
180
- .transpose()?
181
- .unwrap_or_default();
182
-
183
- let config = ServerConfig {
184
- app: HeapVal::from(args1.required.0),
185
- workers: max(args1.optional.0.unwrap_or(1), 1),
186
- threads: max(args1.optional.1.unwrap_or(1), 1),
187
- shutdown_timeout: args1.optional.2.unwrap_or(5.0),
188
- script_name: args1.optional.3.unwrap_or("".to_string()),
189
- binds: Mutex::new(
190
- args1
191
- .optional
192
- .4
193
- .unwrap_or_else(|| vec![DEFAULT_BIND.to_string()])
194
- .into_iter()
195
- .map(|s| s.parse())
196
- .collect::<itsi_error::Result<Vec<Bind>>>()?,
197
- ),
198
- stream_body: args1.optional.5,
199
- hooks,
200
- scheduler_class: args2.optional.1.clone(),
201
- worker_memory_limit: args2.optional.2,
202
- strategy: RwLock::new(None),
203
- oob_gc_responses_threshold: args2.optional.3,
204
- silence: args2.optional.4.is_some_and(|s| s),
205
- };
206
-
207
- if !config.silence {
208
- if let Some(scheduler_class) = args2.optional.1 {
209
- info!(scheduler_class, fiber_scheduler = true);
210
- } else {
211
- info!(fiber_scheduler = false);
212
- }
213
- }
214
-
215
- Ok(Server {
216
- config: Arc::new(config),
217
- })
218
- }
219
-
220
- #[instrument(name = "Bind", skip_all, fields(binds=format!("{:?}", self.config.binds.lock())))]
221
- pub(crate) fn build_listeners(&self) -> Result<Vec<Listener>> {
222
- let listeners = self
223
- .config
224
- .binds
225
- .lock()
226
- .iter()
227
- .cloned()
228
- .map(Listener::try_from)
229
- .collect::<std::result::Result<Vec<Listener>, _>>()?
230
- .into_iter()
231
- .collect::<Vec<_>>();
232
- info!("Bound {:?} listeners", listeners.len());
233
- Ok(listeners)
234
- }
235
-
236
- pub(crate) fn build_strategy(self) -> Result<()> {
237
- let listeners = self.build_listeners()?;
238
- let server = Arc::new(self);
239
- let server_clone = server.clone();
240
-
241
- let strategy = if server.config.workers == 1 {
242
- ServeStrategy::Single(Arc::new(SingleMode::new(
243
- server,
244
- listeners,
245
- SIGNAL_HANDLER_CHANNEL.0.clone(),
246
- )?))
247
- } else {
248
- ServeStrategy::Cluster(Arc::new(ClusterMode::new(
249
- server,
250
- listeners,
251
- SIGNAL_HANDLER_CHANNEL.0.clone(),
252
- )))
253
- };
254
-
255
- *server_clone.strategy.write() = Some(strategy);
256
- Ok(())
257
- }
258
-
259
- pub fn stop(&self) -> Result<()> {
260
- send_shutdown_event();
261
- Ok(())
262
- }
263
-
264
- pub fn start(&self) -> Result<()> {
265
- if self.silence {
266
- run_silently(|| self.build_and_run_strategy())
267
- } else {
268
- self.build_and_run_strategy()
269
- }
270
- }
271
-
272
- fn build_and_run_strategy(&self) -> Result<()> {
273
- reset_signal_handlers();
274
- let rself = self.clone();
275
- call_without_gvl(move || -> Result<()> {
276
- rself.clone().build_strategy()?;
277
- if let Err(e) = rself.strategy.read().as_ref().unwrap().run() {
278
- error!("Error running server: {}", e);
279
- rself.strategy.read().as_ref().unwrap().stop()?;
280
- }
281
- Ok(())
282
- })?;
283
- clear_signal_handlers();
284
- self.strategy.write().take();
285
- info!("Server stopped");
286
- Ok(())
287
- }
288
- }