Skip to content

Conversation

@jvalinsky
Copy link
Contributor

The clippy linting has a rule for too_many_arguments set to a max of 7, my refactored serve func for slingshot has 8 args:

pub async fn serve(
    cache: HybridCache<String, CachedRecord>,
    identity: Identity,
    repo: Repo,
    domain: Option<String>,
    acme_contact: Option<String>,
    certs: Option<PathBuf>,
    shutdown: CancellationToken,
    bind: std::net::SocketAddr,
) -> Result<(), ServerError> {

How do you recommend fixing this?

ServerBuilder::new(api, context, log)
.config(ConfigDropshot {
bind_address: "0.0.0.0:9999".parse().unwrap(),
bind_address: bind,
Copy link
Contributor

Choose a reason for hiding this comment

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

yessss. i love when fixing hacks actually makes code simpler and safer

@uniphil
Copy link
Contributor

uniphil commented Oct 28, 2025

@jvalinsky thank you!!!!

to fix that clippy report you can throw one of these on it

#[allow(clippy::too_many_arguments)]
pub async fn serve(
    cache: HybridCache<String, CachedRecord>,
    ...

eventually it should be refactored to take a config struct or something, but i don't want to spend time on that now because i kind of want to refactor some of the top-level app-running boilerplate into some helpers across the whole repo, which would probably account for that. silencing clippy here is fine :)


a few more fmt things are going to bite you before this passes, but that's the easy part. if you run make check in the project root it should automatically apply most or all of them, and if that doesn't work easily i'm happy to do a quick fixup before merging!

.await
} else {
run(TcpListener::bind("127.0.0.1:3000"), app, shutdown).await
run(TcpListener::bind(bind.to_string()), app, shutdown).await
Copy link
Contributor

Choose a reason for hiding this comment

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

does doing just TcpListener::bind(bind) (without .to_string()) work here?

host[1],
host[2],
host[3]
"metrics server installed! listening on http://{}",
Copy link
Contributor

Choose a reason for hiding this comment

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

clippy is probably yelling at you for not doing

log::info!("metrics server installed! listening on http://{bind_metrics}");

here

host[2],
host[3]
"metrics server installed! listening on http://{}",
bind_metrics
Copy link
Contributor

Choose a reason for hiding this comment

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

...and here

Copy link
Contributor

@uniphil uniphil left a comment

Choose a reason for hiding this comment

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

couple small nits but this is the exact right approach :)

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.

2 participants