itsi 0.2.21.rc1 → 0.2.21

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +3 -0
  3. data/.rubocop.yml +20 -0
  4. data/CHANGELOG.md +3 -0
  5. data/Cargo.lock +14 -14
  6. data/Dockerfile +9 -0
  7. data/crates/itsi_acme/src/caches/no.rs +1 -1
  8. data/crates/itsi_acme/src/caches/test.rs +3 -3
  9. data/crates/itsi_acme/src/config.rs +6 -6
  10. data/crates/itsi_acme/src/lib.rs +1 -1
  11. data/crates/itsi_error/Cargo.toml +1 -1
  12. data/crates/itsi_error/src/lib.rs +32 -15
  13. data/crates/itsi_rb_helpers/Cargo.toml +2 -2
  14. data/crates/itsi_rb_helpers/src/heap_value.rs +4 -4
  15. data/crates/itsi_rb_helpers/src/lib.rs +9 -5
  16. data/crates/itsi_scheduler/Cargo.toml +3 -3
  17. data/crates/itsi_scheduler/src/itsi_scheduler.rs +1 -1
  18. data/crates/itsi_server/Cargo.toml +3 -3
  19. data/crates/itsi_server/src/lib.rs +3 -2
  20. data/crates/itsi_server/src/ruby_types/itsi_body_proxy/big_bytes.rs +10 -3
  21. data/crates/itsi_server/src/ruby_types/itsi_body_proxy/mod.rs +10 -6
  22. data/crates/itsi_server/src/ruby_types/itsi_grpc_call.rs +7 -5
  23. data/crates/itsi_server/src/ruby_types/itsi_grpc_response_stream/mod.rs +2 -2
  24. data/crates/itsi_server/src/ruby_types/itsi_http_request.rs +10 -7
  25. data/crates/itsi_server/src/ruby_types/itsi_http_response.rs +13 -5
  26. data/crates/itsi_server/src/ruby_types/itsi_server/file_watcher.rs +6 -6
  27. data/crates/itsi_server/src/ruby_types/itsi_server/itsi_server_config.rs +15 -11
  28. data/crates/itsi_server/src/ruby_types/itsi_server.rs +34 -18
  29. data/crates/itsi_server/src/server/frame_stream.rs +2 -1
  30. data/crates/itsi_server/src/server/middleware_stack/middleware.rs +1 -1
  31. data/crates/itsi_server/src/server/middleware_stack/middlewares/compression.rs +1 -3
  32. data/crates/itsi_server/src/server/middleware_stack/middlewares/mod.rs +8 -2
  33. data/crates/itsi_server/src/server/middleware_stack/middlewares/proxy.rs +2 -2
  34. data/crates/itsi_server/src/server/middleware_stack/middlewares/redirect.rs +1 -1
  35. data/crates/itsi_server/src/server/middleware_stack/middlewares/ruby_app.rs +17 -7
  36. data/crates/itsi_server/src/server/middleware_stack/middlewares/static_assets.rs +90 -21
  37. data/crates/itsi_server/src/server/middleware_stack/mod.rs +12 -12
  38. data/crates/itsi_server/src/server/serve_strategy/cluster_mode.rs +4 -3
  39. data/crates/itsi_server/src/services/password_hasher.rs +8 -2
  40. data/crates/itsi_server/src/services/rate_limiter.rs +72 -25
  41. data/crates/itsi_server/src/services/static_file_server.rs +38 -13
  42. data/crates/itsi_tracing/src/lib.rs +3 -3
  43. data/gems/scheduler/Cargo.lock +3997 -541
  44. data/gems/scheduler/lib/itsi/scheduler/version.rb +1 -1
  45. data/gems/server/Cargo.lock +40 -13
  46. data/gems/server/lib/itsi/http_request.rb +22 -17
  47. data/gems/server/lib/itsi/rack_env_pool.rb +7 -17
  48. data/gems/server/lib/itsi/server/config/middleware/static_assets.rb +8 -1
  49. data/gems/server/lib/itsi/server/rack_interface.rb +12 -0
  50. data/gems/server/lib/itsi/server/version.rb +1 -1
  51. data/lib/itsi/version.rb +1 -1
  52. data/mise.toml +2 -0
  53. metadata +9 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de46fbc801d723fe981489c7170e18d344b7f0de59b340c1c053bd89d880e3be
4
- data.tar.gz: 3b07a649c4de609d4e022962e7745788bebda8a07819bf930dbefea8f5fdebd4
3
+ metadata.gz: edac434aa9724351fa9fe5220e3451534473303c08d5b6ad34d56bbd5fb1aec6
4
+ data.tar.gz: 88efe1b953ed1a418666d32730450eb7c14c232d25ea94dcc4b1f169f649367e
5
5
  SHA512:
