common

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2021 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	B  = 1
	KB = 1024 * B
	MB = 1024 * KB
	GB = 1024 * MB
)
View Source
const DefaultHangTimeout = 20 * 60
View Source
const DefaultMaxRetryCount = 5

DefaultMaxRetryCount 최대 재시도 횟수 기본값

View Source
const DefaultProgressUpdateInterval = 30

DefaultProgressUpdateInterval 처리정보 갱신 주기 unit (seconds)

View Source
const (
	ErrSigTermCode = 9
)

Variables

View Source
var (
	ErrSigTerm = New(ErrSigTermCode, "signal term", "retry")
)

Functions

func BeautifyJson

func BeautifyJson(byteJson []byte) (string, error)

func DurationToSecond

func DurationToSecond(duration string) (sec float64)

func FromJson

func FromJson(byteJson []byte, object interface{}) error

func GetCarriageReturn

func GetCarriageReturn() byte

func GetCurrentTimeAsMilli added in v0.0.4

func GetCurrentTimeAsMilli() int64

func GetCurrentTimeAsSec added in v0.0.4

func GetCurrentTimeAsSec() float64

func GetMd5OfFile

func GetMd5OfFile(inputFile string) (string, error)

func GetWhereIs

func GetWhereIs() string

func GoRoutineWithContext

func GoRoutineWithContext(ctx context.Context, callbacks ...GoRoutineFunc) ([]interface{}, error)

func GroupLoop

func GroupLoop(originArray []interface{}, concurrencyCount int, callback func(group []interface{}) error) error

func IF

func IF(is bool, trueValue interface{}, falseValue interface{}) interface{}

func JsonFileToObject

func JsonFileToObject(fileName string, object interface{}) error

func NVL

func NVL(value interface{}, replace interface{}) interface{}

func ObjectToFile

func ObjectToFile(fileName string, data interface{}) error

func QueryString

func QueryString(headers map[string]string) string

func RemoveFileExtension

func RemoveFileExtension(inputFile string) string

func RetryWrapper

func RetryWrapper(callback func() (interface{}, error), retryCount int) (interface{}, error)

func StringToFile

func StringToFile(fileName string, data string) error

func ToJson

func ToJson(object interface{}) ([]byte, error)

func ToJsonAsString

func ToJsonAsString(object interface{}) string

func ToJsonBeautifully

func ToJsonBeautifully(object interface{}) string

func WaitForShutdown

func WaitForShutdown(shutdownCallback func())

Types

type DiskInfo

type DiskInfo struct {
	Total uint64 `json:"total"`
	Free  uint64 `json:"free"`
}

func DiskUsage

func DiskUsage(path string) (*DiskInfo, error)

func (*DiskInfo) Used

func (d *DiskInfo) Used() uint64

type ExternalProgramArguments

type ExternalProgramArguments struct {
	InputArgs  []string
	OutputArgs []string
}

type ExternalProgramExecutor

type ExternalProgramExecutor struct {
	HangTimeout int64
	// contains filtered or unexported fields
}

func NewExternalProgramExecutor

func NewExternalProgramExecutor(execName string, inputArgs []string, outputArgs []string) *ExternalProgramExecutor

func (*ExternalProgramExecutor) ExecuteAsynchronously

func (e *ExternalProgramExecutor) ExecuteAsynchronously() <-chan error

func (*ExternalProgramExecutor) ExecuteSynchronously

func (e *ExternalProgramExecutor) ExecuteSynchronously() (string, error)

func (*ExternalProgramExecutor) GetExitCode

func (e *ExternalProgramExecutor) GetExitCode() int

func (*ExternalProgramExecutor) GetProcess

func (e *ExternalProgramExecutor) GetProcess() *exec.Cmd

func (*ExternalProgramExecutor) GetStdErrPipe

func (e *ExternalProgramExecutor) GetStdErrPipe() io.ReadCloser

func (*ExternalProgramExecutor) GetStdInPipe

func (e *ExternalProgramExecutor) GetStdInPipe() io.WriteCloser

func (*ExternalProgramExecutor) GetStdOutPipe

func (e *ExternalProgramExecutor) GetStdOutPipe() io.ReadCloser

func (*ExternalProgramExecutor) OnMessages

func (e *ExternalProgramExecutor) OnMessages(splitFunction func([]byte, bool) (int, []byte, error),
	scanFunction func(*bufio.Scanner, chan string, interface{}), pipe io.ReadCloser, args interface{}) <-chan string

func (*ExternalProgramExecutor) OnProgress

func (e *ExternalProgramExecutor) OnProgress(splitFunction func([]byte, bool) (int, []byte, error),
	scanFunction func(*bufio.Scanner, chan interface{}, interface{}), pipe io.ReadCloser, args interface{}) <-chan interface{}

func (*ExternalProgramExecutor) OnTimeout

func (e *ExternalProgramExecutor) OnTimeout() chan error

type GoRoutineFunc

type GoRoutineFunc func(ctx context.Context) interface{}

type NeptuneError

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

func New

func New(code int, message string, action string) *NeptuneError

func (*NeptuneError) Action

func (h *NeptuneError) Action() string

func (*NeptuneError) Code

func (h *NeptuneError) Code() int

func (*NeptuneError) Copy

func (h *NeptuneError) Copy(err error) *NeptuneError

func (*NeptuneError) Error

func (h *NeptuneError) Error() string

func (*NeptuneError) Message

func (h *NeptuneError) Message() string

func (*NeptuneError) SetAction

func (h *NeptuneError) SetAction(action string) *NeptuneError

func (*NeptuneError) SetMessage

func (h *NeptuneError) SetMessage(message string) *NeptuneError

func (*NeptuneError) SysErr

func (h *NeptuneError) SysErr() error

Jump to

Keyboard shortcuts

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