Documentation ¶
Overview ¶
Package accounting providers an accounting and limiting reader
Index ¶
- Variables
- func SetBwLimit(bandwidth fs.SizeSuffix)
- func StartTokenBucket()
- func StartTokenTicker()
- type Account
- func (acc *Account) AccountRead(n int) (err error)
- func (acc *Account) Close() error
- func (acc *Account) GetAsyncReader() *asyncreader.AsyncReader
- func (acc *Account) GetReader() io.ReadCloser
- func (acc *Account) OldStream() io.Reader
- func (acc *Account) Read(p []byte) (n int, err error)
- func (acc *Account) RemoteStats() (out map[string]interface{})
- func (acc *Account) SetStream(in io.Reader)
- func (acc *Account) StopBuffering()
- func (acc *Account) String() string
- func (acc *Account) UpdateReader(in io.ReadCloser)
- func (acc *Account) WithBuffer() *Account
- func (acc *Account) WrapStream(in io.Reader) io.Reader
- type Accounter
- type StatsInfo
- func (s *StatsInfo) Bytes(bytes int64)
- func (s *StatsInfo) Checking(remote string)
- func (s *StatsInfo) Deletes(deletes int64) int64
- func (s *StatsInfo) DoneChecking(remote string)
- func (s *StatsInfo) DoneTransferring(remote string, ok bool)
- func (s *StatsInfo) Error(err error)
- func (s *StatsInfo) Errored() bool
- func (s *StatsInfo) Errors(errors int64)
- func (s *StatsInfo) FatalError()
- func (s *StatsInfo) GetBytes() int64
- func (s *StatsInfo) GetChecks() int64
- func (s *StatsInfo) GetErrors() int64
- func (s *StatsInfo) GetLastError() error
- func (s *StatsInfo) GetTransfers() int64
- func (s *StatsInfo) HadFatalError() bool
- func (s *StatsInfo) HadRetryError() bool
- func (s *StatsInfo) Log()
- func (s *StatsInfo) RemoteStats(in rc.Params) (out rc.Params, err error)
- func (s *StatsInfo) ResetCounters()
- func (s *StatsInfo) ResetErrors()
- func (s *StatsInfo) RetryAfter() time.Time
- func (s *StatsInfo) RetryError()
- func (s *StatsInfo) SetCheckQueue(n int, size int64)
- func (s *StatsInfo) SetRenameQueue(n int, size int64)
- func (s *StatsInfo) SetTransferQueue(n int, size int64)
- func (s *StatsInfo) String() string
- func (s *StatsInfo) Transferring(remote string)
- type WrapFn
Constants ¶
This section is empty.
Variables ¶
var ErrorMaxTransferLimitReached = fserrors.FatalError(errors.New("Max transfer limit reached as set by --max-transfer"))
ErrorMaxTransferLimitReached is returned from Read when the max transfer limit is reached.
var ( // Stats is global statistics counter Stats = NewStats() )
Functions ¶
func SetBwLimit ¶
func SetBwLimit(bandwidth fs.SizeSuffix)
SetBwLimit sets the current bandwidth limit
func StartTokenBucket ¶
func StartTokenBucket()
StartTokenBucket starts the token bucket if necessary
func StartTokenTicker ¶
func StartTokenTicker()
StartTokenTicker creates a ticker to update the bandwidth limiter every minute.
Types ¶
type Account ¶
type Account struct {
// contains filtered or unexported fields
}
Account limits and accounts for one transfer
func NewAccount ¶
func NewAccount(in io.ReadCloser, obj fs.Object) *Account
NewAccount makes a Account reader for an object
func NewAccountSizeName ¶
func NewAccountSizeName(in io.ReadCloser, size int64, name string) *Account
NewAccountSizeName makes a Account reader for an io.ReadCloser of the given size and name
func (*Account) AccountRead ¶
AccountRead account having read n bytes
func (*Account) GetAsyncReader ¶
func (acc *Account) GetAsyncReader() *asyncreader.AsyncReader
GetAsyncReader returns the current AsyncReader or nil if Account is unbuffered
func (*Account) GetReader ¶
func (acc *Account) GetReader() io.ReadCloser
GetReader returns the underlying io.ReadCloser under any Buffer
func (*Account) RemoteStats ¶
RemoteStats produces stats for this file
func (*Account) StopBuffering ¶
func (acc *Account) StopBuffering()
StopBuffering stops the async buffer doing any more buffering
func (*Account) UpdateReader ¶
func (acc *Account) UpdateReader(in io.ReadCloser)
UpdateReader updates the underlying io.ReadCloser stopping the async buffer (if any) and re-adding it
func (*Account) WithBuffer ¶
WithBuffer - If the file is above a certain size it adds an Async reader
type Accounter ¶
type Accounter interface { io.Reader OldStream() io.Reader SetStream(io.Reader) WrapStream(io.Reader) io.Reader }
Accounter accounts a stream allowing the accounting to be removed and re-added
type StatsInfo ¶
type StatsInfo struct {
// contains filtered or unexported fields
}
StatsInfo accounts all transfers
func (*StatsInfo) DoneChecking ¶
DoneChecking removes a check from the stats
func (*StatsInfo) DoneTransferring ¶
DoneTransferring removes a transfer from the stats
if ok is true then it increments the transfers count
func (*StatsInfo) Error ¶
Error adds a single error into the stats, assigns lastError and eventually sets fatalError or retryError
func (*StatsInfo) GetLastError ¶
GetLastError returns the lastError
func (*StatsInfo) GetTransfers ¶
GetTransfers reads the number of transfers
func (*StatsInfo) HadFatalError ¶
HadFatalError returns whether there has been at least one FatalError
func (*StatsInfo) HadRetryError ¶
HadRetryError returns whether there has been at least one non-NoRetryError
func (*StatsInfo) RemoteStats ¶
RemoteStats returns stats for rc
func (*StatsInfo) ResetCounters ¶
func (s *StatsInfo) ResetCounters()
ResetCounters sets the counters (bytes, checks, errors, transfers, deletes) to 0 and resets lastError, fatalError and retryError
func (*StatsInfo) ResetErrors ¶
func (s *StatsInfo) ResetErrors()
ResetErrors sets the errors count to 0 and resets lastError, fatalError and retryError
func (*StatsInfo) RetryAfter ¶
RetryAfter returns the time to retry after if it is set. It will be Zero if it isn't set.
func (*StatsInfo) SetCheckQueue ¶
SetCheckQueue sets the number of queued checks
func (*StatsInfo) SetRenameQueue ¶
SetRenameQueue sets the number of queued transfers
func (*StatsInfo) SetTransferQueue ¶
SetTransferQueue sets the number of queued transfers
func (*StatsInfo) Transferring ¶
Transferring adds a transfer into the stats
type WrapFn ¶
WrapFn wraps an io.Reader (for accounting purposes usually)
func UnWrap ¶
UnWrap unwraps a reader returning unwrapped and wrap, a function to wrap it back up again. If `in` is an Accounter then this function will take the accounting unwrapped and wrap will put it back on again the new Reader passed in.
This allows functions which wrap io.Readers to move the accounting to the end of the wrapped chain of readers. This is very important if buffering is being introduced and if the Reader might be wrapped again.