6
- metadata.gz: daee3821c95ff7a9de766eca58fb92a207ee26f9d6f7526da73159474e5b598ba6ccd5776b432736cb67ab79a9d394853f180cd09796d9874cd9491cfd5c34cc
7
- data.tar.gz: 3c744080b6f29042b572aedb37c0d7c5a6ed30eb83e9a93db2646d802637a50380c335f9bd30be3c3a48ade597c2bc1cdf26d171d36ee5eed590f02a7dc762a7
6
+ metadata.gz: 675fe7f09ec66c9583f3c69963127f3ec01e46bf613657bc7d8778919dfccf2a38d420348af3ed51fd5f4df6d05291fec816eab78daa67325196d589eb7dae82
7
+ data.tar.gz: e6d3276f2b3e59f5dd6cda1f3bcb44e54a59260ca0bf265092bd26069f6ecb3a2c56ad804792a2304062f3e6f3e0e355cf668b89a9a8a93a18168ca4f90ed811
data/.dockerignore ADDED
@@ -0,0 +1,3 @@
1
+ target
2
+ gems/scheduler/target
3
+ gems/server/target
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ TargetRubyVersion: 3.1
3
+ NewCops: enable
4
+ SuggestExtensions: false
5
+ Include:
6
+ - gems/server/lib/**/*.rb
7
+ - gems/scheduler/lib/**/*.rb
8
+ Exclude:
9
+ - examples/**/*
10
+ - gems/**/tmp/**/*
11
+ - target/**/*
12
+ - pkg/**/*
13
+ - vendor/**/*
14
+ - tmp/**/*
15
+
16
+ Style/StringLiterals:
17
+ EnforcedStyle: double_quotes
18
+
19
+ Style/StringLiteralsInInterpolation:
20
+ EnforcedStyle: double_quotes
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.2.21] - 2026-02-16
2
+ - Fix Ruby 2.7 startup NameError in static_assets redirect schema load path
3
+
1
4
  ## [0.2.21-rc1] - 2026-01-08
2
5
  - Removed Rust `target-cpu=native` to avoid illegal instruction on older CPUs.
3
6
 
data/Cargo.lock CHANGED
@@ -1644,7 +1644,7 @@ checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
1644
1644
 
1645
1645
  [[package]]
1646
1646
  name = "itsi-scheduler"
