Documentation ¶
Overview ¶
Package notify provides some notification services to be used by box services.
Index ¶
- Variables
- type DirEntry
- type DirService
- func (ds *DirService) DeleteDirEntry(zid id.Zid) error
- func (ds *DirService) GetDirEntries(constraint query.RetrievePredicate) []*DirEntry
- func (ds *DirService) GetDirEntry(zid id.Zid) *DirEntry
- func (ds *DirService) NumDirEntries() int
- func (ds *DirService) Refresh()
- func (ds *DirService) RenameDirEntry(oldEntry *DirEntry, newZid id.Zid) (DirEntry, error)
- func (ds *DirService) SetNewDirEntry() (id.Zid, error)
- func (ds *DirService) Start()
- func (ds *DirService) State() DirServiceState
- func (ds *DirService) Stop()
- func (ds *DirService) UpdateDirEntry(updatedEntry *DirEntry) error
- type DirServiceState
- type EntryFetcher
- type Event
- type EventOp
- type Notifier
Constants ¶
This section is empty.
Variables ¶
var ErrNoDirectory = errors.New("unable to retrieve zettel directory information")
ErrNoDirectory signals missing directory data.
Functions ¶
This section is empty.
Types ¶
type DirEntry ¶
type DirEntry struct { Zid id.Zid MetaName string // file name of meta information ContentName string // file name of zettel content ContentExt string // (normalized) file extension of zettel content UselessFiles []string // list of other content files }
DirEntry stores everything for a directory entry.
func (*DirEntry) HasMetaInContent ¶
HasMetaInContent returns true, if metadata will be stored in the content file.
type DirService ¶
type DirService struct {
// contains filtered or unexported fields
}
DirService specifies a directory service for file based zettel.
func NewDirService ¶
func NewDirService(box box.ManagedBox, log *logger.Logger, notifier Notifier, chci chan<- box.UpdateInfo) *DirService
NewDirService creates a new directory service.
func (*DirService) DeleteDirEntry ¶
func (ds *DirService) DeleteDirEntry(zid id.Zid) error
DeleteDirEntry removes a entry from the directory.
func (*DirService) GetDirEntries ¶
func (ds *DirService) GetDirEntries(constraint query.RetrievePredicate) []*DirEntry
GetDirEntries returns a list of directory entries, which satisfy the given constraint.
func (*DirService) GetDirEntry ¶
func (ds *DirService) GetDirEntry(zid id.Zid) *DirEntry
GetDirEntry returns a directory entry with the given zid, or nil if not found.
func (*DirService) NumDirEntries ¶
func (ds *DirService) NumDirEntries() int
NumDirEntries returns the number of entries in the directory.
func (*DirService) RenameDirEntry ¶
RenameDirEntry replaces an existing directory entry with a new one.
func (*DirService) SetNewDirEntry ¶
func (ds *DirService) SetNewDirEntry() (id.Zid, error)
SetNewDirEntry calculates an empty directory entry with an unused identifier and stores it in the directory.
func (*DirService) State ¶ added in v0.11.0
func (ds *DirService) State() DirServiceState
State the current service state.
func (*DirService) UpdateDirEntry ¶
func (ds *DirService) UpdateDirEntry(updatedEntry *DirEntry) error
UpdateDirEntry updates an directory entry in place.
type DirServiceState ¶ added in v0.11.0
type DirServiceState uint8
DirServiceState signal the internal state of the service.
The following state transitions are possible: --newDirService--> dsCreated dsCreated --Start--> dsStarting dsStarting --last list notification--> dsWorking dsWorking --directory missing--> dsMissing dsMissing --last list notification--> dsWorking --Stop--> dsStopping
const ( DsCreated DirServiceState = iota DsStarting // Reading inital scan DsWorking // Initial scan complete, fully operational DsMissing // Directory is missing DsStopping // Service is shut down )
type EntryFetcher ¶
EntryFetcher return a list of (file) names of an directory.
type EventOp ¶
type EventOp uint8
EventOp describe a notification operation.
const ( Error EventOp // Error while operating Make // Make container List // List container Destroy // Destroy container Update // Update element Delete // Delete element )
Valid constants for event operations.
Error signals a detected error. Details are in Event.Err.
Make signals that the container is detected. List events will follow.
List signals a found file, if Event.Name is not empty. Otherwise it signals the end of files within the container.
Destroy signals that the container is not there any more. It might me Make later again.
Update signals that file Event.Name was created/updated. File name is relative to the container.
Delete signals that file Event.Name was removed. File name is relative to the container's name.
type Notifier ¶
type Notifier interface { // Return the channel Events() <-chan Event // Signal a refresh of the container. This will result in some events. Refresh() // Close the notifier (and eventually the channel) Close() }
Notifier send events about their container and content.
func NewFSDirNotifier ¶
NewFSDirNotifier creates a directory based notifier that receives notifications from the file system.
func NewSimpleDirNotifier ¶
NewSimpleDirNotifier creates a directory based notifier that will not receive any notifications from the operating system.