{"id":13507956,"url":"https://github.com/whitfin/sentix","last_synced_at":"2025-12-12T00:27:57.238Z","repository":{"id":57546677,"uuid":"64177035","full_name":"whitfin/sentix","owner":"whitfin","description":"A cross-platform file watcher for Elixir based on fswatch.","archived":false,"fork":false,"pushed_at":"2020-03-03T22:28:48.000Z","size":35,"stargazers_count":16,"open_issues_count":2,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-27T15:18:11.039Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/whitfin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-26T00:31:22.000Z","updated_at":"2024-07-08T15:52:35.000Z","dependencies_parsed_at":"2022-09-26T18:31:09.846Z","dependency_job_id":null,"html_url":"https://github.com/whitfin/sentix","commit_stats":null,"previous_names":["zackehh/sentix"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/whitfin/sentix","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsentix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsentix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsentix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsentix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/whitfin","download_url":"https://codeload.github.com/whitfin/sentix/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/whitfin%2Fsentix/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269532397,"owners_count":24433283,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-09T02:00:10.424Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:00:44.180Z","updated_at":"2025-12-12T00:27:57.172Z","avatar_url":"https://github.com/whitfin.png","language":"Elixir","funding_links":[],"categories":["Files and Directories"],"sub_categories":[],"readme":"# Sentix\n[![Build Status](https://img.shields.io/travis/zackehh/sentix.svg)](https://travis-ci.org/zackehh/sentix) [![Coverage Status](https://img.shields.io/coveralls/zackehh/sentix.svg)](https://coveralls.io/github/zackehh/sentix) [![Hex.pm Version](https://img.shields.io/hexpm/v/sentix.svg)](https://hex.pm/packages/sentix) [![Documentation](https://img.shields.io/badge/docs-latest-yellowgreen.svg)](https://hexdocs.pm/sentix/)\n\nSentix is a file system watcher based on [fswatch](https://github.com/emcrisostomo/fswatch). It provides a stable port binding around `fswatch` (with configurable arguments) and translates the output to messages that are easy to work with from inside Elixir. Naturally, it goes without saying that you need `fswatch` installed to use this tool properly.\n\n## Installation\n\nSentix is available in Hex so you can install it pretty easily:\n\n  1. Add `sentix` to your list of dependencies in `mix.exs`:\n\n    ```elixir\n    def deps do\n      [{:sentix, \"~\u003e 1.0\"}]\n    end\n    ```\n\n  2. Ensure `sentix` is started before your application:\n\n    ```elixir\n    def application do\n      [applications: [:sentix]]\n    end\n    ```\n\nAs previously mentioned, installing `fswatch` is a pre-req for using Sentix.\n\n## Usage\n\n### Startup\n\nIt's likely that you'll want to setup Sentix inside a Supervisor to ensure fault-tolerance. This can be done as follows:\n\n```elixir\nSupervisor.start_link(\n  [ worker(Sentix, [ :watcher_name, [ \"/path/to/watch\" ] ]) ]\n)\n```\n\nOf course you can also start it manually using `Sentix.start_link(:watcher_name, [ \"/path/to/watch\" ])`.\n\nThe first two arguments to `Sentix.start_link/3` are a name for the Sentix watcher and a list of paths to watch (or a single path, whichever). The third parameter is a list of options which are passed through the `fswatch` port. Please see the [documentation](https://hexdocs.pm/sentix/Sentix.html#start_link/3) for `Sentix.start_link/3` for a full list of options which can be used.\n\n### Subscribing\n\nOnce you have a Sentix watcher running, you can subscribe processes to it to receive the forwarded notifications through the port. This is done using `Sentix.subscribe/2`:\n\n```elixir\nSentix.subscribe(:watcher_name)          # subscribes the calling process\nSentix.subscribe(:watcher_name, :sub)    # subscribe by a process name\nSentix.subscribe(:watcher_name, self())  # subscribe using a pid\n```\n\nA watcher can have any number of subscribers, but remember that more subscribers will result in a longer latency to pickup changes - so it may be that you need to implement grouping if you have a large number of subscribers.\n\nIn the case that a subscribed process is not alive when a message comes in, it will be removed from the watcher subscription list to avoid repeatedly sending messages that will never be received. In addition, an ETS cache is used to persist subscribers across restarts in case the watcher has to restart for any reason - so you don't need to subscribe again if the watcher dies (although you can do so just to be certain, watchers do not store duplicates).\n\n### Receiving Notifications\n\nOnce subscribed, you'll receive messages of the following format:\n\n```elixir\n{ os_process_pid, { :fswatch, :file_event }, { file_path, event_list } }\n```\n\nThe file path is naturally the path of the file which has been affected by a filesystem event. The list of events contains the events passed through by `fswatch`. Please note that these events are modified to atoms instead of the raw names from `fswatch`. For example, the `IsFile` event becomes `:is_file` in Sentix.\n\nThis message format is inspired by that of the [fs](https://github.com/synrc/fs) library to make it possible for developers to migrate between the two projects easily.\n\n## Contributions\n\nThe Sentix API is deliberately tiny, as we leverage `fswatch` to do most of the work. If you have any feature requests, please make sure that it can be supported via the current `fswatch` API, or can easily be implemented (with low cost) on top of the API. Aside from this, please feel free to file an issue if you feel that something can be improved.\n\nIf you file any PRs, you can use the commands below to verify the test coverage of your changes, and the quality of your code (as measured by Credo).\n\n```bash\n$ mix test\n$ mix credo\n$ mix coveralls\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitfin%2Fsentix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwhitfin%2Fsentix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwhitfin%2Fsentix/lists"}