/** * Creates a new {@link AbstractKeyValueRequest}. * * @param key the key of the document. * @param bucket the bucket of the document. * @param username the user authorized for bucket access. * @param password the password for the user. */ protected AbstractKeyValueRequest(String key, String bucket, String username, String password) { this(key, bucket, username, password, AsyncSubject.<CouchbaseResponse>create()); }
/** * Creates a new {@link AbstractSubdocRequest}. * * @param key the key of the document. * @param path the subdocument path to consider inside the document. * @param bucket the bucket of the document. * @param restOfContent the optional remainder of the {@link #content()} of the final protocol message, or null if not applicable * @throws NullPointerException if the path is null (see {@link #EXCEPTION_NULL_PATH}) */ public AbstractSubdocRequest(String key, String path, String bucket, ByteBuf... restOfContent) { this(key, path, bucket, AsyncSubject.<CouchbaseResponse>create(), restOfContent); }
@Override public final Subject<T, T> call() { return AsyncSubject.create(); } }, selector);
/** * Creates a new {@link AbstractKeyValueRequest}. * * @param key the key of the document. * @param bucket the bucket of the document. */ protected AbstractKeyValueRequest(String key, String bucket) { this(key, bucket, null, null, AsyncSubject.<CouchbaseResponse>create()); }
/** * Creates a new {@link AbstractKeyValueRequest}. * * @param key the key of the document. * @param bucket the bucket of the document. * @param password the password for the bucket. */ protected AbstractKeyValueRequest(String key, String bucket, String password) { this(key, bucket, bucket, password, AsyncSubject.<CouchbaseResponse>create()); }
/** * Creates a new {@link AbstractKeyValueRequest}. * * @param key the key of the document. * @param bucket the bucket of the document. * @param username the user authorized for bucket access. * @param password the password for the user. */ protected AbstractKeyValueRequest(String key, String bucket, String username, String password) { this(key, bucket, username, password, AsyncSubject.<CouchbaseResponse>create()); }
/** * Creates a new {@link AbstractSubdocRequest}. * * @param key the key of the document. * @param path the subdocument path to consider inside the document. * @param bucket the bucket of the document. * @param restOfContent the optional remainder of the {@link #content()} of the final protocol message, or null if not applicable * @throws NullPointerException if the path is null (see {@link #EXCEPTION_NULL_PATH}) */ public AbstractSubdocRequest(String key, String path, String bucket, ByteBuf... restOfContent) { this(key, path, bucket, AsyncSubject.<CouchbaseResponse>create(), restOfContent); }
/** * Creates a new {@link AbstractKeyValueRequest}. * * @param key the key of the document. * @param bucket the bucket of the document. */ protected AbstractKeyValueRequest(String key, String bucket) { this(key, bucket, null, null, AsyncSubject.<CouchbaseResponse>create()); }
/** * Creates a new {@link AbstractKeyValueRequest}. * * @param key the key of the document. * @param bucket the bucket of the document. * @param password the password for the bucket. */ protected AbstractKeyValueRequest(String key, String bucket, String password) { this(key, bucket, bucket, password, AsyncSubject.<CouchbaseResponse>create()); }
@Override public Subject<? super T, ? extends T> call() { return AsyncSubject.<T> create(); }
/** * Creates a new {@link AbstractSubdocMutationRequest}. * * @param key the key of the document. * @param path the subdocument path to consider inside the document. * @param fragment the fragment of valid JSON to mutate into at the site denoted by the path. * @param bucket the bucket of the document. * @param expiration the TTL of the whole enclosing document. * @param cas the cas value for the operation * @throws NullPointerException if the path is null (see {@link #EXCEPTION_NULL_PATH}) */ protected AbstractSubdocMutationRequest(String key, String path, ByteBuf fragment, String bucket, int expiration, long cas) { this(key, path, fragment, bucket, expiration, cas, AsyncSubject.<CouchbaseResponse>create()); }
/** * Creates a new {@link AbstractSubdocMutationRequest}. * * @param key the key of the document. * @param path the subdocument path to consider inside the document. * @param fragment the fragment of valid JSON to mutate into at the site denoted by the path. * @param bucket the bucket of the document. * @param expiration the TTL of the whole enclosing document. * @param cas the cas value for the operation * @throws NullPointerException if the path is null (see {@link #EXCEPTION_NULL_PATH}) */ protected AbstractSubdocMutationRequest(String key, String path, ByteBuf fragment, String bucket, int expiration, long cas) { this(key, path, fragment, bucket, expiration, cas, AsyncSubject.<CouchbaseResponse>create()); }
/** * Create a new {@link AbstractCouchbaseRequest}. * * Depending on the type of operation, bucket and password may be null, this needs to * be enforced properly by the child implementations. * * This constructor will create a AsyncSubject, which implies that the response for this * request only emits one message. If you need to expose a streaming response, use the * other constructor and feed it a ReplaySubject or something similar. * * @param bucket the name of the bucket. * @param password user password. */ protected AbstractCouchbaseRequest(String bucket, String password) { this(bucket, bucket, password, AsyncSubject.<CouchbaseResponse>create()); }
/** * Create a new {@link AbstractCouchbaseRequest}. * * Depending on the type of operation, bucket and password may be null, this needs to * be enforced properly by the child implementations. * * This constructor will create a AsyncSubject, which implies that the response for this * request only emits one message. If you need to expose a streaming response, use the * other constructor and feed it a ReplaySubject or something similar. * * @param bucket the name of the bucket. * @param username user authorized to access the bucket. * @param password user password. */ protected AbstractCouchbaseRequest(String bucket, String username, String password) { this(bucket, username, password, AsyncSubject.<CouchbaseResponse>create()); }
/** * Create a new {@link AbstractCouchbaseRequest}. * * Depending on the type of operation, bucket and password may be null, this needs to * be enforced properly by the child implementations. * * This constructor will create a AsyncSubject, which implies that the response for this * request only emits one message. If you need to expose a streaming response, use the * other constructor and feed it a ReplaySubject or something similar. * * @param bucket the name of the bucket. * @param password user password. */ protected AbstractCouchbaseRequest(String bucket, String password) { this(bucket, bucket, password, AsyncSubject.<CouchbaseResponse>create()); }
static PendingAck create(long expiryTime) { final Subject<Void, Void> ackSubject = AsyncSubject.create(); OnSubscribe<Void> onSubscribe = new OnSubscribe<Void>() { @Override public void call(Subscriber<? super Void> subscriber) { ackSubject.subscribe(subscriber); } }; return new PendingAck(onSubscribe, ackSubject, expiryTime); } }
/** * An internal alternative to {@link #connect()} where signalling that this is * post-bootstrapping can be done. * * @param bootstrapping is this connect attempt made during bootstrap or after (in * which case more error cases are eligible for retries). */ protected Observable<LifecycleState> connect(boolean bootstrapping) { if (state() != LifecycleState.DISCONNECTED) { return Observable.just(state()); } final AsyncSubject<LifecycleState> observable = AsyncSubject.create(); transitionState(LifecycleState.CONNECTING); hasWritten = false; doConnect(observable, bootstrapping); return observable; }
@Override public void run() { AsyncSubject<Integer> s = AsyncSubject.create(); s.subscribe(new Action1<Integer>() { @Override public void call(Integer integer) { log("" + integer); } }); s.onNext(0); s.onNext(1); s.onNext(2); s.onCompleted(); } });
@OnClick(R.id.async_subject_test_error) public void onAsyncSubjectTestWithErrorClick() { unsubscribe(); createSubscription(); AsyncSubject<Stock> stockAsyncSubject = AsyncSubject.create(); stockAsyncSubject.onNext(new Stock(GOOG, 722)); // Will get the last value (GOOG, 723) and all future items and terminal events Subscription subscription = stockAsyncSubject.subscribe(getDefaultSubscriber()); compositeSubscription.add(subscription); stockAsyncSubject.onNext(new Stock(GOOG, 723)); stockAsyncSubject.onNext(new Stock(GOOG, 100)); stockAsyncSubject.onNext(new Stock(GOOG, 699)); stockAsyncSubject.onError(new Exception("Boom!")); // current and future subscribers will only receive this, with NO items emitted. Subscription tardySubscription = stockAsyncSubject.subscribe(getTardySubscriber()); compositeSubscription.add(tardySubscription); }
@OnClick(R.id.async_subject_test) public void onAsyncSubjectTestClick() { unsubscribe(); createSubscription(); AsyncSubject<Stock> stockAsyncSubject = AsyncSubject.create(); stockAsyncSubject.onNext(new Stock(GOOG, 722)); // Will get the last value (GOOG, 723) and all future items and terminal events Subscription subscription = stockAsyncSubject.subscribe(getDefaultSubscriber()); compositeSubscription.add(subscription); stockAsyncSubject.onNext(new Stock(GOOG, 723)); stockAsyncSubject.onNext(new Stock(GOOG, 100)); stockAsyncSubject.onNext(new Stock(GOOG, 699)); stockAsyncSubject.onCompleted(); Subscription tardySubscription = stockAsyncSubject.subscribe(getTardySubscriber()); compositeSubscription.add(tardySubscription); }