Skip to content

Loading…

[2.2] [WIP] ResourceWatcher component refactored #3961

Closed
wants to merge 72 commits into from

9 participants

@everzet

REBASED TO #4605

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes (for old tests) and partly (InotifyTracker is not yet finished)
Fixes the following tickets: -

This is refactoring of #391, which:

  • Uses EventDispatcher component for events routing
  • Uses inotify naming convention for event types (IN_CREATE, IN_MODIFY, IN_DELETE).

Short overview

This component is here for tracking filesystem changes. You're registering directory or file resources to track with specific track name (tracking_id) and start() watcher. Watcher checks for FS changes after specific timespan and if some change occur (file/directory create/update/delete) - watcher dispatches EventDispatcher event with resource_watcher.all, resource_watcher.tracking_id names and FilesystemEvent as argument.

Usage

Simplest possible way of FS tracking

Simplest tracking code would look like this:

<?php

$watcher = new Symfony\Component\ResourceWatcher\ResourceWatcher;

// track for any change inside `config` subfolder:
$watcher->trackByListener(__DIR__.'/config', function($event) {
    echo $event->getTypeString().': '.(string) $event->getResource();
});

// start listening
$watcher->start();

best suitable Tracker and EventDispatcher would be instantiated for you, implicitly

track() method

Extended usage looks like that:

<?php

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\ResourceWatcher;
use Symfony\Component\Config\Resource;

$dispatcher = new EventDispatcher;
$tracker = new ResourceWatcher\Tracker\RecursiveIteratorTracker;
$watcher = new ResourceWatcher\ResourceWatcher($tracker, $dispatcher);

// track for any change in `view` subfolder to `twig.templates` tracker:
$watcher->track('twig.templates', __DIR__.'/view');

// track for `*.xml` files creations in `config` subfolder to `routing` tracker:
$watcher->track(
    'routing',
    Resource\DirectoryResource(__DIR__.'/config', '/\.xml$/'),
    ResourceWatcher\Event\FilesystemEvent::IN_CREATE
);

// add `routing` track listener:
$dispatcher->addListener('resource_watcher.routing', function($event) {
    echo $event->getTypeString().': '.(string) $event->getResource();
});

// add all tracks listener (listens to every tracked event):
$dispatcher->addListener('resource_watcher.all', function($event) {
    echo $event->getTypeString().': '.(string) $event->getResource();
});

// start listening
$watcher->start();

addListener() method

If you don't want to deal with EventDispatcher, ResourceWatcher can hide this detail for you:

<?php

use Symfony\Component\ResourceWatcher;
use Symfony\Component\Config\Resource;

$tracker = new ResourceWatcher\Tracker\RecursiveIteratorTracker;
$watcher = new ResourceWatcher\ResourceWatcher($tracker);

// track for any change in `view` subfolder to `twig.templates` tracker:
$watcher->track('twig.templates', __DIR__.'/view');

// track for `*.xml` files creations in `config` subfolder to `routing` tracker:
$watcher->track(
    'routing',
    Resource\DirectoryResource(__DIR__.'/config', '/\.xml$/'),
    ResourceWatcher\Event\FilesystemEvent::IN_CREATE
);

// add `routing` track listener:
$watcher->addListener('routing', function($event) {
    echo $event->getTypeString().': '.(string) $event->getResource();
});

// add all tracks listener (listens to every tracked event):
$watcher->addListener('all', function($event) {
    echo $event->getTypeString().': '.(string) $event->getResource();
});

// start listening
$watcher->start();

WIP

InotifyTracker is not ready as i have problems testing it (no Inotify on MacOS). Help here would be highly appreciated - test suite is ready, requirement is to make InotifyTrackerTest green.

everzet and others added some commits
@everzet everzet [ResourceWatcher] resource change event created a30ef7e
@everzet everzet [ResourceWatcher] resource event listener interface described 443c2b4
@everzet everzet [ResourceWatcher] created basic resource event listener object b9f0ab8
@everzet everzet [ResourceWatcher] resource state checker interface described 937882b
@everzet everzet [ResourceWatcher] created recursive iterator resource state checker
this is a basic state checker, which checks all
files and directories recursively for changes
2b4be01
@everzet everzet [ResourceWatcher] resources tracker interface described cb11c9b
@everzet everzet [ResourceWatcher] recursive iterator resources tracker created
this resources tracker uses recursive iterator state
checker internally
d97d728
@everzet everzet [ResourceWatcher] resource watcher object created 752dc6c
@everzet everzet [ResourceWatcher] inotify tracker added 893acfb
@everzet everzet [ResourceWatcher] use best tracker by default
if no tracker were specified in watcher constructor
it will use best one (inotify if available and rec
otherwise)
8dd8e9f
@everzet everzet [ResourceWatcher] renamed Event::handes to Event::supports to be cons…
…istent with other parts of the framework.
51d54c7
@everzet everzet [ResourceWatcher] fixed non-empty directory events 38c92ea
@everzet everzet [Config] updated resources API to be more explicit f3389ce
@everzet everzet [Config] moved DirectoryResource childs retrieving to the special get…
…FilteredChilds method
c3a710b
@everzet everzet [ResourceWatcher] cleaned code little bit 690507b
@everzet everzet [ResourceWatcher] refactored recursive state checkers into 2 separate…
… classes
f7e2267
@everzet everzet [Config] getFilteredChildResources() method added to DirectoryResource 7f720a4
@everzet everzet [ResourceWatcher] refactored recursive iterator tracker to support ne…
…w state checkers
b8349ec
@everzet everzet [Config] updated DirectoryResource tests 3d0e65b
@everzet everzet [Config] update FileResourceTest ab746a3
@everzet everzet [ResourceWatcher] removed InotifyTracker as i have no ability to test…
… it yet
f3dafd6
@everzet everzet [Config] added new methods and their tests to File and Directory reso…
…urces
ed39212
@everzet everzet [ResourceWatcher] updated ResourceWatcher and TrackerInterface bd5079f
@everzet everzet [ResourceWatcher] added time information to events bcbf12d
@everzet everzet [ResourceWatcher] updated FileStateChecker to match FileResource API adbac59
@everzet everzet [ResourceWatcher] refactored DirectoryStateChecker fa5a603
@everzet everzet [ResourceWatcher] refactored RecursiveIteratorTracker 2132e24
@everzet everzet [ResourceWatcher] updated StateCheckerInterface 8510398
@everzet everzet [ResourceWatcher] return of the InotifyTracker c9fa57f
@fabpot fabpot [ResourceWatcher] removed unneeded code 688b8c6
@fabpot fabpot [ResourceWatcher] added an exception when inotify is not available fff3dce
@fabpot fabpot [Config] made ResourceInterface extends Serializable fe9cacb
@fabpot fabpot [ResourceWatcher] removed dead code 7579abc
@fabpot fabpot [ResourceWatcher] added the possibility to watch files that do not ex…
…ist yet

* fixed DELETED event when starting to watch a file that does not exist yet
* fixed files that are deleted and then re-created
dda358e
@fabpot fabpot [ResourceWatcher] added exception classes for the component 15e7406
@fabpot fabpot - a453dd2
@everzet everzet [ResourceWatcher] moved tests into component folder 5daa931
@everzet everzet [ResourceWatcher] refactored event subsystem
- FilesystemEvent is now child of the EventDispatcher\Event
- supported FilesystemEvent types are now inotify-like named
- FilesystemEvent now operates two resources:
  - TrackedResource - resource, which initialized tracking
  - ResourceInterface - resource, which have been modified
- lot of new useful getters like isFileChange(), isDirectoryChange() or getTypeString()
662271a
@everzet everzet [ResourceWatcher] added TrackedResource class
This class holds all necessary information about resource,
being tracked
b56ab6f
@everzet everzet [ResourceWatcher] refactored ResourceWatcher
Now, ResourceWatcher:

- uses EventDispatcher for sending events
- provides couple of useful methods, like track(), listen() or trackBy()

track() method has been refactored too. Now it expects 3 arguments:

- trackingId - name of the track
- resource - resource instance or file/dir path
- eventsMask - what changes to track

trackingId is used to differentiate tracks from each other.
ResourceWatcher dispatches 2 EventDispatcher events for each FS event:

- `resource_watcher.all` - if someone wants to track ALL tracked FS events -
  this is a name to catch them with EventDispatcher
- `resource_watcher.{trackingId}` - events of specific track

If user don't want to deal with event dispatcher directly, ResourceWatcher provides
couple of useful help methods:

- listen() - accepts trackingId and callback, which will be called on track events
- trackBy() - same as consequent calls to track() and listen()
0b8a294
@everzet everzet [ResourceWatcher] refactored TrackerInterface
- removed isResourceTracked()
- track() now accepts 2 arguments - TrackedResource and events mask
53d8d6f
@everzet everzet [ResourceWatcher] refactored RecursiveIteratorTracker to support new …
…TrackerInterface

also, class code were been highly simplified
2c170b1
@everzet everzet [ResourceWatcher] added support for events mask in ResourceStateChecker
now state checker sends event only if tracker expects this type of events
730e7f6
@everzet everzet [ResourceWatcher] refactored state checkers to support new interfaces…
… and requirements
b7ab255
@everzet everzet [ResourceWatcher] refactored TrackerTest and added missing test cases 0aa1ee9
@everzet everzet [ResourceWatcher] added missing TrackerTest cases 7d244af
@everzet everzet [ResourceWatcher] optimized TrackerTest cases a34f4b1
@everzet everzet [ResourceWatcher] started InotifyTracker refactoring e3c260b
@everzet everzet [ResourceWatcher] cleaned ResourceWatcher API to be more consistent w…
…ith other components
0018ed7
@jalliot

Could it be possible to add the resource watcher as a service in the DIC? Based on inotify if available, and fallback to the recursive check otherwise.

@everzet

@jalliot it's DIC extension or compiler pass work, not component.

@jalliot

@everzet Not sure what you meant but what I proposed was adding it as a service in FrameworkBundle (and no need for a compiler pass, registering it in the FrameworkBundle extension should be enough).
EDIT: after re-reading your comment, I get what you meant and yes I know this is the framework bundle DIC extension's work and not the component's work to register the service but nothing forbids to add it in the PR I believe :)

@everzet

I'll try to finish InotifyTracker this evening, after installing Ubuntu in my ParallelsDesktop :-)

Problem with Inotify is that it tracks only 1-level directory changes. So, you need to track every new subfolder with hands. Also, file events should be fired with hands in case when newly created folder has content (copy-paste, move), cuz those events wouldn't be fired.

In addition to that, Inotify events contain relative (to tracked resource) paths, not full one. So, you need to absolutize them with hands, again.

At the end of the day, Inotify solution is not so clear, it's hybrid of some sort. But should be more efficient with resources anyway.

RecursiveIteratorTracker works as expected anyway and i'm quite happy with it.

@everzet

@fabpot i can't make damn inotify work on my VM Ubuntu. What about dropping InotifyTracker for now and concentrate on RecursiveIteratorTracker, which works on every platform and is quite responsive? We can merge this PR with only RecursiveIteratorTracker, making ResourceWatcher available for 2.1, cuz i'm quite happy with API. Then, we would be able to add InotifyTracker or other trackers if someone will have strenghts or interest to do it. What do you think? Does it make sense? @stof @schmittjoh ?

@stof
Symfony member

@everzet agreed. If the cross-platform implementation works well, it is worth adding it without the InotifyTracker. Supporting Inotify can be added later (maybe postponed to 2.2 if needed)

@mvrhov

I've run tests on my 10.04 ubuntu image and the only test failing is.

There was 1 failure:

1) Symfony\Component\Config\Tests\Resource\DirectoryResourceTest::testGetFilteredChilds
Failed asserting that 6 is identical to 5.

/srv/www/github/symfony2/src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php:212

FAILURES!
Tests: 17, Assertions: 30, Failures: 1.

The problem is that getFilteredChilds() also returns .

@everzet

@mvrhov checking on my Ubuntu VM. Thanks for pointing. On OSX everything works fine.

@everzet

@mvrhov yup, there is a bug. I'll fix it in couple of minutes.

@everzet

@mvrhov fixed. Thanks once again ;-)

@everzet

@fabpot i've removed InotifyTracker. I'll add couple of functional tests for ResourceWatcher class in coming hour and i think, we could merge it :)

@fabpot
Symfony member

Removing InotifyTracker is probably not a good idea. The composant should be able to work with native implementations to make things as fast as possible and to reduce CPU usage. If we do not ship with any of those, how can we ensure that we will be able to add them later on?

@awildeep

What about http://pypi.python.org/pypi/MacFSEvents/0.2.4 or something similar for OSX users?

@everzet

@fabpot The problem here is that we'll never be sure. There's only inotify extension and only on Linux. When and if MacFSEvents (and some Win32 analog) extension would be created - i'm not sure we'll be able to support it without breaks too. And most-likely we'll break things if we want to have universal solution at the end. Planning to release everything at the beginning isn't the best way to do it.

The idea here is not to abandon InotifyTracker, but postpone it till someone with time and Linux on machine will add it. For now, there's already working component, that we can use in lot of cases and if we'll need to change something in it later - we'll change it. I don't propose to release it as final code, but it already does the job well and we can leverage it in core and 3rd-party bundles.

I'm not telling that we can't release this component with InotifyTracker. But I currently have no time to make it possible for 2.1 and we already see, that component is really much awaited and needed in 2.1.

@awildeep there's no MacFSEvents extension for php currently :(

@simensen

I'd rather not have inotify hold back this component. It can be worked on down the road if and when resources become available.

@weaverryan weaverryan referenced this pull request in symfony/symfony-docs
Closed

[ResourceWatcher] Bootstrapped documentation #1180

@everzet

@fabpot so what we're deciding here ? :-)

@Dattaya

i'm going to work on InotifyTracker.
@everzet could you look at everzet/symfony#1 and answer my questions, please?

@everzet

@Dattaya great news.

@Dattaya

It's almost done, all tests are green(3.0.0-1-amd64, PHP 5.4.0-3, inotify-0.1.6), even those that RecursiveIteratorTracker doesn't pass.
It most likely has few bugs, tests need to be rearranged and cleaned up, it also lacks of docblocks and another minor flaws. But before I'll fix them I'd like to know your opinions, especially yours, @everzet, since you have experience with it.
https://github.com/Dattaya/symfony/tree/resource-watcher-inotify-tracker

@stof
Symfony member

For people wanting to look at it, the diff between @Dattaya's branch and @everzet's branch is here

@stof
Symfony member

@Dattaya regarding the tests for the tracker, they should all be in the TrackerTest abstract class (and eventually be skipped in implementations not supporting it yet) instead of being added in the child class. This would promote consistency between the different implementations (when a feature missing in a tacker is implemented, we would simply remove the skip flag to let the test be used instead of duplicating the test in the other child class and trying to keep the same expectations)

@Dattaya

@stof, some tests are very specific to InotifyTracker implementation, for example InotifyTracker treats a topmost directory differently than a sub dir and I need to test it. And RecursiveIteratorTracker's tests are very slow because of two sec usleep. Are you sure all of them gotta be there?

be skipped in implementations not supporting it yet

No new features, they all should act alike.
btw, one bug(refers to IN_MOVE inotify event) that I thought was minor, after some investigation it turned out that it's not so easy to fix, need to do some refactoring.

@Dattaya

The bug has been fixed.

@Dattaya Dattaya commented on an outdated diff
...cher/Tests/StateChecker/DirectoryStateCheckerTest.php
((170 lines not shown))
+ $resource = $this->getMockBuilder('Symfony\Component\Config\Resource\FileResource')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->setResourceExists($resource, $exists);
+
+ return $resource;
+ }
+
+ protected function setResourceExists($resource, $exists)
+ {
+ if (is_array($exists)) {
+ $resource
+ ->expects($this->any())
+ ->method('exists')
+ ->will($this->onConsecutiveCalls($exists));
@Dattaya
Dattaya added a note

According to the doc http://www.phpunit.de/manual/3.6/en/test-doubles.html#test-doubles.stubs.examples.StubTest7.php:
$this->onConsecutiveCalls(2, 3, 5, 7) it does not support passing an array to return values from it on each new call. It should be changed to ->will(call_user_func_array(array($this, 'onConsecutiveCalls'), $exists));.

@Dattaya
Dattaya added a note

done or almost done in everzet/symfony#4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Dattaya Dattaya commented on the diff
...y/Component/ResourceWatcher/Event/FilesystemEvent.php
((38 lines not shown))
+ 1 => 'create',
+ 2 => 'modify',
+ 4 => 'delete',
+ );
+
+ /**
+ * Initializes resource event.
+ *
+ * @param TrackedResource $tracked resource, that being tracked
+ * @param ResourceInterface $resource resource instance
+ * @param integer $type event type bit
+ */
+ public function __construct(TrackedResource $tracked, ResourceInterface $resource, $type)
+ {
+ if (!isset(self::$types[$type])) {
+ throw new InvalidArgumentException('Wrong event type providen');
@Dattaya
Dattaya added a note

probably missing docblock @throws tag here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@Dattaya

I've reworked InotifyTracker also prettified code, tests, fixed all bugs that I could find, added docblocks, etc. Where am I supposed to send a PR for the review and discussion? (it depends on the current pull request).

@everzet, are you going to fix that bug I was talking about in pr#1? It's the only bug I found. Test for it is present in my new branch: Dattaya/symfony@6d9eac5#L16R191
To run this test you need to modify assertHasResourceEvent method, for example: Dattaya/symfony@6d9eac5#L16R256

And you didn't say anything about that extra second the pr1 was about. Is it necessary?

@fabpot
Symfony member

@Dattaya You can send a pull request on everzet/resource-watcher-rebuilt. And when @everzet will merge your PR, it will automatically be reflected here too. Thanks.

@travisbot

This pull request fails (merged 0c1fe95 into e7470ff).

@everzet

merged second PR. @Dattaya what also needs to be done from my side?

@Dattaya

merged second PR. @Dattaya what also needs to be done from my side?

  • @everzet, have you seen code comments above?
  • if you try to run test now you'd see a test failure:
1) Symfony\Component\ResourceWatcher\Tests\Tracker\RecursiveIteratorTrackerTest::testTrackDeepDirChanges
Failed asserting that actual size 1 matches expected size 2.

It is a bug of the RecursiveIteratorTracker.

  • Repeating my question from the previous comment: "you didn't say anything about that extra second the pr1 was about. Is it necessary? "
  • If you want to, you can move some functional tests from InotifyTrackerTest to TrackerTest.

my todo:

  • run PHP-CS-FIXER and fix all remaining coding standard issues.
  • make sure InotifyTracker works properly with ResourceWatcher::stop (functional tests needed).
@travisbot

This pull request fails (merged 2fab315 into e7470ff).

@travisbot

This pull request fails (merged a9193eb into e7470ff).

Dattaya and others added some commits
@Dattaya Dattaya Moved previously added assertions from `testTrackDeepDirChanges` to t…
…heir own method.
21cbd27
@Dattaya Dattaya [ResourceWatcher] NewDirectoryStateChecker: removed unnecessary `$res…
…ource->exists()` check
0132949
@Dattaya Dattaya [ResourceWatcher] Ran CS Fixer against code + fixed some CS issues by…
… myself.
0bec395
@everzet everzet Merge pull request #5 from Dattaya/resource-watcher-issues
[ResourceWatcher] Few small issues
0564b07
@everzet everzet [Config] added type prefixes to resource ids
Makes sure that directory and the file resources
with the same name will have different ids
3aaf29b
@everzet everzet [Config] use is_file in FileResource::exists()
file resource existence check shouldn't return true if there's
directory with same name instead of file.
2cf953d
@everzet

All RecursiveIteratorTracker-related tests pass and i'm quite happy with component. @Dattaya could you check that InotifyTracker still passes to?

@fabpot it's almost ready. We just need to have additional pair of eyes to check everything and that's it :)
@stof could you review?

@travisbot

This pull request passes (merged 3aaf29b into e7470ff).

@travisbot

This pull request passes (merged 2cf953d into e7470ff).

@stof
Symfony member

@everzet this PR conflicts with master according to github

@stof stof commented on the diff
vendors.php
@@ -63,3 +63,12 @@
system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
}
+
+// install inotify extension
+system(<<<SH
@stof Symfony member
stof added a note

you should wrap this call as it will fail for Windows users, making the vendors script unusable.

Btw, is it really necessary ? Travis uses Composer now in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@travisbot

This pull request passes (merged 0564b07 into e7470ff).

@stof
Symfony member

@fabpot what about merging the changes done in the ResourceInterface into 2.1 to allow marking the Config component as stable instead of waiting for 2.2 to do it because of this PR ?
Btw, making the ResourceInterface extend Serializable indeed make sense as the resources are always serialized in the meta files.

@Dattaya

@Dattaya could you check that InotifyTracker still passes to?

yep, it passes

All RecursiveIteratorTracker-related tests pass and i'm quite happy with component.

I think the RecursiveIteratorTracker is great. I'm out of ideas how to break it.

@everzet

@stof @fabpot i could cherry-pick Config component changes from this PR.

@stof
Symfony member

@everzet this is what I had in mind. Let's see what @fabpot think about it.

@everzet

Also as there's still no 1st beta for Symfony 2.1 AFAIK, we could think about including this component (in form of unstabilized one) to 2.1, cuz test suite passes for both trackers (recursive, inotify).

@fabpot @stof what do you think, guys?

@stof
Symfony member

@everzet why not forcing the push in the branch to update the PR ?

@everzet

@stof to not break history of this PR. i'm thinking about opening another PR instead.

@everzet

@fabpot can we really get rid of this IN_ prefix (that have been added for inotify event names compliance) or should i revert these 2 @Dattaya commits?

@stof stof commented on an outdated diff
src/Symfony/Component/ResourceWatcher/composer.json
((5 lines not shown))
+ "keywords": ["resource", "filesystem", "watching"],
+ "homepage": "http://symfony.com",
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.3"
+ },
@stof Symfony member
stof added a note

