utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2024 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidStatus = fmt.Errorf("invalid status code received")
	ErrTimeout       = fmt.Errorf("request timed out")
	ErrCanceled      = fmt.Errorf("request was canceled")
)

Custom errors for better error handling

Functions

func DfRowsAsStructList

func DfRowsAsStructList[sType any](d *Dataframe) ([]sType, error)

DfRowsAsStructList the dataframe as a []sType representation; sType must have 'df' tags

func NewRequestEmitter

func NewRequestEmitter(opts ...HTTPEmitterOpt) *httpEmitter

Types

type BadDataframe

type BadDataframe struct{}

type Column

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

type ColumnsNotFoundErr

type ColumnsNotFoundErr struct {
	Available []string
	Required  []string
}

func (*ColumnsNotFoundErr) AsMap

func (e *ColumnsNotFoundErr) AsMap() map[string]any

func (*ColumnsNotFoundErr) Error

func (e *ColumnsNotFoundErr) Error() string

func (*ColumnsNotFoundErr) Header

func (e *ColumnsNotFoundErr) Header() []string

func (*ColumnsNotFoundErr) Other

func (e *ColumnsNotFoundErr) Other() []string

type Dataframe

type Dataframe struct {
	Columns []Column
	Rows    []Record
	// contains filtered or unexported fields
}

func NewDataframe

func NewDataframe(opts ...DfOpts) (*Dataframe, error)

func (*Dataframe) Drop

func (d *Dataframe) Drop(i ...int)

Drop a range of rows from the dataframe

func (*Dataframe) Get

func (d *Dataframe) Get(row int, columns ...string) (*Dataframe, error)

func (*Dataframe) Header

func (d *Dataframe) Header() []string

type DfOpts

type DfOpts func(d *Dataframe) error

func WithInterpretedColumns

func WithInterpretedColumns() DfOpts

func WithProvidedColumns

func WithProvidedColumns(h []string) DfOpts

func WithRecordsFromFiles

func WithRecordsFromFiles(filePaths []string) DfOpts

func WithRecordsFromText

func WithRecordsFromText(b []byte, newLine string, sep string) DfOpts

type FileFilter

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

func NewFileFilter

func NewFileFilter(opts ...FileFilterOption) (*FileFilter, error)

func (FileFilter) Filter

func (ff FileFilter) Filter() ([]string, error)

Filter filters the files in the provided directories and returns a list of absolute file paths

func (*FileFilter) SetDirs

func (ff *FileFilter) SetDirs(d []string)

type FileFilterOption

type FileFilterOption func(*FileFilter) error

func Drill

func Drill() FileFilterOption

WARN: Not implemented; has no effect on behavior

func SetLoc

func SetLoc(loc []string) FileFilterOption

func WithFileAge

func WithFileAge(d time.Duration) FileFilterOption

func WithGlobPattern

func WithGlobPattern(p string) FileFilterOption

type HTTPEmitter

type HTTPEmitter interface {
	Do(ctx context.Context, method string, body []byte) (*http.Response, error)
	SetHeader(key, value string) HTTPEmitter
	SetQueryParam(key, value string) HTTPEmitter
	ChangePath(path string) HTTPEmitter
}

HTTPEmitter defines the contract for HTTP operations

type HTTPEmitterOpt

type HTTPEmitterOpt func(*httpEmitter) error

func WithHTTP

func WithHTTP(host string, path string) HTTPEmitterOpt

func WithHTTPS

func WithHTTPS(host string, path string) HTTPEmitterOpt

func WithProvidedHttpClient

func WithProvidedHttpClient(c *http.Client) HTTPEmitterOpt

func WithRedirectFunc added in v0.1.0

func WithRedirectFunc(redirectFunc func(req *http.Request, via []*http.Request) error) HTTPEmitterOpt

func WithTimeout added in v0.1.0

func WithTimeout(timeout time.Duration) HTTPEmitterOpt

type HeaderError

type HeaderError interface {
	AsMap() map[string]any
	Header() []string
	Other() []string
}

type HeaderInterpretErr

type HeaderInterpretErr struct {
	Provided []string
	Found    []string
}

func (*HeaderInterpretErr) AsMap

func (e *HeaderInterpretErr) AsMap() map[string]any

func (*HeaderInterpretErr) Error

func (e *HeaderInterpretErr) Error() string

func (*HeaderInterpretErr) Header

func (e *HeaderInterpretErr) Header() []string

func (*HeaderInterpretErr) Other

func (e *HeaderInterpretErr) Other() []string

type HeaderMismatchErr

type HeaderMismatchErr struct {
	Original []string
	Mismatch []string
}

func (*HeaderMismatchErr) AsMap

func (e *HeaderMismatchErr) AsMap() map[string]any

func (*HeaderMismatchErr) Error

func (e *HeaderMismatchErr) Error() string

func (*HeaderMismatchErr) Header

func (e *HeaderMismatchErr) Header() []string

func (*HeaderMismatchErr) Other

func (e *HeaderMismatchErr) Other() []string

type Record

type Record []string

Jump to

Keyboard shortcuts

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