run/stop goroutines/tasks securely, recursively

grunner - run/stop goroutines/tasks securely, recursively.

codecov GoDoc license

s1 := grunner.New()

s1.Defer(func() {
    fmt.Println("s1 stopped 2")
})
s1.Defer(func() {
    fmt.Println("s1 stopped 1")
})

// loop run task until s1 closed.
s1.Loop(func() {
    fmt.Println("s1 run loop task")
    time.Sleep(time.Millisecond*3)
})

// run interval task until s1 closed.
s1.Interval(func() {
    t.Log("s1 run interval task")
}, time.Millisecond)

go func() {
    ticker := time.NewTicker(time.Millisecond*2)
    
    for {
        select {
        case <-s1.C:
            return
        case <-ticker.C:
        	fmt.Println("run ticker task until s1 stopped")
        }
    }
}()

s2 := s1.NewChild()
s2.Defer(func() {
    fmt.Println("s2 stopped")
})

s3 := s2.NewChild()
s3.Defer(func() {
    fmt.Println("s3 stopped")
})

time.Sleep(time.Millisecond * 10)

s1.Stop()

time.Sleep(time.Millisecond * 10)

// s1 run loop task
// s1 run interval task
// s1 run interval task
// run ticker task until s1 stopped
// s1 run interval task
// s1 run loop task
// s1 run interval task
// run ticker task until s1 stopped
// s1 run interval task
// s1 run interval task
// run ticker task until s1 stopped
// s1 run loop task
// s1 run interval task
// s1 run interval task
// run ticker task until s1 stopped
// s1 run interval task
// s1 run loop task
// s1 run interval task
// s1 stopped 1
// s3 stopped
// s2 stopped
// s1 stopped 2
Owner
vogo
very open go ~ a gopher community
vogo
Similar Resources

Prophecis is a one-stop machine learning platform developed by WeBank

Prophecis is a one-stop machine learning platform developed by WeBank

Prophecis is a one-stop machine learning platform developed by WeBank. It integrates multiple open-source machine learning frameworks, has the multi tenant management capability of machine learning compute cluster, and provides full stack container deployment and management services for production environment.

Dec 28, 2022

A simple go program which checks if your websites are running and runs forever (stop it with ctrl+c). It takes two optional arguments, comma separated string with urls and an interval.

uptime A simple go program which checks if your websites are running and runs forever (stop it with ctrl+c). It takes two optional arguments: -interva

Dec 15, 2022

The one-stop shop for most common Go functions

The one-stop shop for most common Go functions

Pandati The one stop shop for most common Go functions Table of contents Pandati The one stop shop for most common Go functions Table of contents Purp

Mar 21, 2022

Simple docker tui to list, start and stop your containers

Simple docker tui to list, start and stop your containers

docker-tui Simple docker tui that lets you list, start and stop your containers. Current status Rough, initial prototype. Build with This tool relies

Dec 2, 2022

Dev Lake is the one-stop solution that integrates, analyzes, and visualizes software development data

Dev Lake is the one-stop solution that integrates, analyzes, and visualizes software development data

Dev Lake is the one-stop solution that integrates, analyzes, and visualizes software development data throughout the software development life cycle (SDLC) for engineering teams.

Dec 30, 2022

Ever wanted to stop a PVC from deleting?

Ever wanted to stop a PVC from deleting?

cnskunkworks-unterminate Oh no! This repository will show you how to unterminate terminating kubernetes resources. It relies on manipulating the data

Nov 18, 2021

Automatically stop GCE instances

Automatically stop GCE instances

auto-stop-gce-instances Architecture How to deploy 1. Deploy Pub/Sub $ gcloud pubsub topics create $PUBSUB_NAME 2. Deploy Cloud Functions $ gcloud fu

Nov 28, 2021

Stop using install.sh! Start using install.yml! DAJE...

Daje - A general purpose Ansible dotfiles installer Configure one time and run everywhere. What is this I've never liked using a big bash script to in

Nov 14, 2022

One-stop shop for english-translated licensed hentai manga and doujins, beat your meat in peace, without any bullshit and drama attached to it.

koushoku Source code of site [redacted] for those who are willing to run their own instance. How it serve and index the archives Archives and its file

Jan 2, 2023

Go copy directory recursively

copy copy copies directories recursively. Example Usage err := Copy("your/directory", "your/directory.copy") Advanced Usage // Options specifies optio

Dec 30, 2022

