Replies: 1 comment
-
That actually seems like a good idea but there are other ways to achieve that, for example by using lazy_static! {
static ref SM: Arc<Mutex<Sm>> = Arc::new(Mutex::new(Sm::init()));
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
i wanner integrate a sdk which connected a service like consul as its client.The sdk should be needed to keep it globally during my application running lifecyle. i prefer to use state to do it ,but i not sure that is a good idea just like below code:
#[launch]
fn rocket() -> _ {
let a = Arc::new(Sm::init());
let sm = Arc::clone(&a);
}
pub struct Sm;
impl Sm {
pub fn init()->impl NamingService{
//.....
}}
thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions