xos

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: Apache-2.0 Imports: 10 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInterrupted = NewInterruptError("interrupted")

ErrInterrupted is an error indicating that the interrupted channel was closed, meaning an interrupt was received on the main interrupt channel.

Functions

func CanGetProcessLimits added in v0.5.0

func CanGetProcessLimits() (bool, string)

CanGetProcessLimits returns a boolean to signify if it can return limits, and a warning message if it cannot.

func NewInterruptChannel added in v0.10.0

func NewInterruptChannel(numListeners int) <-chan error

NewInterruptChannel will return an interrupt channel useful with multiple listeners.

func NewInterruptError added in v1.3.0

func NewInterruptError(interrupt string) error

NewInterruptError creates a new InterruptError.

func WaitForInterrupt added in v0.10.0

func WaitForInterrupt(logger *zap.Logger, opts InterruptOptions)

WaitForInterrupt will wait for an interrupt to occur and return when done.

func WatchForInterrupt added in v1.3.0

func WatchForInterrupt(logger *zap.Logger, opts InterruptOptions) func()

WatchForInterrupt watches for interrupts in a non-blocking fashion and closes the interrupted channel when an interrupt is found. Use this method to watch for interrupts while the caller continues to execute (e.g. during server startup). To ensure child goroutines get properly closed, pass them the interrupted channel. If the interrupted channel is closed, then the goroutine knows to stop its work. This method returns a function that can be used to stop the watch.

func WriteFileSync added in v1.2.0

func WriteFileSync(name string, data []byte, perm os.FileMode) error

WriteFileSync calls fsync() in addition to writing a file to disk.

Types

type File

type File interface {
	// Write bytes to the file descriptor.
	Write(p []byte) (int, error)
	// Sync fsyncs the file descriptor ensuring all writes have made it to disk.
	Sync() error
	// Close the file descriptor.
	Close() error
}

File is the interface implemented by *os.File.

type InterruptError added in v1.3.0

type InterruptError struct {
	// contains filtered or unexported fields
}

InterruptError is an error representing an interrupt.

func (*InterruptError) Error added in v1.3.0

func (i *InterruptError) Error() string

type InterruptOptions added in v0.10.0

type InterruptOptions struct {
	// InterruptChannel is an existing interrupt channel, if none
	// specified one will be created.
	InterruptCh <-chan error

	// InterruptedChannel is a channel that will be closed once an
	// interrupt has been seen. Use this to pass to goroutines who
	// want to be notified about interruptions that you don't want
	// consuming from the main interrupt channel.
	InterruptedCh chan struct{}
}

InterruptOptions are options to use when waiting for an interrupt.

func NewInterruptOptions added in v1.3.0

func NewInterruptOptions() InterruptOptions

NewInterruptOptions creates InterruptOptions with sane defaults.

type ProcessLimits

type ProcessLimits struct {
	NoFileCurr    uint64 // RLIMIT_NOFILE Current
	NoFileMax     uint64 // RLIMIT_NOFILE Max
	VMMaxMapCount int64  // corresponds to /proc/sys/vm/max_map_count
	VMSwappiness  int64  // corresponds to /proc/sys/vm/swappiness
}

ProcessLimits captures the different process limits.

func GetProcessLimits

func GetProcessLimits() (ProcessLimits, error)

GetProcessLimits returns the known process limits.

type RaiseProcessNoFileToNROpenResult added in v0.9.5

type RaiseProcessNoFileToNROpenResult struct {
	RaisePerformed  bool
	NROpenValue     uint64
	NoFileMaxValue  uint64
	NoFileCurrValue uint64
}

RaiseProcessNoFileToNROpenResult captures the result of trying to raise the process num files open limit to the nr_open system value.

func RaiseProcessNoFileToNROpen added in v0.9.5

func RaiseProcessNoFileToNROpen() (RaiseProcessNoFileToNROpenResult, error)

RaiseProcessNoFileToNROpen first determines the NROpen limit by reading the corresponding proc sys file and then if the hard or soft limits are below this number, the limits are raised using a call to setrlimit.

Jump to

Keyboard shortcuts

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