lib

package
v2.0.171-beta Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2023 License: MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

View Source
const (
	BasePart = int64(1024*1024*5 + 1024*1024/3)
)
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 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 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 DirEntry

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

func DirEntryWalkFile

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

func (DirEntry) Error

func (d DirEntry) Error() 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 Iter

type Iter struct {
	Query
	ListParams   ListParamsContainer
	Params       []interface{}
	CurrentIndex int
	Values       *[]interface{}
	Cursor       string
	Error        error
	OnPageError
}

func (*Iter) Current

func (i *Iter) Current() interface{}

func (*Iter) EOFPage

func (i *Iter) EOFPage() bool

func (*Iter) Err

func (i *Iter) Err() error

Err returns the error, if any, that caused the Iter to stop. It must be inspected after Next returns false.

func (*Iter) ExportParams

func (i *Iter) ExportParams() (ExportValues, error)

func (*Iter) GetCursor

func (i *Iter) GetCursor() string

func (*Iter) GetPage

func (i *Iter) GetPage() bool

func (*Iter) GetParams

func (i *Iter) GetParams() *ListParams

func (*Iter) Next

func (i *Iter) Next() bool

Next iterates the results in i.Current() or i.`ResourceName`(). It returns true until there are no results remaining. To adjust the number of results set ListParams.PerPage. To have it auto-paginate set ListParams.MaxPages, default is 1.

To iterate over all results use the following pattern.

for i.Next() {
  i.Current()
}

func (*Iter) NextPage

func (i *Iter) NextPage() bool

func (*Iter) Paging

func (i *Iter) Paging() bool

func (*Iter) SetCursor

func (i *Iter) SetCursor(cursor string)

type IterChan

type IterChan[T any] struct {
	Send      chan interface{}
	Stop      chan bool
	SendError chan error

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

func (*IterChan[T]) Current

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

func (*IterChan[T]) Err

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

func (*IterChan[T]) Init

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

func (*IterChan[T]) Next

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

type IterI

type IterI interface {
	Next() bool
	Current() interface{}
	Err() error
}

type IterPagingI

type IterPagingI interface {
	IterI
	EOFPage() bool
}

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 ListParams

type ListParams struct {
	Page     int64  `json:"page,omitempty" url:"page,omitempty" required:"false"`
	PerPage  int64  `json:"per_page,omitempty" url:"per_page,omitempty" required:"false"`
	Cursor   string `json:"cursor,omitempty" url:"cursor,omitempty" required:"false"`
	MaxPages int64  `json:"-" url:"-"`
}

func (*ListParams) GetListParams

func (p *ListParams) GetListParams() *ListParams

GetListParams returns a ListParams struct (itself). It exists because any structs that embed ListParams will inherit it, and thus implement the ListParamsContainer interface.

type ListParamsContainer

type ListParamsContainer interface {
	GetListParams() *ListParams
}

ListParamsContainer is a general interface for which all list parameter structs should comply. They achieve this by embedding a ListParams struct and inheriting its implementation of this 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 OnPageError

type OnPageError func(error) (*[]interface{}, error)

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 Query

type Query func(params Values) (*[]interface{}, string, error)

type Queue

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

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 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]
	goccm.ConcurrencyManager
	Root            string
	WalkFile        func(d fs.DirEntry, path string) (T, error)
	ListDirectories bool
}

func (*Walk[T]) Walk

func (w *Walk[T]) Walk(ctx 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