forks

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 10, 2022 License: Apache-2.0 Imports: 5 Imported by: 1

README

Time-based duplicate suppression for forking processes.

Inspired by @kr.

Docs here.

Documentation

Overview

Example
package main

import (
	"log"
	"time"

	"blake.io/forks"
)

func main() {
	if forks.Maybe(24*time.Hour, nil) {
		log.Println("I am the parent")
	} else {
		log.Println("I am the child")
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Maybe

func Maybe(wait time.Duration, fatalf func(format string, args ...any)) (parent bool)

Maybe forks the current process if no other run of the binary in the same install location has been run within the amount of time specified by wait.

If an error occurs and fatalf is non-nil, the error is logged to fatalf; otherwise no error is logged.

If wait is negative or zero, the touch file is touched and process is forked immediately.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL