SecretsWatcherFileSystem (secrets_watcher_file_system v0.2.10) View Source
A GenServer
process to watch file system changes.
The process receives data from Port, parse event, and send it to the worker process.
Link to this section Summary
Link to this section Functions
Specs
start_link(Keyword.t()) :: GenServer.on_start()
Starts a GenServer
process and linked to the current process.
Options
:dirs
([string], required), the list of directory to monitor.:backend
(atom, optional), default backends::fs_mac
. Available backends::fs_mac
,:fs_inotify
, and:fs_windows
.:name
(atom, optional), thename
of the worker process to subscribe to the file system listerner. Alternative to usingpid
of the worker process.Additional backend implementation options. See backend module documents for more details.
Examples
Start monitoring /tmp/fs
directory using the default :fs_mac
backend of
the current process:
iex> {:ok, pid} = SecretsWatcherFileSystem.start_link(dirs: ["/tmp/fs"])
iex> SecretsWatcherFileSystem.subscribe(pid)
Get instant (latench: 0
) notifications on file changes:
iex> SecretsWatcherFileSystem.start_link(dirs: ["/path/to/some/files"], latency: 0)
Minitor a directory by a process name:
iex> SecretsWatcherFileSystem.start_link(backend: :fs_mac, dirs: ["/tmp/fs"], name: :worker)
iex> SecretsWatcherFileSystem.subscribe(:worker)
Specs
subscribe(GenServer.server()) :: :ok
Register the current process as a subscriber of a file_system
worker.
The pid
you subscribed from will now receive messages like:
{:file_event, worker_pid, {file_path, events}}
{:file_event, worker_pid, :stop}