-
Notifications
You must be signed in to change notification settings - Fork 23
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
removing runtimes #345
removing runtimes #345
Conversation
Deploying with
|
Latest commit: |
87f9a16
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5df0f6da.cw-orchestrator.pages.dev |
Branch Preview URL: | https://solving-runtime.cw-orchestrator.pages.dev |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
cw-orch-daemon/src/sync/builder.rs
Outdated
let rt_handle = self.handle.clone().unwrap_or(RUNTIME.handle().clone()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be unwrap_or_else
so we don't spawn runtime, when only custom used?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the runtime in spawned anyway in the lazy static. But yeah we don't need to get the handle, will add
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I thought lazy_static code only executed when used, sorry
This PR aims at using an existing runtime by default when no runtime is specified in the DaemonBuilder.
This allows removing runtime creation for users.
Removed custom handles in the whole library
Chat-GPT says :
lazy_static is a Rust crate that allows you to create lazy-initialized static variables. This means that the variable is initialized the first time it's accessed and then reused for subsequent accesses. This can be useful for initializing expensive resources once and sharing them across multiple parts of your codebase.
However, when it comes to Tokio runtimes, there are a few considerations:
Given these considerations, it's generally recommended to carefully evaluate whether using lazy_static for Tokio runtimes aligns with the requirements and design of your application. In many cases, it might be preferable to explicitly manage the creation and lifecycle of Tokio runtimes within the scope of your application or library, rather than relying on global state.
If you do decide to use lazy_static with Tokio runtimes, make sure to thoroughly test your code and consider the potential trade-offs in terms of thread safety, resource management, and code maintainability. Additionally, document the usage and constraints of the global Tokio runtime to make it clear for other developers working on the codebase.