Skip to content
Snippets Groups Projects
  1. Apr 18, 2024
    • Quentin Gliech's avatar
      Helpers to transform Twisted requests to Rust http Requests/Responses (#17081) · 09f0957b
      Quentin Gliech authored
      This adds functions to transform a Twisted request to the
      `http::Request`, and then to send back an `http::Response` through it.
      
      It also imports the SynapseError exception so that we can throw that
      from Rust code directly
      
      Example usage of this would be:
      
      ```rust
      use crate::http::{http_request_from_twisted, http_response_to_twisted, HeaderMapPyExt};
      
      fn handler(twisted_request: &PyAny) -> PyResult<()> {
          let request = http_request_from_twisted(twisted_request)?;
      
          let ua: headers::UserAgent = request.headers().typed_get_required()?;
      
          if whatever {
              return Err((crate::errors::SynapseError::new(
                  StatusCode::UNAUTHORIZED,
                  "Whatever".to_owned
                  "M_UNAUTHORIZED",
                  None,
                  None,
              )));
          }
      
          let response = Response::new("hello".as_bytes());
          http_response_to_twisted(twisted_request, response)?;
      
          Ok(())
      }
      ```
      09f0957b
  2. Jan 08, 2024
    • Erik Johnston's avatar
      Port `EventInternalMetadata` class to Rust (#16782) · 5d3850b0
      Erik Johnston authored
      
      There are a couple of things we need to be careful of here:
      
      1. The current python code does no validation when loading from the DB,
      so we need to be careful to ignore such errors (at least on jki.re there
      are some old events with internal metadata fields of the wrong type).
      2. We want to be memory efficient, as we often have many hundreds of
      thousands of events in the cache at a time.
      
      ---------
      
      Co-authored-by: default avatarQuentin Gliech <quenting@element.io>
      5d3850b0
  3. Sep 26, 2023
  4. Feb 03, 2023
    • Patrick Cloke's avatar
      Reload the pyo3-log config when the Python logging config changes. (#14976) · 8e9fc28c
      Patrick Cloke authored
      Since pyo3-log is initialized very early in the Python start-up
      it caches the state of the loggers before they're fully initialized
      (and thus are essentially disabled). Whenever we reload the
      logging configuration we now also tell pyo3-log to discard
      any cached logging configuration it has; it will refetch the
      current logging configuration from Python at the next point
      it logs.
      
      This fixes Rust log lines not appearing in the homeserver logs.
      8e9fc28c
  5. Sep 20, 2022
  6. Sep 12, 2022
  7. Sep 09, 2022
  8. Sep 06, 2022
Loading