/** * signal an error to sender. Will automatically "close" the callback if remoted. * same as complete( null, error ); * * @param error */ default void reject(Object error) { complete(null, error); }
private void fireChange(String webPath) { watchers = watchers.stream().filter( cb -> ! cb.isTerminated() ).collect(Collectors.toList()); watchers.forEach( w -> w.pipe(webPath)); }
public static void main(String[] args) { String arr[] = {"a","b","c","d","e"}; KFlow<String> ks = new KFlow() .filter( x -> x.equals("b") ) .each(x -> System.out.println(x)); for (int i = 0; i < arr.length; i++) { String s = arr[i]; ks.cb().pipe(s); } } }
public Promise<Boolean> unSubscribe(int id, Callback cb) { Callback removed = getSubsMap().remove(id); if ( removed != null ) // ensure remote mapping is cleaned up removed.finish(); return new Promise( removed != null ); }
public void cleanUp() { Iterator<Map.Entry<Integer, Callback>> it = getSubsMap().entrySet().iterator(); while( it.hasNext() ) { Map.Entry<Integer, Callback> next = it.next(); if ( next.getValue().isTerminated() ) it.remove(); } }
if ( ! success ) { if (rce.getCB() != null) { rce.getCB().reject(SERVICE_UNAVAILABLE);
public static void main(String[] args) { String arr[] = {"a","b","c","d","e"}; KFlow<String> ks = new KFlow() .filter( x -> x.equals("b") ) .each(x -> System.out.println(x)); for (int i = 0; i < arr.length; i++) { String s = arr[i]; ks.cb().pipe(s); } } }
public Promise<Boolean> unSubscribe(int id, Callback cb) { Callback removed = getSubsMap().remove(id); if ( removed != null ) // ensure remote mapping is cleaned up removed.finish(); return new Promise( removed != null ); }
public void cleanUp() { Iterator<Map.Entry<Integer, Callback>> it = getSubsMap().entrySet().iterator(); while( it.hasNext() ) { Map.Entry<Integer, Callback> next = it.next(); if ( next.getValue().isTerminated() ) it.remove(); } }
if ( ! success ) { if (rce.getCB() != null) { rce.getCB().reject(SERVICE_UNAVAILABLE);
/** * invalid for Promises!. can be called more than once on Callback's in order to stream objects to the sender. * same as complete( result, CONT ); * * @param result */ default Callback pipe(T result) { complete(result, CONT); return this; }
public void _subscribe(RLPredicate pred, Callback cb, int id) { checkThread(); Subscriber localSubs = new Subscriber(pred, change -> { cb.pipe(change); }).serverSideCB(cb); String sid = addChannelIdIfPresent(cb, ""+id);
public void _unsubscribe( Callback cb /*dummy required to find sending connection*/, int id ) { checkThread(); String sid = addChannelIdIfPresent(cb, ""+id); Subscriber subs = (Subscriber) receiverSideSubsMap.get(sid); filterProcessor.unsubscribe(subs); receiverSideSubsMap.remove(sid); cb.finish(); subs.getServerSideCB().finish(); }
/** * same as complete(null,null) and resolve(null) */ default void resolve() { complete(null, null); }
@CallerSideMethod default <R> void map(RLPredicate<Record> predicate, RLFunction<Record,R> mapFun, Callback<R> cb ) { forEachWithSpore(new MapSpore(predicate,mapFun).setForEach(cb).onFinish( () -> cb.finish() )); }
/** * signal end of streamed objects (required for remoteref housekeeping if actors run remotely) * same as complete( null, null ); * */ default void finish() { complete(null, null); }
@CallerSideMethod default void forEach(RLPredicate<Record> predicate, Callback<Record> cb ) { forEachWithSpore(new FilterSpore(predicate).setForEach(cb).onFinish( () -> cb.finish() )); }
/** * note that sending an error implicitely will close the backstream. * @param err */ protected void streamError(Object err) { cb.complete(null, err); }
/** * signal an error to sender. Will automatically "close" the callback if remoted. * same as complete( null, error ); * * @param error */ default void reject(Object error) { complete(null, error); }
/** * invalid for Promises!. can be called more than once on Callback's in order to stream objects to the sender. * same as complete( result, CONT ); * * @param result */ default Callback pipe(T result) { complete(result, CONT); return this; }