:runner:runs go generate recursively on a specified path or environment variable and can filter by regex

Package generate Package generate runs go generate recursively on a specified path or environment variable like $GOPATH and can filter by regex Why wo

Sep 27, 2022

A small utility command line application that can recursively download Notion pages

notionbackup A small utility command line application that can recursively download Notion pages. I needed something scriptable that could periodicall

Dec 5, 2022

A API scanner written in GOLANG to scan files recursively and look for API keys and IDs.

GO FIND APIS _____ ____ ______ _____ _ _ _____ _____ _____ _____ / ____|/ __ \ | ____|_ _| \ | | __ \ /\ | __ \_

Oct 25, 2021

Recursively searches a map[string]interface{} structure for another map[string]interface{} structure

msirecurse Recursively searches a map[string]interface{} structure for existence of a map[string]interface{} structure Motivation I wrote this package

Mar 3, 2022

Generate a global index for multiple markdown files recursively

Generate a global index for multiple markdown files recursively

markdown index Markdown-index is a library to help you generate a global index for multiple markdown files recursively in a directory, containing a su

Sep 25, 2022

List all files (recursively) in a directory

typewalk List all files (recursively) in a directory Usage: recursively walk ./typewalk.exe walk --path "C:\\" merge two files ./typewalk.exe merg

Nov 5, 2021

Command-line tool to organize large directories of media files recursively by date, detecting duplicates.

go-media-organizer Command-line tool written in Go to organise all media files in a directory recursively by date, detecting duplicates.

Jan 6, 2022

Simple wrapper around multiple fs.FS instances, recursively merging them together dynamically.

go-layerfs This is a simple wrapper around multiple fs.FS instances, recursively merging them together dynamically. If you have two directories, of wh

Aug 9, 2022

recursively list secrets from Vaults KV2 engine

recursively list secrets from Vaults KV2 engine

vkv recursively list secrets from Vaults KV2 engine Installation Find the corresponding binaries, .rpm and .deb packages in the release section. Authe

Dec 29, 2022
Concurrent task runner, developer's routine tasks automation toolkit. Simple modern alternative to GNU Make 🧰
Concurrent task runner, developer's routine tasks automation toolkit. Simple modern alternative to GNU Make 🧰

taskctl - concurrent task runner, developer's routine tasks automation toolkit Simple modern alternative to GNU Make. taskctl is concurrent task runne

Dec 14, 2022
A small utility that aims to automate and simplify some tasks related to software release cycles.

Stork is a small utility that aims to automate and simplify some tasks related to software release cycles such as reading the current version from a f

Nov 9, 2022
Monitoring changes in the source file and automatically compile and run (restart).
Monitoring changes in the source file and automatically compile and run (restart).

dogo Monitoring changes in the source file and automatically compile and run (restart). 中文 Install go get github.com/liudng/dogo Create config Here's

Dec 28, 2022
EGo lets you build, debug und run Go apps on Intel SGX - as simple as conventional Go programming!

EGo is a framework for building confidential apps in Go. Confidential apps run in always-encrypted and verifiable enclaves on Intel SGX-enabled ha

Dec 28, 2022
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)
ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run, exec, cp, logs, stop)

English / 日本語 ecsk ECS + Task = ecsk ?? ecsk is a CLI tool to interactively use frequently used functions of docker command in Amazon ECS. (docker run

Dec 13, 2022
Package tasks is an easy to use in-process scheduler for recurring tasks in Go

Tasks Package tasks is an easy to use in-process scheduler for recurring tasks in Go. Tasks is focused on high frequency tasks that run quick, and oft

Dec 18, 2022
Delay-tasks - A delayed tasks implementation for golang
Delay-tasks - A delayed tasks implementation for golang

delay-tasks An implementation of delayed tasks. Usage $ git clone https://github

Jan 14, 2022
Limits the number of goroutines that are allowed to run concurrently

Golang Concurrency Manager Golang Concurrency Manager package limits the number of goroutines that are allowed to run concurrently. Installation Run t

Dec 12, 2022
Run tasks concurrently with limits

Workerpool Package workerpool implements a concurrency limiting worker pool. Worker routines are spawned on demand as tasks are submitted. This packag

Nov 3, 2022
Ready is a program to run tasks before a commit using a pre-commit git hook.
Ready is a program to run tasks before a commit using a pre-commit git hook.

Ready Ready is a program to run tasks before a commit using a pre-commit git hook. For example, you can automatically run formatting, linting, and tes

Aug 23, 2022