Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor internals to use event based callbacks #22

Merged
merged 31 commits into from
Jan 3, 2013

Conversation

lsegal
Copy link
Contributor

@lsegal lsegal commented Jan 3, 2013

Major changes:
(X) = backward incompatible

  • (X) Removes promise API features on AWSRequest (.data, .done, .fail, .always)
  • (X) Renames AWSRequest/AWSResponse to Request/Response
  • Make Request an EventEmitter object, responding to .on/.addListener interfaces, events are:
    • validate
    • build
    • sign
    • send
    • httpHeaders
    • httpData
    • httpDone
    • retry
    • error
    • success
    • complete
  • (X) All client classes now extend from AWS.Client and use event registration to determine their service interface
  • Moved client subclasses into AWS.ServiceInterface namespace implementing the three methods:
    • buildRequest(request)
    • extractError(response)
    • extractData(response)

lsegal added 30 commits January 2, 2013 10:01
This commit includes many changes to internal systems, namely:

* AWS.RequestHandler was removed. Its logic was moved into AWSRequest

* AWS.AWSRequest is now an EventEmitter emitting the following events:
  - validate
  - build
  - sign
  - send
  - httpHeaders
  - httpData
  - httpDone
  - retry
  - error
  - success
  - complete

* Added AWS.EventListeners namespace to keep track of named events
  that are added to services

* Converted all AWS.Client subclasses (QueryClient, RESTXMLClient, etc.)
  into AWS.ServiceInterface.* modules implementing 3 methods:
    - buildRequest (for build event)
    - extractError (for extractError event)
    - extractData (for extractData event)

  These methods match the events they listen to (named above), and
  are registered by the equivalently named modules in AWS.EventListeners.*

  The separation is for testing. The request building and data extraction
  can now be tested individually for a service interface format without
  requiring the event emitter infrastructure:

    var client = new AWS.Client();
    var req = new AWS.AWSRequest(client, 'operation', params);
    AWS.ServiceInterface.Json.buildRequest(req, req.response);

* Some tests were disabled (renamed *.off). These tests still need to be
  updated to use the new infrastructure for testing. This is a TODO.
Event is removed when another httpData event is registered.

Also re-orders httpData arguments (chunk first)
* Change signatures for event emitters
* Request can now send() multiple times without async issues.
No longer passing `request` to any other events, use `this` to access
the AWSRequest object from an event instead.
trevorrowe added a commit that referenced this pull request Jan 3, 2013
Refactor internals to use event based callbacks
@trevorrowe trevorrowe merged commit b809a28 into master Jan 3, 2013
@lsegal lsegal deleted the feature/event-emitter branch January 3, 2013 21:26
nhinds added a commit to nhinds/aws-sdk-js that referenced this pull request Jan 12, 2016
chrisradek added a commit that referenced this pull request Jan 12, 2016
@srchase srchase added feature-request A feature should be added or improved. and removed enhancement labels Jan 4, 2019
@lock
Copy link

lock bot commented Sep 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators Sep 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants