Skip to content

Commit

Permalink
Merge 25cd779 into 2f0a7ac
Browse files Browse the repository at this point in the history
  • Loading branch information
rastersize committed Jan 5, 2016
2 parents 2f0a7ac + 25cd779 commit a24a722
Showing 1 changed file with 22 additions and 21 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,35 @@

[![Coverage Status](https://coveralls.io/repos/spotify/SPTDataLoader/badge.svg?branch=master&service=github)](https://coveralls.io/github/spotify/SPTDataLoader?branch=master)
[![Build Status](https://api.travis-ci.org/spotify/SPTDataLoader.svg)](https://travis-ci.org/spotify/SPTDataLoader)
[![License](https://img.shields.io/github/license/spotify/apollo.svg)](LICENSE.txt)

## DESCRIPTION
Authentication and back-off logic is a pain, let's do it once and forget about it! This is a library that allows you to centralise this logic and forget about the ugly parts of making HTTP requests.

## LICENSE
[Apache 2](http://www.apache.org/licenses/LICENSE-2.0)
- [x] 📱 iOS 7.0+

## BACKGROUND
At Spotify we have begun moving to a decentralised HTTP architecture, and in doing so have had some growing pains. Initially we had a data loader that would attempt to refresh the access token whenever it became invalid, but we immediately learned this was very hard to keep track of. We needed some way of injecting this authorisation data automatically into a HTTP request that didn't require our features to do any more heavy lifting than they were currently doing. Thus we came up with a way to elegantly inject tokens in a Just-in-time manner for requests that require them. We also wanted to learn from our mistakes with our proprietary protocol, and bake in back-off policies early to avoid us DDOSing our own backends with huge amounts of eronious requests.
## Architecture :triangular_ruler:
`SPTDataLoader` is designed as an HTTP stack with 3 additional layers on top of `NSURLSession`.

## ARCHITECTURE
SPTDataLoader is designed as an HTTP stack with 3 additional layers on top of NSURLSession.
* The Application level, which controls the rate limiting and back-off policies per service, respecting the "Retry-After" header and knowing when or not it should retry the request.
* The User level, which controls the authentication of the HTTP requests.
* The View level, which allows automatic cancellation of requests the view has made upon deallocation
- **The Application level**, which controls the rate limiting and back-off policies per service, respecting the “Retry-After” header and knowing when or not it should retry the request.
- **The User level**, which controls the authentication of the HTTP requests.
- **The View level**, which allows automatic cancellation of requests the view has made upon deallocation.

## AUTHENTICATION
The authentication in this case is abstract, allowing the creator of the SPTDataLoaderFactory to define their own semantics for token acquisition and injection. It allows for asynchronous token acquisition if the token is invalid that seamlessly integrates with the HTTP request/response pattern.
### Authentication :key:
The authentication in this case is abstract, allowing the creator of the SPTDataLoaderFactory to define their own semantics for token acquisition and injection. It allows for asynchronous token acquisition if the token is invalid that seamlessly integrates with the HTTP request-response pattern.

## BACK-OFF POLICY
The data loader service allows rate limiting of URLs to be set explicitly or to be determined by the server using the "Retry-After" semantic. It allows back-off retrying by using a jittered exponential backoff to prevent the thundering hordes creating a request storm after a predictable exponential period has expired.
### Back-off policy :cop:
The data loader service allows rate limiting of URLs to be set explicitly or to be determined by the server using the Retry-After semantic. It allows back-off retrying by using a jittered exponential backoff to prevent the thundering hordes creating a request storm after a predictable exponential period has expired.

## USAGE
For an example of this frameworks usage, see the demo application location in the "demo" folder.
## Usage example :eyes:
For an example of this frameworks usage, see the demo application location in the [demo folder](demo/SPTDataLoaderDemo).

## CONTRIBUTION
Contributions are welcomed, have a look at the [CONTRIBUTING.md](https://github.com/spotify/SPTDataLoader/blob/master/CONTRIBUTING.md) document for more information.
## Background story :book:
At Spotify we have begun moving to a decentralised HTTP architecture, and in doing so have had some growing pains. Initially we had a data loader that would attempt to refresh the access token whenever it became invalid, but we immediately learned this was very hard to keep track of. We needed some way of injecting this authorisation data automatically into a HTTP request that didn't require our features to do any more heavy lifting than they were currently doing.

## CREDITS
* Will Sackfield
* Dmitry Ponomarev
Thus we came up with a way to elegantly inject tokens in a Just-in-time manner for requests that require them. We also wanted to learn from our mistakes with our proprietary protocol, and bake in back-off policies early to avoid us DDOSing our own backends with huge amounts of eronious requests.

## Contributing :mailbox_with_mail:
Contributions are welcomed, have a look at the [CONTRIBUTING.md](CONTRIBUTING.md) document for more information.

## License :memo:
The project is available under the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) license.

0 comments on commit a24a722

Please sign in to comment.