Skip to content

Commit

Permalink
Merge commit '794b2abafedf65c2052f2a7a5932155662de8ab1' into rx
Browse files Browse the repository at this point in the history
  • Loading branch information
jianghaolu committed Aug 30, 2016
2 parents 930fbf5 + 7fb2d38 commit d0191c7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import com.microsoft.rest.ServiceCall;
import com.microsoft.rest.ServiceResponse;
import com.microsoft.rest.ServiceResponseWithHeaders;

import java.util.List;

Expand Down Expand Up @@ -45,6 +46,36 @@ public static <E> ServiceCall<List<E>> create(Observable<ServiceResponse<Page<E>
return serviceCall;
}

/**
* Creates a ServiceCall from a paging operation that returns a header response.
*
* @param first the observable to the first page
* @param next the observable to poll subsequent pages
* @param callback the client-side callback
* @param <E> the element type
* @param <V> the header object type
* @return the future based ServiceCall
*/
public static <E, V> ServiceCall<List<E>> createWithHeaders(Observable<ServiceResponseWithHeaders<Page<E>, V>> first, final Func1<String, Observable<ServiceResponseWithHeaders<Page<E>, V>>> next, final ListOperationCallback<E> callback) {
final AzureServiceCall<List<E>> serviceCall = new AzureServiceCall<>();
final PagingSubscriber<E> subscriber = new PagingSubscriber<>(serviceCall, new Func1<String, Observable<ServiceResponse<Page<E>>>>() {
@Override
public Observable<ServiceResponse<Page<E>>> call(String s) {
return next.call(s)
.map(new Func1<ServiceResponseWithHeaders<Page<E>, V>, ServiceResponse<Page<E>>>() {
@Override
public ServiceResponse<Page<E>> call(ServiceResponseWithHeaders<Page<E>, V> pageVServiceResponseWithHeaders) {
return pageVServiceResponseWithHeaders;
}
});
}
}, callback);
serviceCall.setSubscription(first
.single()
.subscribe(subscriber));
return serviceCall;
}

/**
* The subscriber that handles user callback and automatically subscribes to the next page.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ public Builder(OkHttpClient.Builder httpClientBuilder, Retrofit.Builder retrofit
// Set up OkHttp client
this.httpClientBuilder = httpClientBuilder
.cookieJar(new JavaNetCookieJar(cookieManager))
.readTimeout(30, TimeUnit.SECONDS)
.addInterceptor(userAgentInterceptor);
this.retrofitBuilder = retrofitBuilder;
this.buildable = new Buildable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
*/
public abstract class TaskGroupBase<T, U extends TaskItem<T>>
implements TaskGroup<T, U> {
/**
* Stores the tasks in this group and their dependency information.
*/
private DAGraph<U, DAGNode<U>> dag;

/**
Expand Down Expand Up @@ -67,7 +70,7 @@ public void execute() throws Exception {

@Override
public Observable<T> executeAsync() {
return executeReadyTasksAsync();
return executeReadyTasksAsync().last();
}

@Override
Expand Down Expand Up @@ -98,6 +101,6 @@ public Observable<T> call(T t) {
}));
nextNode = dag.getNext();
}
return Observable.merge(observables).last();
return Observable.merge(observables);
}
}
1 change: 0 additions & 1 deletion client-runtime/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ dependencies {
compile 'com.squareup.retrofit2:converter-jackson:2.0.2'
compile 'com.squareup.retrofit2:adapter-rxjava:2.0.2'
compile 'io.reactivex:rxjava:1.1.8'
compile 'io.reactivex:rxjava-computation-expressions:0.21.0'
compile 'com.fasterxml.jackson.datatype:jackson-datatype-joda:2.7.2'
compile 'org.apache.commons:commons-lang3:3.4'
testCompile 'junit:junit:4.12'
Expand Down
4 changes: 4 additions & 0 deletions client-runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@
<groupId>io.reactivex</groupId>
<artifactId>rxjava</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>adapter-rxjava</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@
<artifactId>rxjava</artifactId>
<version>1.1.8</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>adapter-rxjava</artifactId>
<version>2.0.2</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down

0 comments on commit d0191c7

Please sign in to comment.