-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Added retrofit2 module. #1419
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
Merged
Merged
Added retrofit2 module. #1419
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e28607f
Added retrofit2 module.
bfg 1e357ad
Added newlines at the end of files.
bfg 3b2cced
Added static method runConsumers() and cleanup
bfg 5ac6b77
Introduced concept of call builder customizers, cleanup
bfg 8744424
Refactored integration tests.
bfg 2bba0b9
Added multiple consumers support for each Call event type.
bfg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # Async-http-client Retrofit2 Call Adapter | ||
|
|
||
| An `okhttp3.Call.Factory` for implementing async-http-client powered [Retrofit][1] type-safe HTTP clients. | ||
|
|
||
| ## Download | ||
|
|
||
| Download [the latest JAR][2] or grab via [Maven][3]: | ||
|
|
||
| ```xml | ||
| <dependency> | ||
| <groupId>org.asynchttpclient</groupId> | ||
| <artifactId>async-http-client-extras-retrofit2</artifactId> | ||
| <version>latest.version</version> | ||
| </dependency> | ||
| ``` | ||
|
|
||
| or [Gradle][3]: | ||
|
|
||
| ```groovy | ||
| compile "org.asynchttpclient:async-http-client-extras-retrofit2:latest.version" | ||
| ``` | ||
|
|
||
| [1]: http://square.github.io/retrofit/ | ||
| [2]: https://search.maven.org/remote_content?g=org.asynchttpclient&a=async-http-client-extras-retrofit2&v=LATEST | ||
| [3]: http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.asynchttpclient%22%20a%3A%22async-http-client-extras-retrofit2%22 | ||
| [snap]: https://oss.sonatype.org/content/repositories/snapshots/ | ||
|
|
||
| ## Example usage | ||
|
|
||
| ```java | ||
| // instantiate async-http-client | ||
| AsyncHttpClient httpClient = ... | ||
|
|
||
| // instantiate async-http-client call factory | ||
| Call.Factory callFactory = AsyncHttpClientCallFactory.builder() | ||
| .httpClient(httpClient) // required | ||
| .onRequestStart(onRequestStart) // optional | ||
| .onRequestFailure(onRequestFailure) // optional | ||
| .onRequestSuccess(onRequestSuccess) // optional | ||
| .requestCustomizer(requestCustomizer) // optional | ||
| .build(); | ||
|
|
||
| // instantiate retrofit | ||
| Retrofit retrofit = new Retrofit.Builder() | ||
| .callFactory(callFactory) // use our own call factory | ||
| .addConverterFactory(ScalarsConverterFactory.create()) | ||
| .addConverterFactory(JacksonConverterFactory.create()) | ||
| // ... add other converter factories | ||
| // .addCallAdapterFactory(RxJavaCallAdapterFactory.createAsync()) | ||
| .validateEagerly(true) // highly recommended!!! | ||
| .baseUrl("https://api.github.com/"); | ||
|
|
||
| // time to instantiate service | ||
| GitHub github = retrofit.create(Github.class); | ||
|
|
||
| // enjoy your type-safe github service api! :-) | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
|
|
||
| <parent> | ||
| <artifactId>async-http-client-extras-parent</artifactId> | ||
| <groupId>org.asynchttpclient</groupId> | ||
| <version>2.1.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>async-http-client-extras-retrofit2</artifactId> | ||
| <name>Asynchronous Http Client Retrofit2 Extras</name> | ||
| <description>The Async Http Client Retrofit2 Extras.</description> | ||
|
|
||
| <properties> | ||
| <retrofit2.version>2.3.0</retrofit2.version> | ||
| <lombok.version>1.16.16</lombok.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.projectlombok</groupId> | ||
| <artifactId>lombok</artifactId> | ||
| <version>${lombok.version}</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.squareup.retrofit2</groupId> | ||
| <artifactId>retrofit</artifactId> | ||
| <version>${retrofit2.version}</version> | ||
| </dependency> | ||
|
|
||
| <!-- for tests --> | ||
| <dependency> | ||
| <groupId>com.squareup.retrofit2</groupId> | ||
| <artifactId>converter-scalars</artifactId> | ||
| <version>${retrofit2.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.squareup.retrofit2</groupId> | ||
| <artifactId>converter-jackson</artifactId> | ||
| <version>${retrofit2.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.squareup.retrofit2</groupId> | ||
| <artifactId>adapter-rxjava</artifactId> | ||
| <version>${retrofit2.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>com.squareup.retrofit2</groupId> | ||
| <artifactId>adapter-rxjava2</artifactId> | ||
| <version>${retrofit2.version}</version> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </project> | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I'd rather not use lombok in there so coding style is consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can convert all the code to normal java code, but frankly i don't think it's worth it - some other open source projects, namely spring-cloud started using lombok 2-3 years ago and it seem to work for them very well.
So, do you want me to de-lombok the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can leave Lombok there. But I don't think it will ever make it into main module.