-
Notifications
You must be signed in to change notification settings - Fork 0
track
io.track tracks I/O requests in flight. Duplicated requests are not issued, but a promise for an unfinished request is reused. It allows to register requests initiated outside of io, and register requests without initiating an I/O. io.track serves as a companion for cache and bundle services.
Don't forget to consult the cookbook to see working snippets solving simple real-world problems.
If options object has a Boolean property track, it tells the track service to process or ignore a request. Otherwise, a default algorithm is used described in Service documentation.
Like any service, io.track works transparently with io, but it exposes some helpers.
This function takes options of an I/O request, and returns a promise, which will be resolved when an I/O is finished. It can be used to register an I/O already in progress started outside of io.
This function checks, if an I/O request described by options is marked as "in-flight". It returns a false value, if the request is unknown, or a corresponding deferred object.
If io is instrumented to use the standard Promise, its deferred object contains three property:
-
promise— a corresponding promise object. -
resolve(value)— a method to resolve a promise withvalue. -
reject(value)— a method to reject a promise withvalue.
If io uses FastDeferred or Deferred of heya-async, it exposes one more useful method:
-
progress(value)— a method to report a progress withvalue.
And its promise has one more method:
-
cancel(reason)— a method to cancel waiting for a promise.
See more details in heya-async wiki and docs on Deferred.Promise.
This function is similar to io.track.fly(options), but takes a key rather than options. See io.makeKey() of the main API for more details.
The function is used to implement io.track.fly(), and exposed for efficiency.
This is a dictionary object to keep track of I/O requests in flight. Keys are unique keys generated by io.makeKey(). Values are deferred objects described above in io.track.isFlying().
See Service documentation for more details.