rx.functions.Func3 Java Examples
The following examples show how to use
rx.functions.Func3.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DynamicConnectionSet.java From mantis with Apache License 2.0 | 6 votes |
public DynamicConnectionSet(Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<T>> toObservableFunc, int minTimeoutOnUnexpectedTerminateSec, int maxTimeoutOnUnexpectedTerminateSec) { this.toObservableFunc = toObservableFunc; connectionMetrics = new Metrics.Builder() .name("DynamicConnectionSet") .addGauge("activeConnections") .addGauge("closedConnections") .addGauge("forceCompletedConnections") .build(); activeConnectionsGauge = connectionMetrics.getGauge("activeConnections"); closedConnections = connectionMetrics.getGauge("closedConnections"); forceCompletedConnections = connectionMetrics.getGauge("forceCompletedConnections"); this.minTimeoutOnUnexpectedTerminateSec = minTimeoutOnUnexpectedTerminateSec; this.maxTimeoutOnUnexpectedTerminateSec = maxTimeoutOnUnexpectedTerminateSec; }
Example #2
Source File: SerializationStrategyBuilder.java From datamill with ISC License | 6 votes |
public SerializationStrategy<SourceType> build() { return (target, source) -> { for (int i = 0; i < strategies.size(); i++) { Pair<Func1<OutlineBuilder, Outline<SourceType>>, Func3<StructuredOutput<?>, SourceType, Outline<?>, StructuredOutput<?>>> strategy = strategies.get(i); Outline<?> outline = outlines.get(i); if (outline == null) { outline = strategy.getFirst().call(OutlineBuilder.CAMEL_CASED); outlines.set(i, outline); } strategy.getSecond().call(target, source, outline); } return target; }; }
Example #3
Source File: SoundServiceImpl.java From openwebnet-android with MIT License | 6 votes |
private Func1<SoundModel, Observable<SoundModel>> requestSound( Func3<String, SoundSystem.Type, SoundSystem.Source, SoundSystem> request, Func2<OpenSession, SoundModel, SoundModel> handler) { return sound -> commonService.findClient(sound.getGatewayUuid()) .send(request.call(sound.getWhere(), sound.getSoundSystemType(), sound.getSoundSystemSource())) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(openSession -> handler.call(openSession, sound)) .onErrorReturn(throwable -> { log.warn("sound={} | failing request={}", sound.getUuid(), request.call(sound.getWhere(), sound.getSoundSystemType(), sound.getSoundSystemSource()).getValue()); // unreadable status return sound; }); }
Example #4
Source File: ParallelDocumentQueryExecutionContext.java From azure-cosmosdb-java with MIT License | 6 votes |
protected DocumentProducer<T> createDocumentProducer( String collectionRid, PartitionKeyRange targetRange, String initialContinuationToken, int initialPageSize, FeedOptions feedOptions, SqlQuerySpec querySpecForInit, Map<String, String> commonRequestHeaders, Func3<PartitionKeyRange, String, Integer, RxDocumentServiceRequest> createRequestFunc, Func1<RxDocumentServiceRequest, Observable<FeedResponse<T>>> executeFunc, Func0<IDocumentClientRetryPolicy> createRetryPolicyFunc) { return new DocumentProducer<T>(client, collectionRid, feedOptions, createRequestFunc, executeFunc, targetRange, collectionRid, () -> client.getResetSessionTokenRetryPolicy().getRequestPolicy(), resourceType, correlatedActivityId, initialPageSize, initialContinuationToken, top); }
Example #5
Source File: OrderByDocumentProducer.java From azure-cosmosdb-java with MIT License | 6 votes |
OrderByDocumentProducer( OrderbyRowComparer<T> consumeComparer, IDocumentQueryClient client, String collectionResourceId, FeedOptions feedOptions, Func3<PartitionKeyRange, String, Integer, RxDocumentServiceRequest> createRequestFunc, Func1<RxDocumentServiceRequest, Observable<FeedResponse<T>>> executeRequestFunc, PartitionKeyRange targetRange, String collectionLink, Func0<IDocumentClientRetryPolicy> createRetryPolicyFunc, Class<T> resourceType, UUID correlatedActivityId, int initialPageSize, String initialContinuationToken, int top, Map<String, OrderByContinuationToken> targetRangeToOrderByContinuationTokenMap) { super(client, collectionResourceId, feedOptions, createRequestFunc, executeRequestFunc, targetRange, collectionLink, createRetryPolicyFunc, resourceType, correlatedActivityId, initialPageSize, initialContinuationToken, top); this.consumeComparer = consumeComparer; this.targetRangeToOrderByContinuationTokenMap = targetRangeToOrderByContinuationTokenMap; }
Example #6
Source File: TransformerStateMachineTest.java From rxjava-extras with Apache License 2.0 | 6 votes |
@Test public void testStateTransitionThrowsError() { final RuntimeException ex = new RuntimeException("boo"); Func0<Integer> initialState = Functions.constant0(1); Func3<Integer, Integer, Observer<Integer>, Integer> transition = new Func3<Integer, Integer, Observer<Integer>, Integer>() { @Override public Integer call(Integer collection, Integer t, Observer<Integer> observer) { throw ex; } }; Func2<Integer, Observer<Integer>, Boolean> completion = Functions.alwaysTrue2(); Transformer<Integer, Integer> transformer = Transformers.stateMachine(initialState, transition, completion); TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); Observable.just(1, 1, 1).compose(transformer).subscribe(ts); ts.awaitTerminalEvent(); ts.assertError(ex); }
Example #7
Source File: TransformerStateMachineTest.java From rxjava-extras with Apache License 2.0 | 6 votes |
@Test public void testUnsubscriptionFromTransition() { Func0<Integer> initialState = Functions.constant0(1); Func3<Integer, Integer, Subscriber<Integer>, Integer> transition = new Func3<Integer, Integer, Subscriber<Integer>, Integer>() { @Override public Integer call(Integer collection, Integer t, Subscriber<Integer> subscriber) { subscriber.onNext(123); subscriber.unsubscribe(); return 1; } }; Func2<Integer, Observer<Integer>, Boolean> completion = Functions.alwaysTrue2(); Transformer<Integer, Integer> transformer = Transformers.stateMachine(initialState, transition, completion); TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); Observable.just(1, 1, 1).repeat().compose(transformer).subscribe(ts); ts.assertValue(123); ts.assertCompleted(); ts.assertUnsubscribed(); }
Example #8
Source File: TransformerStateMachineTest.java From rxjava-extras with Apache License 2.0 | 6 votes |
@Test public void testForCompletionWithinStateMachine() { Func0<Integer> initialState = Functions.constant0(1); Func3<Integer, Integer, Subscriber<Integer>, Integer> transition = new Func3<Integer, Integer, Subscriber<Integer>, Integer>() { @Override public Integer call(Integer collection, Integer t, Subscriber<Integer> subscriber) { subscriber.onNext(123); // complete from within transition subscriber.onCompleted(); return 1; } }; Func2<? super Integer, ? super Subscriber<Integer>, Boolean> completion = Functions .alwaysTrue2(); Transformer<Integer, Integer> transformer = Transformers.stateMachine(initialState, transition, completion); TestSubscriber<Integer> ts = new TestSubscriber<Integer>(); final AtomicInteger count = new AtomicInteger(0); Observable.just(1, 2, 3).doOnNext(Actions.increment1(count)).compose(transformer) .subscribe(ts); ts.assertValues(123); ts.assertCompleted(); assertEquals(1, count.get()); }
Example #9
Source File: DynamicConnectionSet.java From mantis with Apache License 2.0 | 6 votes |
public static <T> DynamicConnectionSet<T> create( final ConnectToObservable.Builder<T> config, int maxTimeBeforeDisconnectSec) { Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<T>> toObservableFunc = new Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<T>>() { @Override public RemoteRxConnection<T> call(Endpoint endpoint, Action0 disconnectCallback, PublishSubject<Integer> closeConnectionTrigger) { // copy config, change host, port and id ConnectToObservable.Builder<T> configCopy = new ConnectToObservable.Builder<T>(config); configCopy .host(endpoint.getHost()) .port(endpoint.getPort()) .closeTrigger(closeConnectionTrigger) .connectionDisconnectCallback(disconnectCallback) .slotId(endpoint.getSlotId()); return RemoteObservable.connect(configCopy.build()); } }; return new DynamicConnectionSet<T>(toObservableFunc, MIN_TIME_SEC_DEFAULT, maxTimeBeforeDisconnectSec); }
Example #10
Source File: DynamicConnectionSet.java From mantis with Apache License 2.0 | 6 votes |
public static <K, V> DynamicConnectionSet<MantisGroup<K, V>> createMGO( final ConnectToGroupedObservable.Builder<K, V> config, int maxTimeBeforeDisconnectSec, final SpscArrayQueue<MantisGroup<?, ?>> inputQueue) { Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<MantisGroup<K, V>>> toObservableFunc = new Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<MantisGroup<K, V>>>() { @Override public RemoteRxConnection<MantisGroup<K, V>> call(Endpoint endpoint, Action0 disconnectCallback, PublishSubject<Integer> closeConnectionTrigger) { // copy config, change host, port and id ConnectToGroupedObservable.Builder<K, V> configCopy = new ConnectToGroupedObservable.Builder<K, V>(config); configCopy .host(endpoint.getHost()) .port(endpoint.getPort()) .closeTrigger(closeConnectionTrigger) .connectionDisconnectCallback(disconnectCallback) .slotId(endpoint.getSlotId()); return RemoteObservable.connectToMGO(configCopy.build(), inputQueue); } }; return new DynamicConnectionSet<MantisGroup<K, V>>(toObservableFunc, MIN_TIME_SEC_DEFAULT, maxTimeBeforeDisconnectSec); }
Example #11
Source File: DynamicConnectionSet.java From mantis with Apache License 2.0 | 6 votes |
public static <K, V> DynamicConnectionSet<GroupedObservable<K, V>> create( final ConnectToGroupedObservable.Builder<K, V> config, int maxTimeBeforeDisconnectSec) { Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<GroupedObservable<K, V>>> toObservableFunc = new Func3<Endpoint, Action0, PublishSubject<Integer>, RemoteRxConnection<GroupedObservable<K, V>>>() { @Override public RemoteRxConnection<GroupedObservable<K, V>> call(Endpoint endpoint, Action0 disconnectCallback, PublishSubject<Integer> closeConnectionTrigger) { // copy config, change host, port and id ConnectToGroupedObservable.Builder<K, V> configCopy = new ConnectToGroupedObservable.Builder<K, V>(config); configCopy .host(endpoint.getHost()) .port(endpoint.getPort()) .closeTrigger(closeConnectionTrigger) .connectionDisconnectCallback(disconnectCallback) .slotId(endpoint.getSlotId()); return RemoteObservable.connect(configCopy.build()); } }; return new DynamicConnectionSet<GroupedObservable<K, V>>(toObservableFunc, MIN_TIME_SEC_DEFAULT, maxTimeBeforeDisconnectSec); }
Example #12
Source File: TransformerStateMachine.java From rxjava-extras with Apache License 2.0 | 5 votes |
public static <State, In, Out> Transformer<In, Out> create(Func0<? extends State> initialState, Func3<? super State, ? super In, ? super Subscriber<Out>, ? extends State> transition, Func2<? super State, ? super Subscriber<Out>, Boolean> completion, BackpressureStrategy backpressureStrategy, int initialRequest) { return new TransformerStateMachine<State, In, Out>(initialState, transition, completion, backpressureStrategy, initialRequest); }
Example #13
Source File: TransformerStateMachine.java From rxjava-extras with Apache License 2.0 | 5 votes |
private TransformerStateMachine(Func0<? extends State> initialState, Func3<? super State, ? super In, ? super Subscriber<Out>, ? extends State> transition, Func2<? super State, ? super Subscriber<Out>, Boolean> completion, BackpressureStrategy backpressureStrategy, int initialRequest) { Preconditions.checkNotNull(initialState); Preconditions.checkNotNull(transition); Preconditions.checkNotNull(completion); Preconditions.checkNotNull(backpressureStrategy); Preconditions.checkArgument(initialRequest > 0, "initialRequest must be greater than zero"); this.initialState = initialState; this.transition = transition; this.completion = completion; this.backpressureStrategy = backpressureStrategy; this.initialRequest = initialRequest; }
Example #14
Source File: Transformers.java From rxjava-extras with Apache License 2.0 | 5 votes |
public static <State, In, Out> Transformer<In, Out> stateMachine( Func0<State> initialStateFactory, Func3<? super State, ? super In, ? super Subscriber<Out>, ? extends State> transition, Func2<? super State, ? super Subscriber<Out>, Boolean> completion, BackpressureStrategy backpressureStrategy, int initialRequest) { return TransformerStateMachine.<State, In, Out> create(initialStateFactory, transition, completion, backpressureStrategy, initialRequest); }
Example #15
Source File: AutomationServiceImpl.java From openwebnet-android with MIT License | 5 votes |
private Func1<AutomationModel, Observable<AutomationModel>> requestAutomation( Func3<String, Automation.Type, String, Automation> request, Func2<OpenSession, AutomationModel, AutomationModel> handler) { return automation -> commonService.findClient(automation.getGatewayUuid()) .send(request.call(automation.getWhere(), automation.getAutomationType(), automation.getBus())) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(openSession -> handler.call(openSession, automation)) .onErrorReturn(throwable -> { log.warn("automation={} | failing request={}", automation.getUuid(), request.call(automation.getWhere(), automation.getAutomationType(), automation.getBus()).getValue()); // unreadable status return automation; }); }
Example #16
Source File: LightServiceImpl.java From openwebnet-android with MIT License | 5 votes |
private Func1<LightModel, Observable<LightModel>> requestLight( Func3<String, Lighting.Type, String, Lighting> request, Func2<OpenSession, LightModel, LightModel> handler) { return light -> commonService.findClient(light.getGatewayUuid()) .send(request.call(light.getWhere(), light.getLightingType(), light.getBus())) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .map(openSession -> handler.call(openSession, light)) .onErrorReturn(throwable -> { log.warn("light={} | failing request={}", light.getUuid(), request.call(light.getWhere(), light.getLightingType(), light.getBus()).getValue()); // unreadable status return light; }); }
Example #17
Source File: RxUtils.java From RxBinding with Apache License 2.0 | 5 votes |
public static <T1, T2, T3, R> Observable<R> toObservable(final Func3<T1, T2, T3, R> func, final T1 arg1, final T2 arg2, final T3 arg3) { return Observable.create(new Observable.OnSubscribe<R>() { @Override public void call(Subscriber<? super R> subscriber) { try { final R result = func.call(arg1, arg2, arg3); onNextIfSubscribed(subscriber, result); onCompletedIfSubsribed(subscriber); } catch (Exception e) { onErrorIfSubscribed(subscriber, e); } } }); }
Example #18
Source File: TripleArgumentTypeSwitch.java From datamill with ISC License | 5 votes |
public final R doSwitch(Class<?> type, T1 value1, T2 value2, T3 value3) { Func3<T1, T2, T3, R> typeCase = cases.get(type); if (typeCase != null) { return typeCase.call(value1, value2, value3); } else { return defaultCase(value1, value2, value3); } }
Example #19
Source File: SerializationStrategyBuilder.java From datamill with ISC License | 5 votes |
public SerializationStrategyBuilder<SourceType> withOutline( Func1<OutlineBuilder, Outline<SourceType>> outlineBuilder, Func3<StructuredOutput<?>, SourceType, Outline<SourceType>, StructuredOutput<?>> strategy) { strategies.add(new Pair(outlineBuilder, strategy)); outlines.add(null); return this; }
Example #20
Source File: PersonalCenterHomeController.java From PlayTogether with Apache License 2.0 | 5 votes |
public void getHomeData(final User user) { Observable.zip( mUserBll.getInviteCount(user), mUserBll.getAcceptInvitedCount(user), mUserBll.getNewlyDynamic(user, DYNAMIC_COUNT), new Func3<Integer, Integer, List<Invitation>, PersonalCenterHomeBean>() { @Override public PersonalCenterHomeBean call(Integer inviteCount, Integer acceptInviteCount, List<Invitation> invitations) { PersonalCenterHomeBean data = new PersonalCenterHomeBean(); data.setUser(user); data.setBeInvitedCount(acceptInviteCount); data.setInviteCount(inviteCount); data.setNewlyDynamic(invitations); return data; } }) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(new Action1<PersonalCenterHomeBean>() { @Override public void call(PersonalCenterHomeBean personalCenterHomeBean) { mFragment.getDataSuccess(personalCenterHomeBean); } }, new Action1<Throwable>() { @Override public void call(Throwable throwable) { throwable.printStackTrace(); mFragment.getDataFail("数据请求失败"); } }); }
Example #21
Source File: DataGenerator.java From titus-control-plane with Apache License 2.0 | 5 votes |
/** * Generates all permutations of data from source generators. */ public static <A, B, C, R> DataGenerator<R> union(DataGenerator<A> first, DataGenerator<B> second, DataGenerator<C> third, Func3<A, B, C, R> combiner) { List<DataGenerator<Object>> sources = asList((DataGenerator<Object>) first, (DataGenerator<Object>) second, (DataGenerator<Object>) third); return UnionDataGenerator.newInstance(sources).map(list -> combiner.call((A) list.get(0), (B) list.get(1), (C) list.get(2))); }
Example #22
Source File: ParallelDocumentQueryExecutionContextBase.java From azure-cosmosdb-java with MIT License | 5 votes |
protected void initialize(String collectionRid, Map<PartitionKeyRange, String> partitionKeyRangeToContinuationTokenMap, int initialPageSize, SqlQuerySpec querySpecForInit) { this.pageSize = initialPageSize; Map<String, String> commonRequestHeaders = createCommonHeadersAsync(this.getFeedOptions(null, null)); for (PartitionKeyRange targetRange : partitionKeyRangeToContinuationTokenMap.keySet()) { Func3<PartitionKeyRange, String, Integer, RxDocumentServiceRequest> createRequestFunc = (partitionKeyRange, continuationToken, pageSize) -> { Map<String, String> headers = new HashMap<>(commonRequestHeaders); headers.put(HttpConstants.HttpHeaders.CONTINUATION, continuationToken); headers.put(HttpConstants.HttpHeaders.PAGE_SIZE, Strings.toString(pageSize)); if(feedOptions.getPartitionKey() != null){ headers.put(HttpConstants.HttpHeaders.PARTITION_KEY, feedOptions .getPartitionKey() .getInternalPartitionKey() .toJson()); } return this.createDocumentServiceRequest(headers, querySpecForInit, partitionKeyRange, collectionRid); }; Func1<RxDocumentServiceRequest, Observable<FeedResponse<T>>> executeFunc = (request) -> { return this.executeRequestAsync(request).toObservable(); }; DocumentProducer<T> dp = createDocumentProducer(collectionRid, targetRange, partitionKeyRangeToContinuationTokenMap.get(targetRange), initialPageSize, feedOptions, querySpecForInit, commonRequestHeaders, createRequestFunc, executeFunc, () -> client.getResetSessionTokenRetryPolicy().getRequestPolicy()); documentProducers.add(dp); } }
Example #23
Source File: OrderByDocumentQueryExecutionContext.java From azure-cosmosdb-java with MIT License | 5 votes |
protected OrderByDocumentProducer<T> createDocumentProducer( String collectionRid, PartitionKeyRange targetRange, String continuationToken, int initialPageSize, FeedOptions feedOptions, SqlQuerySpec querySpecForInit, Map<String, String> commonRequestHeaders, Func3<PartitionKeyRange, String, Integer, RxDocumentServiceRequest> createRequestFunc, Func1<RxDocumentServiceRequest, Observable<FeedResponse<T>>> executeFunc, Func0<IDocumentClientRetryPolicy> createRetryPolicyFunc) { return new OrderByDocumentProducer<T>(consumeComparer, client, collectionRid, feedOptions, createRequestFunc, executeFunc, targetRange, collectionRid, () -> client.getResetSessionTokenRetryPolicy().getRequestPolicy(), resourceType, correlatedActivityId, initialPageSize, continuationToken, top, this.targetRangeToOrderByContinuationTokenMap); }
Example #24
Source File: RxHelper.java From sfs with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public static final <T1, T2, T3, R> Observable<R> combineSinglesDelayError(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Func3<? super T1, ? super T2, ? super T3, ? extends R> combineFunction) { return combineSinglesDelayError(asList(o1.single(), o2.single(), o3.single()), fromFunc(combineFunction)); }
Example #25
Source File: Observable.java From letv with Apache License 2.0 | 4 votes |
public static <T1, T2, T3, R> Observable<R> zip(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Func3<? super T1, ? super T2, ? super T3, ? extends R> zipFunction) { return just(new Observable[]{o1, o2, o3}).lift(new OperatorZip(zipFunction)); }
Example #26
Source File: Observable.java From letv with Apache License 2.0 | 4 votes |
public static <T1, T2, T3, R> Observable<R> combineLatest(Observable<? extends T1> o1, Observable<? extends T2> o2, Observable<? extends T3> o3, Func3<? super T1, ? super T2, ? super T3, ? extends R> combineFunction) { return combineLatest(Arrays.asList(new Observable[]{o1, o2, o3}), Functions.fromFunc(combineFunction)); }
Example #27
Source File: ParallelDocumentQueryExecutionContextBase.java From azure-cosmosdb-java with MIT License | 4 votes |
abstract protected DocumentProducer<T> createDocumentProducer(String collectionRid, PartitionKeyRange targetRange, String initialContinuationToken, int initialPageSize, FeedOptions feedOptions, SqlQuerySpec querySpecForInit, Map<String, String> commonRequestHeaders, Func3<PartitionKeyRange, String, Integer, RxDocumentServiceRequest> createRequestFunc, Func1<RxDocumentServiceRequest, Observable<FeedResponse<T>>> executeFunc, Func0<IDocumentClientRetryPolicy> createRetryPolicyFunc);
Example #28
Source File: TransformerStateMachine.java From rxjava-extras with Apache License 2.0 | 4 votes |
private static <State, Out, In> Func1<Notification<In>, Observable<Notification<Out>>> execute( final Func3<? super State, ? super In, ? super Subscriber<Out>, ? extends State> transition, final Func2<? super State, ? super Subscriber<Out>, Boolean> completion, final Mutable<State> state, final BackpressureStrategy backpressureStrategy) { return new Func1<Notification<In>, Observable<Notification<Out>>>() { @Override public Observable<Notification<Out>> call(final Notification<In> in) { Observable<Notification<Out>> o = Observable .create(new OnSubscribe<Notification<Out>>() { @Override public void call(Subscriber<? super Notification<Out>> subscriber) { Subscriber<Out> w = wrap(subscriber); if (in.hasValue()) { state.value = transition.call(state.value, in.getValue(), w); if (!subscriber.isUnsubscribed()) subscriber.onCompleted(); else { // this is a special emission to indicate that the // transition called unsubscribe. It will be // filtered later. subscriber.onNext(UnsubscribedNotificationHolder.<Out>unsubscribedNotification()); } } else if (in.isOnCompleted()) { if (completion.call(state.value, w) && !subscriber.isUnsubscribed()) { w.onCompleted(); } } else if (!subscriber.isUnsubscribed()) { w.onError(in.getThrowable()); } } }); // because the observable we just created does not // support backpressure we need to apply a backpressure // handling operator. This operator is supplied by the // user. return applyBackpressure(o, backpressureStrategy); } }; }
Example #29
Source File: DocumentProducer.java From azure-cosmosdb-java with MIT License | 4 votes |
public DocumentProducer( IDocumentQueryClient client, String collectionResourceId, FeedOptions feedOptions, Func3<PartitionKeyRange, String, Integer, RxDocumentServiceRequest> createRequestFunc, Func1<RxDocumentServiceRequest, Observable<FeedResponse<T>>> executeRequestFunc, PartitionKeyRange targetRange, String collectionLink, Func0<IDocumentClientRetryPolicy> createRetryPolicyFunc, Class<T> resourceType , UUID correlatedActivityId, int initialPageSize, // = -1, String initialContinuationToken, int top) { this.client = client; this.collectionRid = collectionResourceId; this.createRequestFunc = createRequestFunc; this.fetchSchedulingMetrics = new SchedulingStopwatch(); this.fetchSchedulingMetrics.ready(); this.fetchExecutionRangeAccumulator = new FetchExecutionRangeAccumulator(targetRange.getId()); this.executeRequestFuncWithRetries = request -> { retries = -1; this.fetchSchedulingMetrics.start(); this.fetchExecutionRangeAccumulator.beginFetchRange(); IDocumentClientRetryPolicy retryPolicy = null; if (createRetryPolicyFunc != null) { retryPolicy = createRetryPolicyFunc.call(); } final IDocumentClientRetryPolicy finalRetryPolicy = retryPolicy; return ObservableHelper.inlineIfPossibleAsObs( () -> { if (finalRetryPolicy != null) { finalRetryPolicy.onBeforeSendRequest(request); } ++retries; return executeRequestFunc.call(request); }, retryPolicy); }; this.correlatedActivityId = correlatedActivityId; this.feedOptions = feedOptions != null ? new FeedOptions(feedOptions) : new FeedOptions(); this.feedOptions.setRequestContinuation(initialContinuationToken); this.lastResponseContinuationToken = initialContinuationToken; this.resourceType = resourceType; this.targetRange = targetRange; this.collectionLink = collectionLink; this.createRetryPolicyFunc = createRetryPolicyFunc; this.pageSize = initialPageSize; this.top = top; }
Example #30
Source File: LoadBalancerRule.java From ocelli with Apache License 2.0 | 4 votes |
public LoadBalancerRule(Func3<Observable<Instance<SocketAddress>>, Func1<FailureListener, ? extends TcpClientEventListener>, LoadBalancerStrategy<HostConnectionProvider<String, String>>, AbstractLoadBalancer<String, String>> lbFactory) { this.lbFactory = lbFactory; }