-
Notifications
You must be signed in to change notification settings - Fork 257
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
trigger: Decouple Trigger from clap #2864
base: main
Are you sure you want to change the base?
Conversation
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.
In general I'm in favor of reducing the number of dependencies an implementor has to explicitly depend on especially if the implementor doesn't really have a choice.
I do feel though like we've long been on a path of exposing dependencies just when we run into a place where it would be convenient. This doesn't feel particularly disciplined, and I worry that over time we're going to regret some of these decisions.
I'm not necessarily against merging this as is, so I'll approve the PR, but I wanted to voice my concern that I'm not convinced this is the right path forward.
crates/trigger/src/lib.rs
Outdated
use spin_factors_executor::{FactorsExecutorApp, FactorsInstanceBuilder}; | ||
|
||
pub use anyhow; | ||
pub use clap::Parser; |
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.
I don't love making clap
even more a part of the Spin public API, but alas it may be too late...
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.
Another option would be to rename Trigger::CliArgs
to e.g. ::GlobalConfig
and move the Args
constraint to FactorsTriggerCommand ... T::GlobalConfig: Args
(and RuntimeFactorsBuilder
? 🤔)
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.
I like it.
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.
Done; take a look
@@ -4,10 +4,12 @@ pub mod loader; | |||
use std::future::Future; | |||
|
|||
use clap::Args; | |||
use spin_core::Linker; | |||
use spin_factors::RuntimeFactors; | |||
pub use spin_core::Linker; |
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.
I'm surprised by this. I looked at a few of the external triggers, and they don't use Linker
. Is this really necessary?
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.
Its used in the (admittedly optional) Trigger::add_to_linker
signature.
Signed-off-by: Lann Martin <[email protected]>
- Rename `Trigger`'s associated `CliArgs` type to `GlobalConfig` - Move that `clap::Args` bound into `FactorsTriggerCommand` - Fix up related code Signed-off-by: Lann Martin <[email protected]>
Trigger
's associatedCliArgs
type toGlobalConfig
clap::Args
bound intoFactorsTriggerCommand
Also (the original PR):