fileWatcher

package
v0.0.0-...-126e10b Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: MIT Imports: 5 Imported by: 0

README

File Watcher Service

The purpose of this Service Mesh service is to provide a single service responsible watching for filesystem changes to files and calling handler functions when those files change.

Dependencies

This service has dependencies on all other Diablo2 file-loader services:


This service exports an integration interface IsFoo with an alias Dependencncy which are intended to be used by other services for dependency resolution (see servicemesh.HasDependencies), and expose just the methods which other services should use.

type Dependency = Foo

type IsFoo interface {
    Foo()
}

Lua service integration

Describe how this service integrates with the lua service (this is just an example).

You should show an example of the lua API usage:

data = assets.load("/data/global/ui/Loading/loadingscreen.dc6")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dependency

type Dependency = IsFileWatcher

type FileHandlerFunc

type FileHandlerFunc = func(path string) error

type IsFileWatcher

type IsFileWatcher interface {
	AddWatcher(path string, f func(path string) error)
	WatchAndLoad(path string, f func(path string) error)
	CloseWatcher()
}

type NeedsFileWatcher

type NeedsFileWatcher interface {
	FileHandlers() map[string]FileHandlerFunc
}

NeedsFileWatcher is an integration interface intended to be implemented by other services to integrate with and be maintained by this file watcher service.

type Service

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

func (*Service) AddWatcher

func (s *Service) AddWatcher(path string, f func(path string) error)

AddWatcher watches the given file for changes and invokes f with the file path when a change is detected.

func (*Service) CloseWatcher

func (s *Service) CloseWatcher()

CloseWatcher closes the watcher for file changes.

func (*Service) Init

func (s *Service) Init(mesh servicemesh.Mesh)

func (*Service) Logger

func (s *Service) Logger() *slog.Logger

func (*Service) Name

func (s *Service) Name() string

func (*Service) OnServiceAdded

func (s *Service) OnServiceAdded(service servicemesh.Service)

func (*Service) Ready

func (s *Service) Ready() bool

func (*Service) SetLogger

func (s *Service) SetLogger(logger *slog.Logger)

func (*Service) WatchAndLoad

func (s *Service) WatchAndLoad(path string, f func(path string) error)

WatchAndLoad watches the given file for changes and invokes f with the file path when a change is detected. The given file is loaded once using f when calling WatchAndLoad.

Jump to

Keyboard shortcuts

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