utils

package
v0.5.0-beta Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	PathSeparator = string(os.PathSeparator)
)

Variables

View Source
var ZeroDevice = zeroDevice{}

Functions

func ContentTrim

func ContentTrim(contentType, content string) string

func DecodeBase64

func DecodeBase64(s string) ([]byte, error)

func DecodeBase64String

func DecodeBase64String(s string) (string, error)

func EncodeBase64

func EncodeBase64(s []byte) string

func EncodeStringBase64

func EncodeStringBase64(s string) string

func ExtendMemoryBlock

func ExtendMemoryBlock(blk []byte, expectedSize int64) []byte

func GenerateNewID

func GenerateNewID() int64

func HandleTerminalSignal

func HandleTerminalSignal() chan struct{}

func Mkdir

func Mkdir(path string) error

func MustRandString

func MustRandString(length int) string

func NewApiContext

func NewApiContext(r *http.Request) context.Context

func NewMemoryBlock

func NewMemoryBlock(blkSize int64) []byte

func NewReader

func NewReader(reader io.ReaderAt) io.Reader

func NewReaderWithContextReaderAt

func NewReaderWithContextReaderAt(ctx context.Context, reader ContextReaderAt) io.Reader

func NewReaderWithOffset

func NewReaderWithOffset(reader io.ReaderAt, off int64) io.Reader

func NewWorkflowJobContext

func NewWorkflowJobContext(ctx context.Context, jobID string) context.Context

func NewWriter

func NewWriter(writer io.WriterAt) io.Writer

func NewWriterWithContextWriter

func NewWriterWithContextWriter(ctx context.Context, writer ContextWriterAt) io.Writer

func NewWriterWithOffset

func NewWriterWithOffset(writer io.WriterAt, off int64) io.Writer

func RandString

func RandString(length int) (string, error)

func RandStringRunes

func RandStringRunes(n int) string

func Recover

func Recover() error

func ReleaseMemoryBlock

func ReleaseMemoryBlock(blk []byte)

func Rmdir

func Rmdir(path string) error

func Shutdown

func Shutdown()

func WorkflowJobLogger

func WorkflowJobLogger(ctx context.Context, log *zap.SugaredLogger) *zap.SugaredLogger

Types

type ContextReaderAt

type ContextReaderAt interface {
	ReadAt(ctx context.Context, dest []byte, off int64) (int64, error)
}

type ContextWriterAt

type ContextWriterAt interface {
	WriteAt(ctx context.Context, data []byte, off int64) (int64, error)
}

type LFUPool

type LFUPool struct {
	HandlerRemove func(k string, v interface{})
	// contains filtered or unexported fields
}

func NewLFUPool

func NewLFUPool(size int) *LFUPool

func (*LFUPool) Get

func (c *LFUPool) Get(key string) interface{}

func (*LFUPool) Put

func (c *LFUPool) Put(key string, val interface{})

func (*LFUPool) Remove

func (c *LFUPool) Remove(key string)

func (*LFUPool) Visit

func (c *LFUPool) Visit(fn func(k string, v interface{}))

type ParallelLimiter

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

func NewParallelLimiter

func NewParallelLimiter(ctn int) *ParallelLimiter

func (*ParallelLimiter) Acquire

func (l *ParallelLimiter) Acquire(ctx context.Context) error

func (*ParallelLimiter) Release

func (l *ParallelLimiter) Release()

type ParallelWorker

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

func NewParallelWorker

func NewParallelWorker(num int32) *ParallelWorker

func (*ParallelWorker) Dispatch

func (p *ParallelWorker) Dispatch(ctx context.Context, fn func())

type StringSet

type StringSet map[string]struct{}

func NewStringSet

func NewStringSet(strList ...string) StringSet

func (StringSet) Del

func (s StringSet) Del(str string)

func (StringSet) Has

func (s StringSet) Has(str string) bool

func (StringSet) Insert

func (s StringSet) Insert(strList ...string)

func (StringSet) Len

func (s StringSet) Len() int

func (StringSet) List

func (s StringSet) List() (result []string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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