Feedback required for the following code

So in this repository , I have initialized my aws dynamo db Client using the lazy_static evaluation so that I don't need to reinitialize it everytime it is being call.

And this static value is being called at several locations in my code for DB operations

One problem I see here is if the connection is lost due to some reason .. therefore it is never reinitialized again

is there anything you guys see here which I can improve?

Get rid of global values and don't use lazy_static. :slight_smile:

1 Like

Debug vs compile mode is not a replacement for command line arguments.

Another lazy static rust-TOTP-server/ at 13a357fc9dbd4f51bbab7d27e80f2c9d06c0bdcf · artech-git/rust-TOTP-server · GitHub

Generally, a proper program should take all the input from env/command line very early, parse it, validate it, put it in some struct Opts or something. and then pass it around where it needed. axum - Rust

Using global variables for everything makes the whole thing completely uncomposable, hard to test and debug.

These comment-lines are unnecessary and not idiomatic.

Thanks to using global statics, this code can't handle external input properly, and needs to panic. :confused:

Oh dear. There's barely any code here that is not in a lazy_static. :stuck_out_tongue:

Thanks for your valuable input

but one thing I was not confident in regarding what exactly is wrong if the program panics!
can you please elaborate more to it

one thing I often become indecisive about is what should exactly be inserted in lazy_static evaluation

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.