Skip to content

refactor: introduce statefull sub-modules #44

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025

Conversation

JanZachmann
Copy link
Contributor

@JanZachmann JanZachmann commented May 21, 2025

  • introduced statefull sub-modules Api, OmnectDeviceServiceClient and SocketClient
  • refactored startup sequence
  • changed to rust edition 2024

@JanZachmann JanZachmann force-pushed the refactor branch 11 times, most recently from 4aca0f3 to 2cf243d Compare May 26, 2025 07:19
@JanZachmann JanZachmann changed the title WIP:refactor: big refactoring refactor: big refactoring May 26, 2025
@JanZachmann JanZachmann changed the title refactor: big refactoring refactor: introduce statefull sub-modules May 26, 2025
src/common.rs Outdated
Comment on lines 24 to 35
let port = var("CENTRIFUGO_HTTP_SERVER_PORT").unwrap_or({
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { set_var("CENTRIFUGO_HTTP_SERVER_PORT", "8000") };
"8000".to_string()
});
let client_token = Uuid::new_v4().to_string();
let api_key = Uuid::new_v4().to_string();

// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { set_var("CENTRIFUGO_CLIENT_TOKEN_HMAC_SECRET_KEY", &client_token) };
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe { set_var("CENTRIFUGO_HTTP_API_KEY", &api_key) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we should explicitly launch centrifugo with the environment variables taken from CENTRIFUGO_CONFIG. Then we don't have to poison the environment of the running parent process (which could lead to complexities in testing down the line).

src/main.rs Outdated
Comment on lines 286 to 226
std::env::set_var("CENTRIFUGO_HTTP_SERVER_TLS_CERT_PEM", cert_path!());
std::env::set_var("CENTRIFUGO_HTTP_SERVER_TLS_KEY_PEM", key_path!());
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe {
std::env::set_var(
"CENTRIFUGO_HTTP_SERVER_TLS_CERT_PEM",
certificate::cert_path(),
)
};
// TODO: Audit that the environment access only happens in single-threaded code.
unsafe {
std::env::set_var(
"CENTRIFUGO_HTTP_SERVER_TLS_KEY_PEM",
certificate::key_path(),
)
};

let mut centrifugo =
Command::new(std::fs::canonicalize("centrifugo").expect("centrifugo not found"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO we should launch Command with env (https://doc.rust-lang.org/std/process/struct.Command.html#method.env), this way the environment of our omnect-ui stays clean, we don't have to use unsafe, and we don't run in sketchy edge cases with threading.

Signed-off-by: Jan Zachmann <[email protected]>
@JanZachmann JanZachmann merged commit fd9c85d into omnect:main May 28, 2025
3 checks passed
JanZachmann added a commit that referenced this pull request May 28, 2025
JanZachmann added a commit that referenced this pull request May 28, 2025
Revert "refactor: introduce statefull sub-modules (#44)"

This reverts commit fd9c85d.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants