asyncstat

package
v0.0.0-...-e2c53ed Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

README

Package cloudeng.io/file/filewalk/asyncstat

import cloudeng.io/file/filewalk/asyncstat

Variables

DefaultAsyncStats, DefaultAsyncThreshold
// DefaultAsyncStats is the default maximum number of async stats to be issued
// when WithAsyncStats is not specified.
DefaultAsyncStats = 100
// DefaultAsyncThreshold is the default value for the number of directory
// entries that must be present before async stats are used when
// WithAsyncThreshold is not specified.
DefaultAsyncThreshold = 10

Types

Type Configuration
type Configuration struct {
	AsyncStats     int
	AsyncThreshold int
}
Type ErrorLogger
type ErrorLogger func(ctx context.Context, filename string, err error)

ErrorLogger is the type of function called when a Stat or Lstat return an error.

Type LatencyTracker
type LatencyTracker interface {
	Before() time.Time
	After(time.Time)
}

LatencyTracker is used to track the latency of Stat or Lstat operations.

Type Option
type Option func(*options)

Option is used to configure an asyncstat.T.

Functions
func WithAsyncStats(stats int) Option

WithAsyncStats sets the total number of asynchronous stats to be issued. The default is DefaultAsyncStats.

func WithAsyncThreshold(threshold int) Option

WithAsyncThreshold sets the threshold at which asynchronous stats are used, any directory with less than number of entries will be processed synchronously. The default is DefaultAsyncThreshold.

func WithErrorLogger(fn ErrorLogger) Option

WithErrorLogger sets the function to be called when an error is returned by Stat or Lstat.

func WithLStat() Option

WithLStat requests that fs.LStat be used instead of fs.Stat. This is the default.

func WithLatencyTracker(lt LatencyTracker) Option

WithLatencyTracker sets the latency tracker to be used.

func WithStat() Option

WithStat requests that fs.Stat be used instead of fs.LStat.

Type T
type T struct {
	// contains filtered or unexported fields
}

T provides support for issuing asynchronous stat or lstat calls.

Functions
func New(fs filewalk.FS, opts ...Option) *T

New returns an aysncstat.T that uses the supplied filewalk.FS.

Methods
func (is *T) Configuration() Configuration
func (is *T) Process(ctx context.Context, prefix string, entries []filewalk.Entry) (children, all file.InfoList, err error)

Process processes the supplied entries, returning the list of children as filewalk.Entry and the list of stat/lstat results as a file.InfoList.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultAsyncStats is the default maximum number of async stats to be issued
	// when WithAsyncStats is not specified.
	DefaultAsyncStats = 100
	// DefaultAsyncThreshold is the default value for the number of directory
	// entries that must be present before async stats are used when
	// WithAsyncThreshold is not specified.
	DefaultAsyncThreshold = 10
)

Functions

This section is empty.

Types

type Configuration

type Configuration struct {
	AsyncStats     int
	AsyncThreshold int
}

type ErrorLogger

type ErrorLogger func(ctx context.Context, filename string, err error)

ErrorLogger is the type of function called when a Stat or Lstat return an error.

type LatencyTracker

type LatencyTracker interface {
	Before() time.Time
	After(time.Time)
}

LatencyTracker is used to track the latency of Stat or Lstat operations.

type Option

type Option func(*options)

Option is used to configure an asyncstat.T.

func WithAsyncStats

func WithAsyncStats(stats int) Option

WithAsyncStats sets the total number of asynchronous stats to be issued. The default is DefaultAsyncStats.

func WithAsyncThreshold

func WithAsyncThreshold(threshold int) Option

WithAsyncThreshold sets the threshold at which asynchronous stats are used, any directory with less than number of entries will be processed synchronously. The default is DefaultAsyncThreshold.

func WithErrorLogger

func WithErrorLogger(fn ErrorLogger) Option

WithErrorLogger sets the function to be called when an error is returned by Stat or Lstat.

func WithLStat

func WithLStat() Option

WithLStat requests that fs.LStat be used instead of fs.Stat. This is the default.

func WithLatencyTracker

func WithLatencyTracker(lt LatencyTracker) Option

WithLatencyTracker sets the latency tracker to be used.

func WithStat

func WithStat() Option

WithStat requests that fs.Stat be used instead of fs.LStat.

type T

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

T provides support for issuing asynchronous stat or lstat calls.

func New

func New(fs filewalk.FS, opts ...Option) *T

New returns an aysncstat.T that uses the supplied filewalk.FS.

func (*T) Configuration

func (is *T) Configuration() Configuration

func (*T) Process

func (is *T) Process(ctx context.Context, prefix string, entries []filewalk.Entry) (children, all file.InfoList, err error)

Process processes the supplied entries, returning the list of children as filewalk.Entry and the list of stat/lstat results as a file.InfoList.

Jump to

Keyboard shortcuts

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