{"action":"created","issue":{"url":"https://api.github.com/repos/mirage/irmin/issues/187","labels_url":"https://api.github.com/repos/mirage/irmin/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/mirage/irmin/issues/187/comments","events_url":"https://api.github.com/repos/mirage/irmin/issues/187/events","html_url":"https://github.com/mirage/irmin/pull/187","id":67202721,"number":187,"title":"Watches","user":{"login":"samoht","id":103693,"avatar_url":"https://avatars.githubusercontent.com/u/103693?v=3","gravatar_id":"","url":"https://api.github.com/users/samoht","html_url":"https://github.com/samoht","followers_url":"https://api.github.com/users/samoht/followers","following_url":"https://api.github.com/users/samoht/following{/other_user}","gists_url":"https://api.github.com/users/samoht/gists{/gist_id}","starred_url":"https://api.github.com/users/samoht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samoht/subscriptions","organizations_url":"https://api.github.com/users/samoht/orgs","repos_url":"https://api.github.com/users/samoht/repos","events_url":"https://api.github.com/users/samoht/events{/privacy}","received_events_url":"https://api.github.com/users/samoht/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-08T19:35:20Z","updated_at":"2015-04-08T19:43:52Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/mirage/irmin/pulls/187","html_url":"https://github.com/mirage/irmin/pull/187","diff_url":"https://github.com/mirage/irmin/pull/187.diff","patch_url":"https://github.com/mirage/irmin/pull/187.patch"},"body":"Not ready to merge yet. Here is the current status:\r\n\r\n- the code compiles but is totally untested (so assume it is broken)\r\n\r\n- there is no unit-tests at all for the notification code (the old one as well as the new one). I'll add extensive tests before envisaging merging.\r\n\r\n- the new API is much simpler than the previous one, with explicit de-allocation and clearer concurrency semantics. Basically you now only have:\r\n    ```ocaml\r\n  type 'a diff = [ `Updated of 'a * 'a | `Added of 'a | `Removed of 'a ]\r\n\r\n  val watch_tag: t -> ?init:head -> (head diff -> unit Lwt.t) ->\r\n    (unit -> unit Lwt.t) Lwt.t\r\n  (** [watch_tag t f] calls [f] everytime the contents of [t]'s tag is\r\n      updated. Do nothing if [t] is not persistent. Return a clean-up\r\n      function to remove the watch handler.\r\n\r\n      {b Note:} even [f] might skip some head updates, it will never\r\n      be called concurrently: all consecutive calls to [f] are done in\r\n      sequence, so we ensure that the previous one ended before\r\n      calling the next one. *)\r\n\r\n  val watch_tags: t -> ?init:(tag * head) list ->\r\n    (tag -> head diff -> unit Lwt.t) -> (unit -> unit Lwt.t) Lwt.t\r\n  (** [watch_tags t f] calls [f] to the watch handlers of {b all} tag\r\n      changes in the local store. Return a function to remove the\r\n      handler. *)\r\n    ```\r\n     I'm not totally convinced about the function names yet, but the types are ok now I think. Basically, you register a callback which is called on every update. If multiple callbacks are registered, they are called in sequence, and they won't overloap with each other. \r\n\r\n- There is not (yet?) an optimisation to clean-up the callback calls in case the waiting queue become too big and starts to lag. I'm not sure it is necessary, I plan to run some stress-tests to see how it works under load with lots of long-running callback function.\r\n\r\n- The previous API which let you watch for changes in sub-path has been completely removed. This was designed first to look like xenstore watches, but with subtle semantic differences so not really useful as they were. I plan to maybe add back something similar later if people needs it, but for now I prefer relying on fewer well-tested functions."},"comment":{"url":"https://api.github.com/repos/mirage/irmin/issues/comments/91015200","html_url":"https://github.com/mirage/irmin/pull/187#issuecomment-91015200","issue_url":"https://api.github.com/repos/mirage/irmin/issues/187","id":91015200,"user":{"login":"samoht","id":103693,"avatar_url":"https://avatars.githubusercontent.com/u/103693?v=3","gravatar_id":"","url":"https://api.github.com/users/samoht","html_url":"https://github.com/samoht","followers_url":"https://api.github.com/users/samoht/followers","following_url":"https://api.github.com/users/samoht/following{/other_user}","gists_url":"https://api.github.com/users/samoht/gists{/gist_id}","starred_url":"https://api.github.com/users/samoht/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samoht/subscriptions","organizations_url":"https://api.github.com/users/samoht/orgs","repos_url":"https://api.github.com/users/samoht/repos","events_url":"https://api.github.com/users/samoht/events{/privacy}","received_events_url":"https://api.github.com/users/samoht/received_events","type":"User","site_admin":false},"created_at":"2015-04-08T19:43:52Z","updated_at":"2015-04-08T19:43:52Z","body":"> Actually, I was wondering about that. Is there a way to watch changes to value in path, i.e., I commit new value?\r\n\r\nnot anymore, but I can add back that some helper functions doing that if it is useful for you."}}