Logo

dev-resources.site

for different kinds of informations.

Task scheduler interval in the rust

Published at
10/17/2023
Categories
rust
tasks
job
Author
raminfp
Categories
3 categories in total
rust
open
tasks
open
job
open
Author
7 person written this
raminfp
open
Task scheduler interval in the rust

Tasks Schedule

Task scheduler in code that runs a function at specific intervals,

Example

use task_schedule::{schedule_tasks, ScheduledTask};
use task_schedule::utils::*;

fn task_without_params() {
    println!("I am running sec task.");
}

fn task_min() {
    println!("I am running min task.");
}

fn task_hours() {
    println!("I am running hours task.");
}

fn task_days() {
    println!("I am running days task.");
}

fn task_week() {
    println!("I am running week task.");
}

fn task_with_params(a: i32, b: &str) {
    println!("Task with parameters: a = {}, b = {}", a, b);
}

fn task_with_params_wrapper() {
    task_with_params(42, "Hello");
}


fn main() {
    let mut tasks = vec![
        ScheduledTask::new(convert_duration_to_seconds(1), task_without_params as fn()),
        ScheduledTask::new(convert_duration_to_seconds(2), task_with_params_wrapper as fn()),
        ScheduledTask::new(convert_duration_to_minutes(1), task_min as fn()),
        ScheduledTask::new(convert_duration_to_hours(1), task_hours as fn()),
        ScheduledTask::new(convert_duration_to_days(1), task_days as fn()),
        ScheduledTask::new(convert_duration_to_weeks(1), task_week as fn()),
    ];

    schedule_tasks(&mut tasks);
}
Enter fullscreen mode Exit fullscreen mode

Output

I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Task with parameters: a = 42, b = Hello
I am running sec task.
I am running sec task.
Enter fullscreen mode Exit fullscreen mode

Github : https://github.com/raminfp/schedule-tasks

tasks Article's
30 articles in total
Favicon
Diving into the Use of Use Cases in JIRA🌟
Favicon
Python Day- 14 Looping-Exercises and tasks
Favicon
Python - Level : 2 Tasks
Favicon
Python - Level : 1 Tasks
Favicon
Operators, Conditionals& Inputs Tasks
Favicon
Track your Google Tasks to-do list in Google Sheets with webMethods.io Integration
Favicon
Streamlining Asynchronous Tasks in Django with Django Tasks Scheduler
Favicon
Navigating the Landscape of Tasks APIs and Integration Challenges
Favicon
Task scheduler interval in the rust
Favicon
Scheduling tasks in Golang with atomicgo
Favicon
Priority and Severity of tasks and bugs
Favicon
Command Prompt - Dealing with Tasks
Favicon
Cron Jobs - Automating tasks on Linux
Favicon
Celery & Redis : exécution de tâches en différé / asynchrones
Favicon
How to Practice Root Cause Analysis in tech problems
Favicon
Prioritizing Tasks - Time Management
Favicon
How I make myself productive with Google
Favicon
VSCode tasks and parsing your custom output for problems
Favicon
Creating containers for Django apps with periodical tasks
Favicon
Top 5 Work Habits to Boost Productivity
Favicon
Calendar Heroes: Michele Wiedemer, Manager of Customer Education at Snyk
Favicon
Calendar Heroes: Rohini Pandhi, Product @ Square
Favicon
A way to not lose track of what you've done at work
Favicon
C# - The For Loop Paradox
Favicon
Plan like a Pro with Automatic Scheduling in Taskjuggler
Favicon
Brief intro on Celery
Favicon
My approach to planning personal projects, tasks, and goals with examples
Favicon
Rails Tasks: exporting database models to a CSV.
Favicon
VSCode Tasks - Specifying custom PATH
Favicon
Using a text editor for task tracking

Featured ones: