api

package
v0.0.0-...-285fe68 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAck

func IsAck(ident interface{}) bool

Types

type ChanErrSink

type ChanErrSink chan error

func (ChanErrSink) Error

func (s ChanErrSink) Error(err error)

type Command

type Command struct {
	// the type of request. Values in this field will mean different things
	// depending on the driver
	Type int

	// The payload used to fulfill the operation. Maybe nil depending on the
	// driver and the operation
	Payload interface{}

	// A channel where errors can be reported back to the watcher goroutine.
	Reply chan error
}

Command represents a request sent from the fsnotify watcher to the driver. The driver is (presumably) running asynchronously wrt to the watcher, and thus operations that modify the state of the driver are passed via channels.

The Command object is the object that gets passed from the watcher goroutine to the driver goroutine.

type CommandOption

type CommandOption interface {
	Option
	// contains filtered or unexported methods
}

func WithAck

func WithAck(b bool) CommandOption

type CommandQueue

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

func NewCommandQueue

func NewCommandQueue(chooser CommandQueueEgressChooser) *CommandQueue

func (*CommandQueue) Append

func (q *CommandQueue) Append(cmd *Command)

func (*CommandQueue) Drain

func (q *CommandQueue) Drain(ctx context.Context)

func (*CommandQueue) SendCmd

func (q *CommandQueue) SendCmd(cmd *Command, options ...CommandOption) error

type CommandQueueEgressChooseFunc

type CommandQueueEgressChooseFunc func(*Command) chan *Command

func (CommandQueueEgressChooseFunc) Choose

func (fn CommandQueueEgressChooseFunc) Choose(cmd *Command) chan *Command

type CommandQueueEgressChooser

type CommandQueueEgressChooser interface {
	Choose(*Command) chan *Command
}

type Driver

type Driver interface {
	// Add adds a new watch target to the driver.
	Add(string, ...CommandOption) error

	// Remove removes a watch target.
	Remove(string, ...CommandOption) error

	// Run starts the driver's processing of the entries.
	//
	// The second parameter is used to tell the caller (fsnotiy.Wathcer)
	// that the driver is ready to serve requests. When the driver is
	// ready, close the channel to tell the Watcher that it's ready.
	//
	// The third and fourht parameters are where events and errors
	// should be sent from the Driver
	Run(context.Context, chan struct{}, EventSink, ErrorSink)
}

Driver is the interface that must be implemented by the underlying fsnotify implementation.

type ErrorSink

type ErrorSink interface {
	// Error accepts an error that occurred during the execution
	// of `Watch()`. It must be non-blocking.
	Error(error)
}

ErrorSink is the destination where errors are reported to

type Event

type Event interface {
	// Name returns the name of file that caused this event
	Name() string

	// Op is a compatibility layer for github.com/fsnotify/fsnotify.
	Op() OpMask

	// OpMask returns a bitmask of operation(s) that caused this event
	Mask() OpMask

	// String() returns the string representation in a human readable
	// format. Do not expect the string to be stable or parsable.
	String() string
}

Event represents a file system event. It is an interface because driver implementation may want to extend the event and store extra information

func NewEvent

func NewEvent(name string, mask OpMask) Event

type EventSink

type EventSink interface {
	Event(Event)
}

EventSink is the destination where each Driver should send events to.

type NilSink

type NilSink struct{}

func (NilSink) Error

func (NilSink) Error(error)

func (NilSink) Event

func (NilSink) Event(Event)

type NullDriver

type NullDriver struct{}

NullDriver exists to be plugged in when there are no other drivers to be used. fsnotify will not function, but your code will at least not die a horrible death.

func (NullDriver) Add

func (_ NullDriver) Add(_ string, _ ...CommandOption) error

func (NullDriver) Remove

func (_ NullDriver) Remove(_ string, _ ...CommandOption) error

func (NullDriver) Run

func (_ NullDriver) Run(_ context.Context, _ EventSink, _ ErrorSink)

type Op

type Op uint32
const (
	OpCreate Op = 1 << iota
	OpWrite
	OpRemove
	OpRename
	OpChmod
)

func (Op) String

func (op Op) String() string

type OpMask

type OpMask uint32

func (OpMask) IsSet

func (mask OpMask) IsSet(op Op) bool

func (*OpMask) Set

func (mask *OpMask) Set(op Op)

func (OpMask) String

func (mask OpMask) String() string

func (*OpMask) Unset

func (mask *OpMask) Unset(op Op)

type Option

type Option = option.Interface

Jump to

Keyboard shortcuts

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