status

package
v2.0.249 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2023 License: MIT Imports: 17 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Null        = Status{"", -1}
	Indexed     = Status{"indexed", 0}
	Retrying    = Status{"retrying", 0}
	Queued      = Status{"queued", 1}
	Downloading = Status{"downloading", 2}
	Uploading   = Status{"uploading", 2}
	Skipped     = Status{"skipped", 3}
	Ignored     = Status{"ignored", 3}
	Complete    = Status{"complete", 4}
	Canceled    = Status{"canceled", 5}
	Errored     = Status{"errored", 5}

	Included = []GetStatus{Indexed, Queued, Retrying, Downloading, Uploading, Complete, Canceled, Errored}
	Excluded = []GetStatus{Skipped, Ignored}
	Valid    = []GetStatus{Indexed, Queued, Retrying, Downloading, Uploading, Complete}
	Invalid  = []GetStatus{Null, Canceled, Errored, Skipped, Ignored}
	Running  = []GetStatus{Downloading, Uploading}
	Ended    = []GetStatus{Complete, Canceled, Errored, Skipped, Ignored}
)

Functions

func WaitTellFinished

func WaitTellFinished[T any](job *Job, onStatusComplete chan T, beforeCallingFinish func())

Types

type Change

type Change struct {
	Status
	time.Time
	Err error
}

type Changes

type Changes []Change

func (Changes) Count

func (c Changes) Count(s Status) (count int)

type EventsReporter

type EventsReporter map[Status][]reporterSettings

func CreateFileEvents added in v2.0.219

func CreateFileEvents(callback Reporter, events ...GetStatus) EventsReporter

type File

type File struct {
	StatusName    string        `json:"status"`
	TransferBytes int64         `json:"transferred_bytes"`
	Size          int64         `json:"size_bytes"`
	LocalPath     string        `json:"local_path"`
	RemotePath    string        `json:"remote_path"`
	EndedAt       time.Time     `json:"completed_at"`
	StartedAt     time.Time     `json:"started_at"`
	Err           error         `json:"error"`
	Id            string        `json:"-"`
	Attempts      int           `json:"attempts"`
	Mutex         *sync.RWMutex `json:"-"`
	LastByte      time.Time     `json:"-"`
	Status        `json:"-"`
	filesSDK.File `json:"-"`
	*Job          `json:"-"`
}

func ToStatusFile

func ToStatusFile(f IFile) File

type GetStatus added in v2.0.219

type GetStatus interface {
	Status() Status
}

func OnBytesChange added in v2.0.219

func OnBytesChange(event GetStatus) GetStatus

type IFile

type IFile interface {
	SetStatus(Status, error)
	StatusChanges() Changes
	TransferBytes() int64
	IncrementTransferBytes(int64)
	File() filesSDK.File
	Size() int64
	Id() string
	LocalPath() string
	RemotePath() string
	Status() Status
	LastByte() time.Time
	EndedAt() time.Time
	StartedAt() time.Time
	Err() error
	Job() *Job
}

type Job

type Job struct {
	Id string
	*timer.Timer
	Statuses  []IFile
	Direction direction.Direction

	LocalPath  string
	RemotePath string
	Sync       bool
	CodeStart  func()
	context.CancelFunc

	Params interface{}
	Client interface{}
	Config interface{}
	EventsReporter
	directory.Type
	*manager.Manager
	RetryPolicy interface{}
	*ignore.GitIgnore
	Started     *lib.Signal
	Finished    *lib.Signal
	Canceled    *lib.Signal
	Scanning    *lib.Signal
	EndScanning *lib.Signal
	retryablehttp.Logger
	RemoteFs fs.FS
	// contains filtered or unexported fields
}

func (*Job) Add

func (r *Job) Add(report IFile)

func (*Job) All

func (r *Job) All(t ...GetStatus) bool

func (*Job) Any

func (r *Job) Any(t ...GetStatus) (b bool)

