lib

package
v2.0.287 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2023 License: MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BasePart = int64(1024 * 1024 * 5)
)
View Source
const (
	URLPathSeparator = "/"
)

Variables

View Source
var PartSizes = partSizes()

PartSizes return 10k parts that add up to 4.9 TB

Functions

func AnyError

func AnyError(callback func(error), functions ...func() error)

func Bool

func Bool(bool bool) *bool

func BuildPath

func BuildPath(resourcePath string, values interface{}) (string, error)

func BuildPathSpecTest

func BuildPathSpecTest(t *testing.T, mutex *sync.Mutex, tt PathSpecTest, sourceFs ReadWriteFs, destinationFs ReadWriteFs, cmdBuilder func(source, destination string) Cmd)

func ChangeDir

func ChangeDir(fs ReadWriteFs, relativePath string, fullPath string, mutex *sync.Mutex) (func(), bool, error)

func CheckRequired

func CheckRequired(iStruct interface{}) error

func CloseBody

func CloseBody(res *http.Response)

func CopyAt

func CopyAt(dst io.WriterAt, writeOff int64, src io.Reader) (written int64, err error)

func CreateError

func CreateError(i interface{}, name string) error

func ExpandTilde

func ExpandTilde(path string) string

func Int64

func Int64(i int64) *int64

func Interface

func Interface() interface{}

func IsHTML

func IsHTML(res *http.Response) bool

func IsJSON

func IsJSON(res *http.Response) bool

func IsNonOkStatus

func IsNonOkStatus(res *http.Response) bool

func IsOkStatus

func IsOkStatus(res *http.Response) bool

func IsStatus

func IsStatus(status int) func(res *http.Response) error

func JSONEmptyValue

func JSONEmptyValue(v reflect.Type) string

func NewReader

func NewReader(ctx context.Context, r io.ReadCloser) io.ReadCloser

NewReader gets a context-aware io.Reader.

func NewReaderAt

func NewReaderAt(ctx context.Context, r io.ReaderAt) io.ReaderAt

NewReader gets a context-aware io.Reader.

func NonJSONError

func NonJSONError(res *http.Response) error

func NonOkError

func NonOkError(res *http.Response) error

func NonOkErrorCustom

func NonOkErrorCustom(callbacks ...func(error) error) func(res *http.Response) error

func NormalizeForComparison

func NormalizeForComparison(path string) string

func NotStatus

func NotStatus(status int) func(res *http.Response) error

func PathEscape

func PathEscape(path string) (string, error)

func ResponseErrors

func ResponseErrors(res *http.Response, errorFunc ...func(res *http.Response) error) error

func String

func String(string string) *string

func Time

func Time(t time.Time) *time.Time

func UnWrapBool

func UnWrapBool(b *bool) bool

func UrlJoinNoEscape

func UrlJoinNoEscape(paths ...string) string

func UrlLastSegment

func UrlLastSegment(path string) (rest string, lastSegment string)

Types

type Cmd

type Cmd interface {
	SetOut(io.Writer)
	SetErr(newErr io.Writer)
	Run() error
	Args() []string
}

type ConcurrencyManager

type ConcurrencyManager interface {
	// Wait until a slot is available for the new goroutine.
	Wait()

	// Done Mark a goroutine as finished
	Done()

	// WaitAllDone Wait for all goroutines are done
	WaitAllDone()

	// RunningCount Returns the number of goroutines which are running
	RunningCount() int

	// WaitWithContext Acquires a semaphore to allow a new goroutine to run or returns false if the context is done
	WaitWithContext(ctx context.Context) bool

	// WaitForADone Blocks until at least one goroutine has completed.
	WaitForADone() bool
}

type ConcurrencyManagerWithSubWorker

type ConcurrencyManagerWithSubWorker interface {
	ConcurrencyManager
	NewSubWorker() ConcurrencyManager
}

type ConstrainedWorkGroup

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

func NewConstrainedWorkGroup

func NewConstrainedWorkGroup(maxConcurrency int) *ConstrainedWorkGroup

func (*ConstrainedWorkGroup) Done

func (cw *ConstrainedWorkGroup) Done()

func (*ConstrainedWorkGroup) Max

func (cw *ConstrainedWorkGroup) Max() int

func (*ConstrainedWorkGroup) NewSubWorker

func (cw *ConstrainedWorkGroup) NewSubWorker() ConcurrencyManager

func (*ConstrainedWorkGroup) RemainingCapacity

func (cw *ConstrainedWorkGroup) RemainingCapacity() int

func (*ConstrainedWorkGroup) RunningCount

func (cw *ConstrainedWorkGroup) RunningCount() int

func (*ConstrainedWorkGroup) Wait

func (cw *ConstrainedWorkGroup) Wait()

func (*ConstrainedWorkGroup) WaitAllDone

func (cw *ConstrainedWorkGroup) WaitAllDone()

func (*ConstrainedWorkGroup) WaitForADone

