Skip to content

Commit

Permalink
build: updated simple example
Browse files Browse the repository at this point in the history
  • Loading branch information
simbleau committed Oct 20, 2023
1 parent a6540f1 commit e8958e9
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ impl AuthProvider for MyAuthProvider {
access_token: "123".to_string(),
refresh_token: "456".to_string(),
access_expires: bevy_key_rotation::Instant::now()
+ Duration::from_secs(30),
+ Duration::from_secs(10),
refresh_expires: bevy_key_rotation::Instant::now()
+ Duration::from_secs(60),
+ Duration::from_secs(20),
})
}
async fn refresh(
Expand All @@ -38,7 +38,7 @@ impl AuthProvider for MyAuthProvider {
password: keystore.password,
access_token: "789".to_string(),
refresh_token: keystore.refresh_token,
access_expires: keystore.access_expires + Duration::from_secs(30),
access_expires: keystore.access_expires + Duration::from_secs(5),
refresh_expires: keystore.refresh_expires,
})
}
Expand All @@ -53,29 +53,27 @@ fn status_check(
let update_every = update_every
.get_or_insert(Timer::from_seconds(2.0, TimerMode::Repeating));
update_every.tick(time.delta());
if !update_every.just_finished() {
if !update_every.finished() {
return;
}
update_every.reset();

// Log current access token
log::info!("{:?}", *keystore);
}

pub fn main() {
App::new()
.add_plugins(MinimalPlugins)
.add_plugins(LogPlugin::default())
.add_plugins((MinimalPlugins, LogPlugin::default()))
.add_plugins(KeyRotationPlugin {
username: "username".to_string(),
password: "password".to_string(),
rotation_settings: KeyRotationSettings {
access_valid_time: bevy_key_rotation::Duration::from_secs(5),
refresh_valid_time: bevy_key_rotation::Duration::from_secs(10),
rotation_timeout: bevy_key_rotation::Duration::from_secs(1),
rotation_timeout: bevy_key_rotation::Duration::MAX, // no timeout
rotation_check_interval: bevy_key_rotation::Duration::from_secs(
1,
),
rotate_before: bevy_key_rotation::Duration::from_secs(3),
rotate_before: bevy_key_rotation::Duration::from_secs(5),
},
auth_provider: Arc::new(MyAuthProvider),
})
Expand Down

0 comments on commit e8958e9

Please sign in to comment.