process

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

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