Class: RequestItem
Defined in: | src/kermit/RequestItem.coffee |
Overview
The RequestItem is the central object in the processing of a single URL. The Crawler will funnel each item through the different ProcessingPhases - applying all Extensions registered for the particular phase.
During its lifecycle the item is enriched with listeners and properties by the Extensions that take care of its processing.
(Meta-)Information necessary for its processing is usually attached to the item in order to centralize state.
Instance Method Summary
-
#
(RequestItem)
onChange(property, listener)
Register a listener {Function} to be invoked whenever the specified property value is changed changes.
- # (String) url(url) Get the string representation of the uri
- # (String) id()
- # (void) useSSL() Check whether https should be used to fetch this item
- # (String) phase(phase) Private Change the phase and notify subscribed listeners or retrieve the current phase value
- # (void) stamp(tag) Add a new timestamp to the collection of timestamps for the given tag.
- # (void) stamps(tag) Get all timestamps stored for the given tag
- # (Number) durationOf(phase) Compute the duration of a phase
- # (void) timeToComplete() Calculate processing time from INITIAL to COMPLETE
- # (RequestItem) onPhase(phase, listener) Register a change listener for a specific value of the phase property
- # (RequestItem) spool() Change the items phase to SPOOLED
- # (RequestItem) ready() Change the items phase to READY
- # (RequestItem) fetching() Change the items phase to FETCHING
- # (RequestItem) fetched() Bound Change the items phase to FETCHED
- # (RequestItem) complete() Change the items phase to COMPLETE
- # (RequestItem) error(error) Change the items phase to ERROR
- # (RequestItem) cancel() Change the items phase to CANCELED
- # (Boolean) isInitial() Check whether this item has phase INITIAL
- # (Boolean) isSpooled() Check whether this item has phase SPOOLED
- # (Boolean) isReady() Check whether this item has phase READY
- # (Boolean) isFetching() Check whether this item has phase FETCHING
- # (Boolean) isFetched() Check whether this item has phase FETCHED
- # (Boolean) isComplete() Check whether this item has phase COMPLETE
- # (Boolean) isCanceled() Check whether this item has phase CANCELED
- # (Boolean) isError() Check whether this item has phase ERROR
- # (void) cleanup() Clean all item data that potentially occupies much memory
- # (void) pipeline() Access the Pipeline of this item
- # (Number) parents() A item might have been created by another item (its parent).
- # (void) toString() Generate a human readable representation of this item
Constructor Details
#
(void)
constructor(url, meta, log)
Create a new item for the given url and with the given metadata attached
Instance Method Details
#
(RequestItem)
onChange(property, listener)
Register a listener {Function} to be invoked whenever the specified property value is changed changes. The post-change state of the item will be passed to the handler
#
(String)
url(url)
Get the string representation of the uri
#
(String)
id()
#
(void)
useSSL()
Check whether https should be used to fetch this item
#
(String)
phase(phase)
Private
Change the phase and notify subscribed listeners or retrieve the current phase value
#
(void)
stamp(tag)
Add a new timestamp to the collection of timestamps for the given tag. Timestamps are useful to keep track of processing durations.
#
(void)
stamps(tag)
Get all timestamps stored for the given tag
#
(Number)
durationOf(phase)
Compute the duration of a phase
#
(void)
timeToComplete()
Calculate processing time from INITIAL to COMPLETE
#
(RequestItem)
onPhase(phase, listener)
Register a change listener for a specific value of the phase property
#
(RequestItem)
spool()
Change the items phase to SPOOLED
#
(RequestItem)
ready()
Change the items phase to READY
#
(RequestItem)
fetching()
Change the items phase to FETCHING
#
(RequestItem)
fetched()
Bound
Change the items phase to FETCHED
#
(RequestItem)
complete()
Change the items phase to COMPLETE
#
(RequestItem)
error(error)
Change the items phase to ERROR
#
(RequestItem)
cancel()
Change the items phase to CANCELED
#
(Boolean)
isInitial()
Check whether this item has phase INITIAL
#
(Boolean)
isSpooled()
Check whether this item has phase SPOOLED
#
(Boolean)
isReady()
Check whether this item has phase READY
#
(Boolean)
isFetching()
Check whether this item has phase FETCHING
#
(Boolean)
isFetched()
Check whether this item has phase FETCHED
#
(Boolean)
isComplete()
Check whether this item has phase COMPLETE
#
(Boolean)
isCanceled()
Check whether this item has phase CANCELED
#
(Boolean)
isError()
Check whether this item has phase ERROR
#
(void)
cleanup()
Clean all item data that potentially occupies much memory
#
(void)
pipeline()
Access the Pipeline of this item
#
(Number)
parents()
A item might have been created by another item (its parent). That parent might in turn have been created by another item and so on.
#
(void)
toString()
Generate a human readable representation of this item