mongo-lock-async 0.4.0

Distributed mutex locks with MongoDB
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use mongodb::bson::DateTime;
use std::time::{Duration, SystemTime};

#[inline]
pub fn now_and_expires_at(ttl: Duration) -> (DateTime, DateTime) {
    let now = SystemTime::now();
    let expires_at = now + ttl;

    let now = DateTime::from_system_time(now);
    let expires_at = DateTime::from_system_time(expires_at);

    (now, expires_at)
}