1647
- version = "0.2.20"
1647
+ version = "0.2.21"
1648
1648
  dependencies = [
1649
1649
  "bytes",
1650
1650
  "derive_more",
@@ -1662,7 +1662,7 @@ dependencies = [
1662
1662
 
1663
1663
  [[package]]
1664
1664
  name = "itsi-server"
1665
- version = "0.2.20"
1665
+ version = "0.2.21"
1666
1666
  dependencies = [
1667
1667
  "argon2",
1668
1668
  "async-channel",
@@ -1933,9 +1933,9 @@ checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94"
1933
1933
 
1934
1934
  [[package]]
1935
1935
  name = "magnus"
1936
- version = "0.7.1"
1936
+ version = "0.8.2"
1937
1937
  source = "registry+https://github.com/rust-lang/crates.io-index"
1938
- checksum = "3d87ae53030f3a22e83879e666cb94e58a7bdf31706878a0ba48752994146dab"
1938
+ checksum = "3b36a5b126bbe97eb0d02d07acfeb327036c6319fd816139a49824a83b7f9012"
1939
1939
  dependencies = [
1940
1940
  "bytes",
1941
1941
  "magnus-macros",
@@ -1946,9 +1946,9 @@ dependencies = [
1946
1946
 
1947
1947
  [[package]]
1948
1948
  name = "magnus-macros"
1949
- version = "0.6.0"
1949
+ version = "0.8.0"
1950
1950
  source = "registry+https://github.com/rust-lang/crates.io-index"
1951
- checksum = "5968c820e2960565f647819f5928a42d6e874551cab9d88d75e3e0660d7f71e3"
1951
+ checksum = "47607461fd8e1513cb4f2076c197d8092d921a1ea75bd08af97398f593751892"
1952
1952
  dependencies = [
1953
1953
  "proc-macro2",
1954
1954
  "quote",
@@ -2581,18 +2581,18 @@ dependencies = [
2581
2581
 
2582
2582
  [[package]]
2583
2583
  name = "rb-sys"
2584
- version = "0.9.111"
2584
+ version = "0.9.124"
2585
2585
  source = "registry+https://github.com/rust-lang/crates.io-index"
2586
- checksum = "becea799ce051c16fb140be80f5e7cf781070f99ca099332383c2b17861249af"
2586
+ checksum = "c85c4188462601e2aa1469def389c17228566f82ea72f137ed096f21591bc489"
2587
2587
  dependencies = [
2588
2588
  "rb-sys-build",
2589
2589
  ]
2590
2590
 
2591
2591
  [[package]]
2592
2592
  name = "rb-sys-build"
2593
- version = "0.9.111"
2593
+ version = "0.9.124"
2594
2594
  source = "registry+https://github.com/rust-lang/crates.io-index"
2595
- checksum = "64691175abc704862f60a9ca8ef06174080cc50615f2bf1d4759f46db18b4d29"
2595
+ checksum = "568068db4102230882e6d4ae8de6632e224ca75fe5970f6e026a04e91ed635d3"
2596
2596
  dependencies = [
2597
2597
  "bindgen",
2598
2598
  "lazy_static",
@@ -2605,9 +2605,9 @@ dependencies = [
2605
2605
 
2606
2606
  [[package]]
2607
2607
  name = "rb-sys-env"
2608
- version = "0.1.2"
2608
+ version = "0.2.3"
2609
2609
  source = "registry+https://github.com/rust-lang/crates.io-index"
2610
- checksum = "a35802679f07360454b418a5d1735c89716bde01d35b1560fc953c1415a0b3bb"
2610
+ checksum = "cca7ad6a7e21e72151d56fe2495a259b5670e204c3adac41ee7ef676ea08117a"
2611
2611
 
2612
2612
  [[package]]
2613
2613
  name = "rcgen"
@@ -2999,9 +2999,9 @@ dependencies = [
2999
2999
 
3000
3000
  [[package]]
3001
3001
  name = "serde_magnus"
3002
- version = "0.9.0"
3002
+ version = "0.11.0"
3003
3003
  source = "registry+https://github.com/rust-lang/crates.io-index"
3004
- checksum = "51b8b945a2dadb221f1c5490cfb411cab6c3821446b8eca50ee07e5a3893ec51"
3004
+ checksum = "8ff64c88ddd26acdcad5a501f18bcc339927b77b69f4a03bfaf2a6fc5ba2ac4b"
3005
3005
  dependencies = [
3006
3006
  "magnus",
3007
3007
  "serde",
data/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM ruby:3.4
2
+
3
+ RUN apt-get update && apt-get install build-essential libclang-dev -y && apt-get clean && rm -rf /var/lib/apt/lists/*
4
+ RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
5
+
6
+ COPY pkg/itsi-server-0.2.21.gem .
7
+ RUN gem install itsi-server-0.2.21.gem
8
+
9
+ CMD ["itsi", "serve"]
@@ -7,7 +7,7 @@ use std::sync::atomic::AtomicPtr;
7
7
 
8
8
  /// No-op cache, which does nothing.
9
9
  /// ```rust
10
- /// # use tokio_rustls_acme::caches::NoCache;
10
+ /// # use itsi_acme::caches::NoCache;
11
11
  /// # type EC = std::io::Error;
12
12
  /// # type EA = EC;
13
13
  /// let no_cache = NoCache::<EC, EA>::new();
@@ -10,9 +10,9 @@ use std::sync::atomic::AtomicPtr;
10
10
  use std::sync::Arc;
11
11
 
12
12
  /// Test cache, which generates certificates for ACME incompatible test environments.
13
- /// ```rust
14
- /// # use tokio_rustls_acme::{AcmeConfig};
15
- /// # use tokio_rustls_acme::caches::{DirCache, TestCache};
13
+ /// ```rust,no_run
14
+ /// # use itsi_acme::AcmeConfig;
15
+ /// # use itsi_acme::caches::{DirCache, TestCache};
16
16
  /// # let test_environment = true;
17
17
  /// let mut config = AcmeConfig::new(["example.com"])
18
18
  /// .cache(DirCache::new("./cache"));
@@ -31,9 +31,9 @@ impl AcmeConfig<Infallible, Infallible> {
31
31
  /// error types will be `Infallible` since the cache cannot return an error. The methods to set
32
32
  /// a cache will change the error types to match those returned by the supplied cache.
33
33
  ///
34
- /// ```rust
35
- /// # use tokio_rustls_acme::AcmeConfig;
36
- /// use tokio_rustls_acme::caches::DirCache;
34
+ /// ```rust,no_run
35
+ /// # use itsi_acme::AcmeConfig;
36
+ /// use itsi_acme::caches::DirCache;
37
37
  /// let config = AcmeConfig::new(["example.com"]).cache(DirCache::new("./rustls_acme_cache"));
38
38
  /// ```
39
39
  ///
@@ -43,9 +43,9 @@ impl AcmeConfig<Infallible, Infallible> {
43
43
  /// An uncached instance of [AcmeConfig] with particular type parameters can be created using
44
44
  /// [NoCache].
45
45
  ///
46
- /// ```rust
47
- /// # use tokio_rustls_acme::AcmeConfig;
48
- /// use tokio_rustls_acme::caches::NoCache;
46
+ /// ```rust,no_run
47
+ /// # use itsi_acme::AcmeConfig;
48
+ /// use itsi_acme::caches::NoCache;
49
49
  /// # type EC = std::io::Error;
50
50
  /// # type EA = EC;
51
51
  /// let config: AcmeConfig<EC, EA> = AcmeConfig::new(["example.com"]).cache(NoCache::new());
@@ -31,7 +31,7 @@
31
31
  //! ```rust,no_run
32
32
  //! use tokio::io::AsyncWriteExt;
33
33
  //! use futures::StreamExt;
34
- //! use tokio_rustls_acme::{AcmeConfig, caches::DirCache};
34
+ //! use itsi_acme::{AcmeConfig, caches::DirCache};
35
35
  //! use tokio_stream::wrappers::TcpListenerStream;
36
36
  //!
37
37
  //! #[tokio::main]
@@ -5,7 +5,7 @@ edition = "2021"
5
5
 
6
6
  [dependencies]
7
7
  thiserror = "2.0.11"
8
- magnus = { version = "0.7.1" }
8
+ magnus = { version = "0.8.2" }
9
9
  rcgen = "0.13.2"
10
10
  nix = "0.29.0"
11
11
  httparse = "1.10.1"
@@ -1,9 +1,6 @@
1
1
  pub use anyhow::Context;
2
2
  use magnus::Error as MagnusError;
3
- use magnus::{
4
- error::ErrorType,
5
- exception::{self, arg_error, standard_error},
6
- };
3
+ use magnus::{error::ErrorType, Ruby};
7
4
  use thiserror::Error;
8
5
 
9
6
  pub static CLIENT_CONNECTION_CLOSED: &str = "Client disconnected";
@@ -73,7 +70,10 @@ pub trait IntoMagnusError {
73
70
 
74
71
  impl<T: std::error::Error> IntoMagnusError for T {
75
72
  fn into_magnus_error(self) -> MagnusError {
76
- MagnusError::new(standard_error(), self.to_string())
73
+ MagnusError::new(
74
+ Ruby::get().unwrap().exception_standard_error(),
75
+ self.to_string(),
76
+ )
77
77
  }
78
78
  }
79
79
 
@@ -92,17 +92,34 @@ impl From<String> for ItsiError {
92
92
  impl From<ItsiError> for magnus::Error {
93
93
  fn from(err: ItsiError) -> Self {
94
94
  match err {
95
- ItsiError::InvalidInput(msg) => magnus::Error::new(arg_error(), msg),
96
- ItsiError::InternalServerError(msg) => magnus::Error::new(standard_error(), msg),
97
- ItsiError::InternalError(msg) => magnus::Error::new(standard_error(), msg),
98
- ItsiError::UnsupportedProtocol(msg) => magnus::Error::new(arg_error(), msg),
99
- ItsiError::ArgumentError(msg) => magnus::Error::new(arg_error(), msg),
100
- ItsiError::Jump(msg) => magnus::Error::new(exception::local_jump_error(), msg),
101
- ItsiError::ClientConnectionClosed => {
102
- magnus::Error::new(exception::eof_error(), CLIENT_CONNECTION_CLOSED)
95
+ ItsiError::InvalidInput(msg) => {
96
+ magnus::Error::new(Ruby::get().unwrap().exception_arg_error(), msg)
97
+ }
98
+ ItsiError::InternalServerError(msg) => {
99
+ magnus::Error::new(Ruby::get().unwrap().exception_standard_error(), msg)
100
+ }
101
+ ItsiError::InternalError(msg) => {
102
+ magnus::Error::new(Ruby::get().unwrap().exception_standard_error(), msg)
103
+ }
104
+ ItsiError::UnsupportedProtocol(msg) => {
105
+ magnus::Error::new(Ruby::get().unwrap().exception_arg_error(), msg)
106
+ }
107
+ ItsiError::ArgumentError(msg) => {
108
+ magnus::Error::new(Ruby::get().unwrap().exception_arg_error(), msg)
109
+ }
110
+ ItsiError::Jump(msg) => {
111
+ magnus::Error::new(Ruby::get().unwrap().exception_local_jump_error(), msg)
112
+ }
113
+ ItsiError::ClientConnectionClosed => magnus::Error::new(
114
+ Ruby::get().unwrap().exception_eof_error(),
115
+ CLIENT_CONNECTION_CLOSED,
116
+ ),
117
+ ItsiError::Break => {
118
+ magnus::Error::new(Ruby::get().unwrap().exception_interrupt(), "Break")
119
+ }
120
+ ItsiError::Pass => {
121
+ magnus::Error::new(Ruby::get().unwrap().exception_interrupt(), "Pass")
103
122
  }
104
- ItsiError::Break => magnus::Error::new(exception::interrupt(), "Break"),
105
- ItsiError::Pass => magnus::Error::new(exception::interrupt(), "Pass"),
106
123
  ItsiError::Io(err) => err.into_magnus_error(),
107
124
  ItsiError::Rcgen(err) => err.into_magnus_error(),
108
125
  ItsiError::HttpParse(err) => err.into_magnus_error(),
@@ -5,7 +5,7 @@ edition = "2021"
5
5
 
6
6
  [dependencies]
7
7
  cfg-if = "1.0.0"
8
- magnus = { version = "0.7.1", features = ["rb-sys", "bytes"] }
8
+ magnus = { version = "0.8.2", features = ["rb-sys", "bytes"] }
9
9
  nix = "0.29.0"
10
- rb-sys = "0.9.105"
10
+ rb-sys = "0.9.117"
11
11
  serde = "1.0.219"
@@ -1,7 +1,7 @@
1
- use magnus::IntoValue;
2
1
  use magnus::rb_sys::AsRawValue;
3
2
  use magnus::value::BoxValue;
4
- use magnus::{Ruby, Value, value::ReprValue};
3
+ use magnus::IntoValue;
4
+ use magnus::{value::ReprValue, Ruby, Value};
5
5
  use std::fmt::{self, Debug, Formatter};
6
6
  use std::ops::Deref;
7
7
 
@@ -66,7 +66,7 @@ where
66
66
  T: ReprValue,
67
67
  {
68
68
  fn into_value_with(self, _: &Ruby) -> Value {
69
- self.0.into_value()
69
+ self.0.into_value_with(&magnus::Ruby::get().unwrap())
70
70
  }
71
71
  }
72
72
 
@@ -116,7 +116,7 @@ impl Deref for HeapVal {
116
116
 
117
117
  impl IntoValue for HeapVal {
118
118
  fn into_value_with(self, _: &Ruby) -> Value {
119
- self.0.into_value()
119
+ self.0.into_value_with(&magnus::Ruby::get().unwrap())
120
120
  }
121
121
  }
122
122
 
@@ -1,14 +1,14 @@
1
1
  use std::{ffi::c_int, os::raw::c_void, ptr::null_mut};
2
2
 
3
3
  use magnus::{
4
- ArgList, RArray, Ruby, Thread, Value,
5
4
  block::Proc,
6
- rb_sys::{AsRawId, FromRawValue, protect},
5
+ rb_sys::{protect, AsRawId, FromRawValue},
7
6
  value::{IntoId, LazyId, ReprValue},
7
+ ArgList, RArray, Ruby, Thread, Value,
8
8
  };
9
9
  use rb_sys::{
10
- VALUE, rb_funcallv, rb_thread_call_with_gvl, rb_thread_call_without_gvl, rb_thread_create,
11
- rb_thread_schedule, rb_thread_wakeup,
10
+ rb_funcallv, rb_thread_call_with_gvl, rb_thread_call_without_gvl, rb_thread_create,
11
+ rb_thread_schedule, rb_thread_wakeup, VALUE,
12
12
  };
13
13
 
14
14
  mod heap_value;
@@ -182,7 +182,11 @@ pub fn terminate_non_fork_safe_threads() {
182
182
  && !v_thread
183
183
  .funcall::<_, _, bool>(*ID_THREAD_VARIABLE_GET, (ruby.sym_new("fork_safe"),))
184
184
  .unwrap_or(false);
185
- if non_fork_safe { Some(v_thread) } else { None }
185
+ if non_fork_safe {
186
+ Some(v_thread)
187
+ } else {
188
+ None
189
+ }
186
190
  })
187
191
  .collect::<Vec<_>>();
188
192
 
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-scheduler"
3
- version = "0.2.21-rc1"
3
+ version = "0.2.21"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -10,7 +10,7 @@ publish = false
10
10
  crate-type = ["cdylib"]
11
11
 
12
12
  [dependencies]
13
- magnus = { version = "0.7.1", features = ["rb-sys", "bytes"] }
13
+ magnus = { version = "0.8.2", features = ["rb-sys", "bytes"] }
14
14
  derive_more = { version = "2.0.1", features = ["debug"] }
15
15
  itsi_tracing = { path = "../itsi_tracing" }
16
16
  itsi_rb_helpers = { path = "../itsi_rb_helpers" }
@@ -18,7 +18,7 @@ itsi_error = { path = "../itsi_error" }
18
18
  itsi_instrument_entry = { path = "../itsi_instrument_entry" }
19
19
  parking_lot = "0.12.3"
20
20
  mio = { version = "1.0.3", features = ["os-poll", "os-ext"] }
21
- rb-sys = "0.9.105"
21
+ rb-sys = "0.9.117"
22
22
  bytes = "1.10.1"
23
23
  nix = "0.29.0"
24
24
  tracing = "0.1.41"
@@ -68,7 +68,7 @@ impl ItsiScheduler {
68
68
  pub fn wake(&self) -> MagnusResult<()> {
69
69
  self.waker.lock().wake().map_err(|_| {
70
70
  magnus::Error::new(
71
- magnus::exception::standard_error(),
71
+ magnus::Ruby::get().unwrap().exception_standard_error(),
72
72
  "Failed to wake the scheduler",
73
73
  )
74
74
  })?;
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "itsi-server"
3
- version = "0.2.21-rc1"
3
+ version = "0.2.21"
4
4
  edition = "2021"
5
5
  authors = ["Wouter Coppieters <wc@pico.net.nz>"]
6
6
  license = "MIT"
@@ -42,7 +42,7 @@ itsi_rb_helpers = { path = "../itsi_rb_helpers" }
42
42
  itsi_tracing = { path = "../itsi_tracing" }
43
43
  itsi_acme = { path = "../itsi_acme" }
44
44
  jsonwebtoken = "9.3.1"
45
- magnus = { version = "0.7.1", features = ["bytes", "rb-sys"] }
45
+ magnus = { version = "0.8.2", features = ["bytes", "rb-sys"] }
46
46
  notify = { version = "8.0.0" }
47
47
  nix = { version = "0.29.0", features = [
48
48
  "socket",
@@ -72,7 +72,7 @@ rustls = "0.23.23"
72
72
  rustls-pemfile = "2.2.0"
73
73
  serde = "1.0.219"
74
74
  serde_json = "1.0.140"
75
- serde_magnus = "0.9.0"
75
+ serde_magnus = "0.11.0"
76
76
  sha2 = "0.10.8"
77
77
  socket2 = "0.5.8"
78
78
  sysinfo = "0.33.1"
@@ -7,7 +7,7 @@ pub mod ruby_types;
7
7
  pub mod server;
8
8
  pub mod services;
9
9
 
10
- use magnus::{error::Result, function, method, Module, Object, Ruby};
10
+ use magnus::{error::Result, function, method, Class, Module, Object, Ruby};
11
11
  use prelude::*;
12
12
  use ruby_types::{
13
13
  itsi_body_proxy::ItsiBodyProxy, itsi_grpc_call::ItsiGrpcCall,
@@ -36,7 +36,8 @@ fn init(ruby: &Ruby) -> Result<()> {
36
36
  )?;
37
37
 
38
38
  let server = ruby.get_inner(&ITSI_SERVER);
39
- server.define_singleton_method("new", function!(ItsiServer::new, 3))?;
39
+ server.define_alloc_func::<ItsiServer>();
40
+ server.define_method("initialize", method!(ItsiServer::initialize, 3))?;
40
41
  server.define_singleton_method("reset_signal_handlers", function!(reset_signal_handlers, 0))?;
41
42
  server.define_method("start", method!(ItsiServer::start, 0))?;
42
43
  server.define_method("stop", method!(ItsiServer::stop, 0))?;
@@ -50,14 +50,21 @@ impl BigBytes {
50
50
  if bytes.is_empty() {
51
51
  None
52
52
  } else {
53
- Some(bytes.into_value())
53
+ Some(bytes.into_value_with(&magnus::Ruby::get().unwrap()))
54
54
  }
55
55
  }
56
56
  BigBytes::OnDisk(path) => {
57
57
  let ruby = Ruby::get().unwrap();
58
58
  let rarray = ruby.ary_new();
59
- rarray.push(path.path().to_str().unwrap().into_value()).ok();
60
- Some(rarray.into_value())
59
+ rarray
60
+ .push(
61
+ path.path()
62
+ .to_str()
63
+ .unwrap()
64
+ .into_value_with(&magnus::Ruby::get().unwrap()),
65
+ )
66
+ .ok();
67
+ Some(rarray.into_value_with(&magnus::Ruby::get().unwrap()))
61
68
  }
62
69
  }
63
70
  }
@@ -32,7 +32,9 @@ impl ItsiBody {
32
32
  pub fn into_value(&self) -> Option<Value> {
33
33
  match self {
34
34
  ItsiBody::Buffered(bytes) => bytes.as_value(),
35
- ItsiBody::Stream(proxy) => Some(proxy.clone().into_value()),
35
+ ItsiBody::Stream(proxy) => {
36
+ Some(proxy.clone().into_value_with(&magnus::Ruby::get().unwrap()))
37
+ }
36
38
  ItsiBody::Empty => None,
37
39
  }
38
40
  }
@@ -54,7 +56,7 @@ impl ItsiBodyProxy {
54
56
  if let Some(chunk) = block_on(stream.next()) {
55
57
  let chunk = chunk.map_err(|err| {
56
58
  magnus::Error::new(
57
- magnus::exception::standard_error(),
59
+ magnus::Ruby::get().unwrap().exception_standard_error(),
58
60
  format!("Error reading body {:?}", err),
59
61
  )
60
62
  })?;
@@ -86,7 +88,7 @@ impl ItsiBodyProxy {
86
88
  if let Some(chunk) = block_on(stream.next()) {
87
89
  let chunk = chunk.map_err(|err| {
88
90
  magnus::Error::new(
89
- magnus::exception::standard_error(),
91
+ magnus::Ruby::get().unwrap().exception_standard_error(),
90
92
  format!("Error reading body {:?}", err),
91
93
  )
92
94
  })?;
@@ -97,7 +99,9 @@ impl ItsiBodyProxy {
97
99
  break;
98
100
  }
99
101
  }
100
- let output_string = buffer.take().unwrap_or(RString::buf_new(buf.len()));
102
+ let output_string = buffer
103
+ .take()
104
+ .unwrap_or(magnus::Ruby::get().unwrap().str_buf_new(buf.len()));
101
105
  output_string.cat(buf.clone());
102
106
  buf.clear();
103
107
  Ok(Some(output_string))
@@ -111,7 +115,7 @@ impl ItsiBodyProxy {
111
115
  while let Some(chunk) = block_on(stream.next()) {
112
116
  let chunk = chunk.map_err(|err| {
113
117
  magnus::Error::new(
114
- magnus::exception::standard_error(),
118
+ magnus::Ruby::get().unwrap().exception_standard_error(),
115
119
  format!("Error reading body {:?}", err),
116
120
  )
117
121
  })?;
@@ -133,7 +137,7 @@ impl ItsiBodyProxy {
133
137
  fn verify_open(&self) -> MagnusResult<()> {
134
138
  if self.closed.load(atomic::Ordering::SeqCst) {
135
139
  return Err(magnus::Error::new(
136
- magnus::exception::standard_error(),
140
+ magnus::Ruby::get().unwrap().exception_standard_error(),
137
141
  "Body stream is closed",
138
142
  ));
139
143
  }
@@ -64,7 +64,9 @@ impl ItsiGrpcCall {
64
64
  let snake_case_method_name = METHOD_NAME_REGEX
65
65
  .replace_all(method_name, "${1}_${2}")
66
66
  .to_lowercase();
67
- Ok(Symbol::new(snake_case_method_name))
67
+ Ok(magnus::Ruby::get()
68
+ .unwrap()
69
+ .to_symbol(snake_case_method_name))
68
70
  }
69
71
 
70
72
  pub fn stream(&self) -> MagnusResult<ItsiGrpcResponseStream> {
@@ -205,7 +207,7 @@ impl ItsiGrpcCall {
205
207
  })
206
208
  .map_err(|e: std::io::Error| {
207
209
  Error::new(
208
- magnus::exception::standard_error(),
210
+ magnus::Ruby::get().unwrap().exception_standard_error(),
209
211
  format!("deflate decompression failed: {}", e),
210
212
  )
211
213
  })?;
@@ -224,7 +226,7 @@ impl ItsiGrpcCall {
224
226
  })
225
227
  .map_err(|e: std::io::Error| {
226
228
  Error::new(
227
- magnus::exception::standard_error(),
229
+ magnus::Ruby::get().unwrap().exception_standard_error(),
228
230
  format!("gzip decompression failed: {}", e),
229
231
  )
230
232
  })?;
@@ -243,7 +245,7 @@ impl ItsiGrpcCall {
243
245
  })
244
246
  .map_err(|e| {
245
247
  Error::new(
246
- magnus::exception::standard_error(),
248
+ magnus::Ruby::get().unwrap().exception_standard_error(),
247
249
  format!("gzip compression failed: {e}"),
248
250
  )
249
251
  })?;
@@ -262,7 +264,7 @@ impl ItsiGrpcCall {
262
264
  })
263
265
  .map_err(|e| {
264
266
  Error::new(
265
- magnus::exception::standard_error(),
267
+ magnus::Ruby::get().unwrap().exception_standard_error(),
266
268
  format!("deflate compression failed: {e}"),
267
269
  )
268
270
  })?;
@@ -59,7 +59,7 @@ impl ItsiGrpcResponseStreamInner {
59
59
  .blocking_send(ByteFrame::Data(bytes))
60
60
  .map_err(|err| {
61
61
  magnus::Error::new(
62
- magnus::exception::io_error(),
62
+ magnus::Ruby::get().unwrap().exception_io_error(),
63
63
  format!("Trying to write to closed stream: {:?}", err),
64
64
  )
65
65
  })?;
@@ -80,7 +80,7 @@ impl ItsiGrpcResponseStreamInner {
80
80
  let trailer_tx = std::mem::replace(&mut self.trailer_tx, oneshot::channel().0);
81
81
  trailer_tx.send(header_map).map_err(|err| {
82
82
  magnus::Error::new(
83
- magnus::exception::standard_error(),
83
+ magnus::Ruby::get().unwrap().exception_standard_error(),
84
84
  format!("Error sending trailers {:?}", err),
85
85
  )
86
86
  })?;
@@ -6,9 +6,9 @@ use itsi_error::CLIENT_CONNECTION_CLOSED;
6
6
  use itsi_rb_helpers::{funcall_no_ret, print_rb_backtrace, HeapValue};
7
7
  use itsi_tracing::debug;
8
8
  use magnus::{
9
- block::{yield_values, Proc},
9
+ block::Proc,
10
10
  error::{ErrorType, Result as MagnusResult},
11
- Error, IntoValue, RHash, Symbol,
11
+ Error, IntoValue, RHash,
12
12
  };
13
13
  use magnus::{
14
14
  value::{LazyId, ReprValue},
@@ -110,20 +110,20 @@ impl ItsiHttpRequest {
110
110
  // when building against Ruby < 3.2...
111
111
  #[cfg(not(ruby_gte_3_2))]
112
112
  {
113
- RHash::new()
113
+ magnus::Ruby::get().unwrap().hash_new()
114
114
  }
115
115
  };
116
116
  for (i, group_name) in re.capture_names().enumerate().skip(1) {
117
117
  if let Some(name) = group_name {
118
118
  if let Some(m) = caps.get(i) {
119
119
  // Insert into the hash: key is the group name, value is the match.
120
- params.aset(Symbol::new(name), m.as_str())?;
120
+ params.aset(magnus::Ruby::get().unwrap().to_symbol(name), m.as_str())?;
121
121
  }
122
122
  }
123
123
  }
124
124
  Ok(params)
125
125
  } else {
126
- Ok(RHash::new())
126
+ Ok(magnus::Ruby::get().unwrap().hash_new())
127
127
  }
128
128
  }
129
129
 
@@ -201,7 +201,7 @@ impl ItsiHttpRequest {
201
201
  }
202
202
  },
203
203
  Ok(_) => match receiver.await {
204
- Ok(ResponseFrame::HttpResponse(response)) => Ok(response),
204
+ Ok(ResponseFrame::HttpResponse(response)) => Ok(*response),
205
205
  Ok(ResponseFrame::HijackedResponse(response)) => {
206
206
  match response.process_hijacked_response().await {
207
207
  Ok(result) => Ok(result),
@@ -354,7 +354,10 @@ impl ItsiHttpRequest {
354
354
 
355
355
  pub(crate) fn each_header(&self) -> MagnusResult<()> {
356
356
  self.parts.headers.iter().for_each(|(hn, hv)| {
357
- yield_values::<_, Value>((hn.as_str(), hv.to_str().unwrap_or(""))).ok();
357
+ magnus::Ruby::get()
358
+ .unwrap()
359
+ .yield_values::<_, Value>((hn.as_str(), hv.to_str().unwrap_or("")))
360
+ .ok();
358
361
  });
359
362
  Ok(())
360
363
  }