Skip to content

Cli refactor #43

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Cli refactor #43

wants to merge 2 commits into from

Conversation

Threated
Copy link
Member

@Threated Threated commented Jun 16, 2025

  • chore: replace once_cell with LazyLock
  • refactor: make transfair a cli with subcommands

bridgehead PR samply/bridgehead#319

ENTRYPOINT [ "/usr/local/bin/samply" ]
CMD [ "dic" ]
Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if we actually want to include this CMD instruction here it preserves backwards compatibility with the no ttp usecase but its probably not worth it as the other ttp use cases have require the linked bridgehead PR anyway

Comment on lines +25 to +26
pub static CLIENT: LazyLock<&Client> = LazyLock::new(|| INNER_CLIENT.get().expect("Client should be initialized before use"));
static INNER_CLIENT: OnceLock<Client> = OnceLock::new();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is rather hacky but quite clever I think because we don't have the whole config as a global anymore but really want to share a client everywhere that is configured correctly and dont want to write .get().unwrap() everywhere we just do it once here and store the ref to the finished client.

Comment on lines +46 to +51
#[derive(Debug, Clone)]
pub struct DicAppState {
pub database_pool: Pool<Sqlite>,
pub config: &'static DicConfig,
pub request_server: &'static FhirServer,
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Again because config is not globaly anymore we need to share more data with axum. So we include everything in this struct

@Threated
Copy link
Member Author

Subcommand name of dic is of course debatable its just the first one that came to my mind but maybe its a bit to generic

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.

1 participant