{"id":20576499,"url":"https://github.com/zalky/axle","last_synced_at":"2025-06-24T04:08:52.711Z","repository":{"id":65631796,"uuid":"537329068","full_name":"zalky/axle","owner":"zalky","description":"An efficient cross-platform DirectoryWatcher based service for Clojure","archived":false,"fork":false,"pushed_at":"2023-02-04T07:35:48.000Z","size":10,"stargazers_count":41,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-15T15:54:44.318Z","etag":null,"topics":["clojure","directory-watcher"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalky.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":"2022-09-16T06:14:04.000Z","updated_at":"2024-09-24T19:55:29.000Z","dependencies_parsed_at":"2023-02-18T14:45:16.633Z","dependency_job_id":null,"html_url":"https://github.com/zalky/axle","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/zalky/axle","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalky%2Faxle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalky%2Faxle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalky%2Faxle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalky%2Faxle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalky","download_url":"https://codeload.github.com/zalky/axle/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalky%2Faxle/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260665526,"owners_count":23044283,"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","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":["clojure","directory-watcher"],"created_at":"2024-11-16T05:45:59.546Z","updated_at":"2025-06-24T04:08:52.684Z","avatar_url":"https://github.com/zalky.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"https://i.imgur.com/GH71uSi.png\" title=\"zalky\" align=\"right\" width=\"250\"/\u003e\n\n# Axle\n\n[![Clojars Project](https://img.shields.io/clojars/v/io.zalky/axle?labelColor=blue\u0026color=green\u0026style=flat-square\u0026logo=clojure\u0026logoColor=fff)](https://clojars.org/io.zalky/axle)\n\nAxle is an efficient cross-platform DirectoryWatcher based service\nfor Clojure.\n\nBarbaryWatchService for Mac is considered deprecated and no longers\nworks with newer versions of Java. This means existing watcher\nimplementations that depend on it, like\n[Hawk](https://github.com/wkf/hawk), no longer perform well. Axle\nintroduces a `axle.core/watch!` fn that is a thin wrapper of the\ncross-platform, high performance\n[DirectoryWatcher](https://github.com/gmethvin/directory-watcher).\n\n## Getting Started\n\nJust add the following dependency in your `deps.edn`:\n\n```clj\nio.zalky/axle {:mvn/version \"0.2.1\"}\n```\n\nYou can start a watch task like so:\n\n```clj\n(require '[axle.core :as axle])\n\n(def watcher\n  (axle/watch!\n   {:paths   [\"src/clojure\" \"src/assets\"]\n    :context {:init \"context\"}\n    :handler (fn [context event]\n               (update-context ...))}))\n```\n\nWhere `:handler` is a reducing function that accepts the current\ncontext and a file event to return an updated context, `:paths` is a\nlist of paths (to individual files or directories) to watch, and\noptionally, `:context` is the initial value of the accumulated\ncontext.\n\nFile events have the following form:\n\n```clj\n{:type       :modify,\n :path       \"/path/to/file.clj\",\n :count      1,\n :root-path  \"src\",\n :directory? false,\n```\n\nThere are four event types, `:create`, `:delete`, `:modify` and\n`:overflow` (which is emitted if the file system is generating events\nfaster than the underlying implementation can process them).\n\nEach event can optionally include a file hash. Since this affects\nperformance it is disabled by default, but can be turned on via the\n`:file-hashing true` option:\n\n```clj\n(def watcher\n  (axle/watch!\n   {:paths        [\"src/clojure\" \"src/assets\"]\n    :handler      handler\n    :file-hashing true}))\n```\n\nNow events will include an additional `:hash` attribute.\n\nOn uncaught exceptions, `watch!` will print a stacktrace that includes\nthe context at the time of the error. However, you should consider\ncatching errors in your handler, where you have access to both the\ncontext and the event, and also have the option to update the context\nin response to an error.\n\nFinally, a watch task can be stopped via:\n\n```clj\n(axle/stop! watcher)\n```\n\n### Windowing\n\nYou can return a windowing handler, which handles a collection of\nevents that have occurred within a certain number of milliseconds,\nvia:\n\n```clj\n{:handler (axle/window ms (fn handler [context events] ...))}\n```\nWhere `events` is just a sequence of event maps, and `ms` is just an\ninteger number of milliseconds.\n\n## Alternatives\n\n[Beholder](https://github.com/nextjournal/beholder) is a similar\n`DirectoryWatcher` based wrapper. However, its callback is not a\nreducing function, so you cannot accumulate a context, and it does not\nprovide windowing functionality.\n\n## License\n\nAxle is distributed under the terms of the Apache License 2.0.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalky%2Faxle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalky%2Faxle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalky%2Faxle/lists"}