func (cw *ConstrainedWorkGroup) WaitForADone() bool

func (*ConstrainedWorkGroup) WaitWithContext

func (cw *ConstrainedWorkGroup) WaitWithContext(ctx context.Context) bool

type DirEntry

type DirEntry struct {
	fs.DirEntry
	fs.FileInfo
	// contains filtered or unexported fields
}

func DirEntryWalkFile

func DirEntryWalkFile(d fs.DirEntry, path string, err error) (DirEntry, error)

func (DirEntry) Err

func (d DirEntry) Err() error

func (DirEntry) Path

func (d DirEntry) Path() string

type ErrorWithOriginalResponse

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

func (ErrorWithOriginalResponse) OriginalResponse

func (u ErrorWithOriginalResponse) OriginalResponse() interface{}

func (ErrorWithOriginalResponse) ProcessError

func (u ErrorWithOriginalResponse) ProcessError(data []byte, err error, t interface{}) error

type ExeCmd

type ExeCmd struct {
	*exec.Cmd
}

func (ExeCmd) Args

func (e ExeCmd) Args() []string

func (ExeCmd) Run

func (e ExeCmd) Run() error

func (ExeCmd) SetErr

func (e ExeCmd) SetErr(w io.Writer)

func (ExeCmd) SetOut

func (e ExeCmd) SetOut(w io.Writer)

type ExportValues

type ExportValues struct {
	url.Values
}

func (ExportValues) ToJSON

func (m ExportValues) ToJSON() (io.Reader, error)

func (ExportValues) ToValues

func (m ExportValues) ToValues() (url.Values, error)

type FSWithContext

type FSWithContext interface {
	WithContext(ctx context.Context) fs.FS
}

type FileWithContext

type FileWithContext interface {
	WithContext(ctx context.Context) fs.File
}

type IsDir

type IsDir interface {
	IsDir() bool
}

type IterChan

type IterChan[T any] struct {
	Send      chan T
	SendError chan error

	Error atomic.Value
	Start func(*IterChan[T])
	context.Context
	Stop context.CancelFunc
	// contains filtered or unexported fields
}

func (*IterChan[T]) Current

func (i *IterChan[T]) Current() interface{}

func (*IterChan[T]) Err

func (i *IterChan[T]) Err() error

func (*IterChan[T]) Init

func (i *IterChan[T]) Init(ctx context.Context) *IterChan[T]

func (*IterChan[T]) Next

func (i *IterChan[T]) Next() bool

func (*IterChan[T]) Resource

func (i *IterChan[T]) Resource() T

type KeyedMutex

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

func NewKeyedMutex

func NewKeyedMutex() KeyedMutex

func (KeyedMutex) Lock

func (s KeyedMutex) Lock(key interface{})

func (KeyedMutex) Unlock

func (s KeyedMutex) Unlock(key interface{})

type LocalFileSystem

type LocalFileSystem struct{}

func (LocalFileSystem) Chdir

func (w LocalFileSystem) Chdir(dir string) error

func (LocalFileSystem) Create

func (w LocalFileSystem) Create(path string) (io.WriteCloser, error)

func (LocalFileSystem) Getwd

func (w LocalFileSystem) Getwd() (string, error)

func (LocalFileSystem) MkdirAll

func (w LocalFileSystem) MkdirAll(path string, mode fs.FileMode) error

func (LocalFileSystem) MkdirTemp

func (w LocalFileSystem) MkdirTemp(dir, pattern string) (string, error)

func (LocalFileSystem) Open

func (w LocalFileSystem) Open(path string) (fs.File, error)

func (LocalFileSystem) PathJoin

func (w LocalFileSystem) PathJoin(paths ...string) string

func (LocalFileSystem) PathSeparator

func (w LocalFileSystem) PathSeparator() string

func (LocalFileSystem) RelPath

func (w LocalFileSystem) RelPath(parent, child string) (string, error)

func (LocalFileSystem) Remove

func (w LocalFileSystem) Remove(path string) error

func (LocalFileSystem) RemoveAll

func (w LocalFileSystem) RemoveAll(path string) error

func (LocalFileSystem) SplitPath

func (w LocalFileSystem) SplitPath(path string) (string, string)

func (LocalFileSystem) TempDir

func (w LocalFileSystem) TempDir() string

type Map

type Map[T any] struct {
	sync.Map
}

func (*Map[T]) Delete

func (m *Map[T]) Delete(key any)

func (*Map[T]) Load

func (m *Map[T]) Load(key any) (value T, ok bool)

func (*Map[T]) Store

func (m *Map[T]) Store(key any, value T)

type Params

type Params struct {
	Params interface{}
}

func (Params) ToJSON

func (p Params) ToJSON() (io.Reader, error)

func (Params) ToValues

func (p Params) ToValues() (url.Values, error)

type Path

type Path struct {
	Path      string
	Separator string
}

func NewUrlPath

func NewUrlPath(path string) Path

func (Path) ConvertEmptyToRoot

