Categorygithub.com/itrepablik/isked
modulepackage
1.0.3
Repository: https://github.com/itrepablik/isked.git
Documentation: pkg.go.dev

# README

isked The isked package is the simplified and easy to use task schedulers for your Go projects.

Installation

go get -u github.com/itrepablik/isked

Usage

These are some of the examples on how you can use isked package.

package main

import (
	"fmt"

	"github.com/itrepablik/isked"
)

func myFunc1() {
	fmt.Println("calling from myFunc1(): ")
}

func myFunc2(s string) func() {
	return func() {
		fmt.Println("calling from myFunc4(): ", s)
	}
}

func main() {
	// Frequently methods:
	isked.TaskName("Task 1").Frequently().Seconds(7).ExecFunc(myFunc2("hello world")).AddTask()
	isked.TaskName("Task 2").Frequently().Minutes(1).ExecFunc(myFunc1).AddTask()
	isked.TaskName("Task 3").Frequently().Hours(2).ExecFunc(myFunc1).AddTask()

	// Daily methods:
	// The start date is tomorrow's date, not, today's date
	isked.TaskName("Task 4").Daily().At("14:18").ExecFunc(myFunc1).AddTask()

	// Weekly methods:
	isked.TaskName("Task 6").Weekly().Tuesday().At("17:30").ExecFunc(myFunc1).AddTask()

	// Monthly methods: 0 - means 'last day' of each month
	isked.TaskName("Task 7").Monthly().Every(0).At("09:30").ExecFunc(myFunc1).AddTask()
	isked.TaskName("Task 8").Monthly().Every(2).At("10:30").ExecFunc(myFunc1).AddTask()

	isked.Run()
}

Subscribe to Maharlikans Code Youtube Channel:

Please consider subscribing to my Youtube Channel to recognize my work on this package. Thank you for your support! https://www.youtube.com/channel/UCdAVUmldU9Jn2VntuQChHqQ/

License

Code is distributed under MIT license, feel free to use it in your proprietary projects as well.

# Functions

Run executes the task scheduler's individual task item.
SetLogDT customizes the DateTime logging format to be used for each logs.
TaskName method is the run type option of each task that execute once only.

# Variables

ChannelTS is the channel to be used during cancellation of all the tasks that are currently running, this is useful when reloading some config variables to get the latest values and reload the task scheduler.
DTFormat is the standard DateTime format to be used for logging information.
TK initialize the 'Tasks' struct with an empty values.
TS initialize the 'TaskScheduler' struct with an empty values.

# Structs

LogDTFormat is the DateTime format for each logs.
Tasks is the individual task item to be executed.
TaskScheduler is the task scheduler's format.

# Type aliases

FuncToExec is the function that needs to be executed as parameter.