the component requires symfony/config

@everzet
everzet added a note

I think @stofbot is right. This component does depends on symfony/config...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@fabpot
Symfony member

@everzet feel free to remove the IN_ prefix.

@everzet

rebased to #4605

@everzet everzet closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2012
  1. @everzet
  2. @everzet
  3. @everzet
  4. @everzet
  5. @everzet

    [ResourceWatcher] created recursive iterator resource state checker

    everzet committed
    this is a basic state checker, which checks all
    files and directories recursively for changes
  6. @everzet
  7. @everzet

    [ResourceWatcher] recursive iterator resources tracker created

    everzet committed
    this resources tracker uses recursive iterator state
    checker internally
  8. @everzet
  9. @everzet
  10. @everzet

    [ResourceWatcher] use best tracker by default

    everzet committed
    if no tracker were specified in watcher constructor
    it will use best one (inotify if available and rec
    otherwise)
  11. @everzet

    [ResourceWatcher] renamed Event::handes to Event::supports to be cons…

    everzet committed
    …istent with other parts of the framework.
  12. @everzet
  13. @everzet
  14. @everzet
  15. @everzet
  16. @everzet
  17. @everzet
  18. @everzet
  19. @everzet
  20. @everzet

    [Config] update FileResourceTest

    everzet committed
  21. @everzet
  22. @everzet
  23. @everzet
  24. @everzet
  25. @everzet
  26. @everzet
  27. @everzet
  28. @everzet
  29. @everzet
  30. @fabpot @everzet
  31. @fabpot @everzet
  32. @fabpot @everzet
  33. @fabpot @everzet
  34. @fabpot @everzet

    [ResourceWatcher] added the possibility to watch files that do not ex…

    fabpot committed with everzet
    …ist yet
    
    * fixed DELETED event when starting to watch a file that does not exist yet
    * fixed files that are deleted and then re-created
  35. @fabpot @everzet
  36. @fabpot @everzet

    -

    fabpot committed with everzet
  37. @everzet
  38. @everzet

    [ResourceWatcher] refactored event subsystem

    everzet committed
    - FilesystemEvent is now child of the EventDispatcher\Event
    - supported FilesystemEvent types are now inotify-like named
    - FilesystemEvent now operates two resources:
      - TrackedResource - resource, which initialized tracking
      - ResourceInterface - resource, which have been modified
    - lot of new useful getters like isFileChange(), isDirectoryChange() or getTypeString()
  39. @everzet

    [ResourceWatcher] added TrackedResource class

    everzet committed
    This class holds all necessary information about resource,
    being tracked
  40. @everzet

    [ResourceWatcher] refactored ResourceWatcher

    everzet committed
    Now, ResourceWatcher:
    
    - uses EventDispatcher for sending events
    - provides couple of useful methods, like track(), listen() or trackBy()
    
    track() method has been refactored too. Now it expects 3 arguments:
    
    - trackingId - name of the track
    - resource - resource instance or file/dir path
    - eventsMask - what changes to track
    
    trackingId is used to differentiate tracks from each other.
    ResourceWatcher dispatches 2 EventDispatcher events for each FS event:
    
    - `resource_watcher.all` - if someone wants to track ALL tracked FS events -
      this is a name to catch them with EventDispatcher
    - `resource_watcher.{trackingId}` - events of specific track
    
    If user don't want to deal with event dispatcher directly, ResourceWatcher provides
    couple of useful help methods:
    
    - listen() - accepts trackingId and callback, which will be called on track events
    - trackBy() - same as consequent calls to track() and listen()
  41. @everzet

    [ResourceWatcher] refactored TrackerInterface

    everzet committed
    - removed isResourceTracked()
    - track() now accepts 2 arguments - TrackedResource and events mask
  42. @everzet

    [ResourceWatcher] refactored RecursiveIteratorTracker to support new …

    everzet committed
    …TrackerInterface
    
    also, class code were been highly simplified
  43. @everzet

    [ResourceWatcher] added support for events mask in ResourceStateChecker

    everzet committed
    now state checker sends event only if tracker expects this type of events
  44. @everzet
  45. @everzet
  46. @everzet
  47. @everzet
  48. @everzet
  49. @everzet
Commits on Apr 17, 2012
  1. @everzet
Commits on Apr 20, 2012
  1. @everzet
  2. @everzet
  3. @everzet
  4. @everzet
Commits on May 24, 2012
  1. @Dattaya
  2. @everzet

    Merge pull request #2 from Dattaya/resource-watcher-rebuilt-inotify-r…

    everzet committed
    …ebuilt
    
    Inotify Tracker
  3. @Dattaya
  4. @everzet

    Merge pull request #3 from Dattaya/resource-watcher-typos-docblock

    everzet committed
    Resource watcher typos and docblocks clearing
  5. @Dattaya
  6. @everzet

    Merge pull request #4 from Dattaya/resource-watcher-tests-issues

    everzet committed
    Resource watcher, onConsecutiveCalls
Commits on May 26, 2012
  1. @Dattaya
Commits on May 27, 2012
  1. @Dattaya
  2. @Dattaya
Commits on Jun 9, 2012
  1. @everzet

    Merge pull request #5 from Dattaya/resource-watcher-issues

    everzet committed
    [ResourceWatcher] Few small issues
  2. @everzet

    [Config] added type prefixes to resource ids

    everzet committed
    Makes sure that directory and the file resources
    with the same name will have different ids
  3. @everzet

    [Config] use is_file in FileResource::exists()

    everzet committed
    file resource existence check shouldn't return true if there's
    directory with same name instead of file.
  4. @everzet
Commits on Jun 13, 2012
  1. @everzet

    Merge pull request #6 from Dattaya/resource-watcher-tests-and-event-n…

    everzet committed
    …ames
    
    [ResourceWatcher] Resource watcher tests and event names
  2. @everzet
  3. @Dattaya
  4. @Dattaya
  5. @everzet
Something went wrong with that request. Please try again.