/delayed

Primary LanguageGoMIT LicenseMIT

Delayed

A small and simple delayed tasks management library

Go Report Card test status MIT license

Overview

  • No external dependencies
  • Developer friendly

WIP

  • Repeating task every t units
  • Cancellation

Install

go get -u github.com/buraindo/delayed

Usage

package main

import (
	"fmt"
	"time"

	"github.com/buraindo/delayed"
)

func main() {
	m, err := delayed.NewTaskManager(time.Second) // err = nil
	future, err := m.Run(func() (any, error) { // err = nil
		return "hello", nil
	}, 10*time.Second)
	if future.HasError() { // blocks for 10 sec, returns `false` after
		fmt.Printf("error: %v", future.Error())
	}
	fmt.Printf("result: %v", future.Get()) // "hello"
}

License

© buraindo, 2023~time.Now

Released under the MIT License