common

package
v1.5.38 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package common provides the ability to write a file with an eventual rename on Close (using os.Rename). This allows for a file to always be in a consistent state and never represent an in-progress write.

NOTE: `os.Rename` may not be atomic on your operating system.

Index

Constants

View Source
const (
	RestSuccess = 0
)

Variables

This section is empty.

Functions

func ReadPid

func ReadPid() (int, error)

ReadPid the pid from the configured file. It is an error if the pidFile hasn't been configured.

func SavePid

func SavePid(processConfig conf.ProcessConfig) error

SavePid save current process's pid into files.

func SetPidFilePath

func SetPidFilePath(p string)

SetPidFilePath sets the pidFile path.

func WritePid

func WritePid() error

WritePid the pidFile based on the flag. It is an error if the pidFile hasn't been configured.

Types

type AtomicFile

type AtomicFile struct {
	*os.File
	// contains filtered or unexported fields
}

AtomicFile behaves like os.File, but does an atomic rename operation at Close.

func AtomicFileNew

func AtomicFileNew(path string, mode os.FileMode) (*AtomicFile, error)

AtomicFileNew creates a new temporary file that will replace the file at the given path when Closed.

func (*AtomicFile) Abort

func (f *AtomicFile) Abort() error

Abort closes the file and removes it instead of replacing the configured file. This is useful if after starting to write to the file you decide you don't want it anymore.

func (*AtomicFile) Close

func (f *AtomicFile) Close() error

Close the file replacing the configured file.

Directories

Path Synopsis
glog
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
Package glog implements logging analogous to the Google-internal C++ INFO/ERROR/V setup.
store

Jump to

Keyboard shortcuts

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