process

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2025 License: Apache-2.0 Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exclusive

type Exclusive struct {
	Name string
	// contains filtered or unexported fields
}

Exclusive is a data structure used to tracking and ensure only one instance of the go runner is active on a system at once

func NewExclusive

func NewExclusive(ctx context.Context, name string) (excl *Exclusive, err kv.Error)

NewExclusive is used to initialize a unix domain socket that ensure that only one runner process is active on a kubernetes pod or machine at the same time. If there are other processes active then it will return an error.

An example of a server that wishes to restrict itself to a single instance of a process would appear as follows:

func main() {

	ctx, cancel := context.WithCancel(context.Background())
	defer cancel()

	// This is the one check that does not get tested when the server is under test
	//
	if _, err := process.NewExclusive(ctx, "my-server"); err != nil {
		fmt.Fprintf(os.Sdterr, "An instance of this process is already running %s", err.Error())
		os.Exit(-1)
	}
	…
}

Jump to

Keyboard shortcuts

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