func (*Job) Cancel

func (r *Job) Cancel()

func (*Job) ClearCalled

func (r *Job) ClearCalled()

func (*Job) ClearStatuses

func (r *Job) ClearStatuses() Job

func (*Job) Count

func (r *Job) Count(t ...GetStatus) int

func (*Job) ETA

func (r *Job) ETA(t ...GetStatus) time.Duration

func (*Job) ElapsedTime

func (r *Job) ElapsedTime() time.Duration

func (*Job) EndScan

func (r *Job) EndScan()

func (*Job) EnqueueNext

func (r *Job) EnqueueNext() (f IFile, ok bool)

func (*Job) Files

func (r *Job) Files() []filesSDK.File

func (*Job) Find

func (r *Job) Find(t GetStatus) (IFile, bool)

func (*Job) FindRemoteFile

func (r *Job) FindRemoteFile(file IFile) (filesSDK.File, bool, error)

func (*Job) Finish

func (r *Job) Finish()

func (*Job) Idle

func (r *Job) Idle(durations ...time.Duration) bool

func (*Job) Init

func (r *Job) Init() *Job

func (*Job) Job

func (r *Job) Job() *Job

func (*Job) Percentage

func (r *Job) Percentage(t ...GetStatus) int

func (*Job) RegisterFileEvent

func (r *Job) RegisterFileEvent(callback Reporter, events ...GetStatus)

func (*Job) RemainingBytes

func (r *Job) RemainingBytes(t ...GetStatus) int64

func (*Job) Reset

func (r *Job) Reset()

func (*Job) Scan

func (r *Job) Scan()

func (*Job) SetEventsReporter

func (r *Job) SetEventsReporter(e EventsReporter)

func (*Job) SetManager

func (r *Job) SetManager(m *manager.Manager)

func (*Job) Start

func (r *Job) Start(ignoreCodeStart ...bool)

func (*Job) StatusFromError

func (r *Job) StatusFromError(s IFile, err error)

func (*Job) Sub

func (r *Job) Sub(t ...GetStatus) *Job

func (*Job) TotalBytes

func (r *Job) TotalBytes(t ...GetStatus) int64

func (*Job) TransferBytes

func (r *Job) TransferBytes(t ...GetStatus) int64

func (*Job) TransferRate

func (r *Job) TransferRate(t ...GetStatus) int64

func (*Job) UpdateStatus

func (r *Job) UpdateStatus(status GetStatus, file IFile, err error)

func (*Job) UpdateStatusWithBytes added in v2.0.219

func (r *Job) UpdateStatusWithBytes(status GetStatus, file IFile, bytesCount int64)

func (*Job) Wait

func (r *Job) Wait()

func (*Job) WithContext

func (r *Job) WithContext(ctx context.Context) context.Context

type Log

type Log struct {
	Path   string
	Action string
}

type MashableError

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

func (MashableError) Err

func (me MashableError) Err() error

func (MashableError) MarshalJSON

func (me MashableError) MarshalJSON() ([]byte, error)

type Reporter

type Reporter func(File)

type Status

type Status struct {
	Name  string
	Value int
}

func SetStatus

func SetStatus(old GetStatus, new GetStatus, err error) (Status, bool)

func (Status) Any

func (e Status) Any(statuses ...GetStatus) bool

func (Status) Has

func (e Status) Has(statuses ...GetStatus) bool

func (Status) Is

func (e Status) Is(statuses ...GetStatus) bool

func (Status) IsNot

func (e Status) IsNot(statuses ...GetStatus) bool

func (Status) Status added in v2.0.219

func (e Status) Status() Status

func (Status) String

func (e Status) String() string

type Subscriptions

type Subscriptions struct {
	Started     chan time.Time
	Finished    chan time.Time
	Canceled    chan time.Time
	Scanning    chan time.Time
	EndScanning chan time.Time
}

type UnwrappedError

type UnwrappedError struct {
	OriginalError error
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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