func (p Path) ConvertEmptyToRoot() Path

func (Path) EndingSlash

func (p Path) EndingSlash() bool

func (Path) Join

func (p Path) Join(str ...string) Path

func (Path) NormalizePathSystemForAPI

func (p Path) NormalizePathSystemForAPI() Path

func (Path) PathSeparator

func (p Path) PathSeparator() string

func (Path) Pop

func (p Path) Pop() string

func (Path) PruneEndingSlash

func (p Path) PruneEndingSlash() Path

func (Path) PruneStartingSlash

func (p Path) PruneStartingSlash() Path

func (Path) String

func (p Path) String() string

func (Path) SwitchPathSeparator

func (p Path) SwitchPathSeparator(separator string) Path

type PathSpecArgs

type PathSpecArgs struct {
	Src  string
	Dest string
}

type PathSpecEntry

type PathSpecEntry struct {
	Dir bool

	Preexisting bool
	// contains filtered or unexported fields
}

type PathSpecTest

type PathSpecTest struct {
	Name string
	Args PathSpecArgs
	Dest []PathSpecEntry
	Src  []PathSpecEntry
}

func PathSpec

func PathSpec(srcPathSeparator string, destPathSeparator string) []PathSpecTest

type ProgressWriter

type ProgressWriter struct {
	WriterAndAt
	ProgressWatcher func(int64)
}

func (ProgressWriter) Close

func (w ProgressWriter) Close() error

func (ProgressWriter) Write

func (w ProgressWriter) Write(p []byte) (n int, err error)

func (ProgressWriter) WriteAt

func (w ProgressWriter) WriteAt(p []byte, off int64) (n int, err error)

type Queue

type Queue[T any] struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

func (*Queue[T]) Clear

func (q *Queue[T]) Clear()

func (*Queue[T]) Init

func (q *Queue[T]) Init(size int) *Queue[T]

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() T

func (*Queue[T]) Push

func (q *Queue[T]) Push(item T)

type ReadWriteFs

type ReadWriteFs interface {
	WritableFs
	fs.FS
}

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.ReadCloser
}

type Resource

type Resource struct {
	Path   string
	Params interface{}
	Method string
	Entity UnmarshalJSON
}

func (Resource) Out

func (r Resource) Out() (ResourceOut, error)

type ResourceOut

type ResourceOut struct {
	Resource
	Values
}

type ResponseError

type ResponseError struct {
	StatusCode int
	// contains filtered or unexported fields
}

func (ResponseError) Error

func (r ResponseError) Error() string

type Signal

type Signal struct {
	C chan bool
}

func (*Signal) Call

func (s *Signal) Call()

func (*Signal) Called

func (s *Signal) Called() bool

func (*Signal) Clear

func (s *Signal) Clear()

func (*Signal) Init

func (s *Signal) Init() *Signal

type StatefulDirectory

type StatefulDirectory interface {
	Chdir(string) error
	Getwd() (string, error)
}

type SubWorker

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

func (*SubWorker) Done

func (sw *SubWorker) Done()

func (*SubWorker) RunningCount

func (sw *SubWorker) RunningCount() int

func (*SubWorker) Wait

func (sw *SubWorker) Wait()

func (*SubWorker) WaitAllDone

func (sw *SubWorker) WaitAllDone()

func (*SubWorker) WaitForADone

func (sw *SubWorker) WaitForADone() bool

WaitForADone Blocks until at least one goroutine has completed.

func (*SubWorker) WaitWithContext

func (sw *SubWorker) WaitWithContext(ctx context.Context) bool

type UnmarshalJSON

type UnmarshalJSON interface {
	UnmarshalJSON(data []byte) error
}

type Values

type Values interface {
	ToValues() (url.Values, error)
	ToJSON() (io.Reader, error)
}

type Walk

type Walk[T any] struct {
	fs.FS
	Queue[string]
	IterChan[T]
	ConcurrencyManager ConcurrencyManagerWithSubWorker
	Root               string
	WalkFile           func(d fs.DirEntry, path string, err error) (T, error)
	ListDirectories    bool
}

func (*Walk[T]) Walk

func (w *Walk[T]) Walk(parentCtx context.Context) *IterChan[T]

type WithContextReader

type WithContextReader interface {
	WithContext(context.Context) interface{}
	io.Reader
}

type WithContextReaderAt

type WithContextReaderAt interface {
	WithContext(context.Context) interface{}
	io.ReaderAt
}

type WritableFs

type WritableFs interface {
	MkdirAll(string, fs.FileMode) error
	MkdirTemp(dir, pattern string) (string, error)
	TempDir() string
	Create(string) (io.WriteCloser, error)
	RemoveAll(string) error
	Remove(string) error
	PathSeparator() string
	PathJoin(...string) string
	RelPath(parent, child string) (string, error)
	SplitPath(path string) (string, string)
}

type WriterAndAt

type WriterAndAt interface {
	io.WriterAt
	io.Writer
	io.Closer
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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