/** * Registers publisher using a given api * See Events#publisher(Class, Result) for documentation * * @see Events#publisher(Class, Result) */ @Pin <T> T publisher(Class<T> api);
/** * Registers subscribers using a given api * See Events#subscriber(Class, Object, Result) for documentation * * @see Events#subscriber(Class, Object, Result) */ <T> Cancel subscriber(Class<T> api, @Pin T subscriber); }
/** * Registers consumer using a given api * See Events#consumer(Class, Object, Result) for documentation * * @see Events#consumer(Class, Object, Result) */ <T> Cancel consumer(Class<T> api, @Pin T consumer);
/** * Registers an event publisher of a given class. * <p> * Internally, the api.getName() is used as a path. * * @param api api class (interface) of the sender proxy * @param result holder for the sender proxy instance * @param <T> type i.e. sender interface */ <T> void publisher(Class<T> api, @Pin Result<T> result);
/** * Registers a subscriber at a given path. * * @param path path / queue name * @param consumer consumer object, must conform to the sender api * @param result holder for event consumer cancel handler * @param <T> type i.e. receiver interface */ <T> void subscriber(String path, @Pin T consumer, Result<? super Cancel> result);
/** * Registers publisher at path. * See Events#publisherPath(String, Class, Result) for documentation * * @see Events#publisherPath(String, Class, Result) */ @Pin <T> T publisherPath(String path, Class<T> api);
/** * Registers consumer for a given path. * See Events#consumer(String, Object, Result) for documentation * * @see Events#consumer(String, Object, Result) */ <T> Cancel consumer(String path, @Pin T consumer);
/** * Registers subscriber for a given path * See Events#subscriber(String, Object, Result) for documentation * * @see Events#subscriber(String, Object, Result) */ <T> Cancel subscriber(String path, @Pin T subscriber);
/** * Registers an event publisher at a given path. * * @param path path / queue name * @param api api class (interface) of the sender proxy * @param result holder for the sender proxy instance * @param <T> type i.e. sender interface */ <T> void publisherPath(String path, Class<T> api, @Pin Result<T> result);
/** * Registers consumer at a given path. * <p> * Messages are consumed after reaching a consumer. * * @param path path / queue name * @param consumer consumer object, must conform to the sender api * @param result holder for event consumer cancel handler * @param <T> type i.e. receiver interface */ <T> void consumer(String path, @Pin T consumer, Result<? super Cancel> result);
/** * Registers consumer using a given api class. * <p> * Internally, the api.getName() is used as a path. * * @param api api class (interface) of a consumer object * @param consumer consumer object, must conform to the sender api * @param result holder for event consumer cancel handler * @param <T> type i.e. receiver interface */ <T> void consumer(Class<T> api, @Pin T consumer, Result<? super Cancel> result);
/** * Registers a subscriber using a given api class. * <p> * Internally, the api.getName() is used as a path * * @param api api class (interface) of a consumer object * @param consumer consumer object, must conform ot the sender api * @param result holder for event consumer cancel handler * @param <T> type i.e. receiver interface */ <T> void subscriber(Class<T> api, @Pin T consumer, Result<? super Cancel> result); }
/** * Run the task at the given time. * * The task implements {@code Consumer} to accept a cancel. * * <blockquote><pre> * // run 5 seconds from now * timers.runAt(task, System.currentTimeMillis() + 5000); * </pre></blockquote> * * @param task the task to execute * @param time millisecond time since epoch to run * @return cancel handler */ Cancel runAt(@Pin Consumer<? super Cancel> task, long time);
/** * Run the task <b>once</b> after the given delay. * * <pre> * MyRunnable task = new MyRunnable(); * * // run once 10 seconds from now * timers.runAfter(task, 10, TimeUnit.SECONDS); * </pre> * * @param task the executable timer task * @param delay time to delay in units * @param unit unit type specifier * @return cancel handler */ Cancel runAfter(@Pin Consumer<? super Cancel> task, long delay, TimeUnit unit);
/** * Implements {@link Timers#runAfter(Runnable, long, TimeUnit)} */ @Override public void runEvery(@Pin Consumer<? super Cancel> task, long delay, TimeUnit unit, Result<? super Cancel> result) { // cancel(task); long period = unit.toMillis(delay); if (period <= 0) { throw new IllegalArgumentException(); } schedule(task, new RunEveryScheduler(period), result); }
/** * Implements {@link Timers#runAfter(Runnable, long, TimeUnit)} */ @Override public void runAfter(@Pin Consumer<? super Cancel> task, long delay, TimeUnit unit, Result<? super Cancel> result) { Objects.requireNonNull(task); Objects.requireNonNull(unit); TimerListener listener = new TimerListener(task, null); // _timerMap.put(task, listener); listener.alarm().runAfter(unit.toMillis(delay)); result.ok(listener); }
/** * Subscribe a callback to a location. */ public void subscriber(Class<?> api, @Pin ServiceRefAmp serviceRef, Result<? super Cancel> result) { String path = api.getName(); String address = address(path); EventNodeAsset node = lookupPubSubNode(address); Cancel cancel = node.subscribeImpl(serviceRef); result.ok(cancel); }
/** * Consume a callback to a location. */ public void consumer(Class<?> api, @Pin ServiceRefAmp serviceRef, Result<? super Cancel> result) { String path = api.getName(); String address = address(path); EventNodeAsset node = lookupPubSubNode(address); Cancel cancel = node.consumeImpl(serviceRef); result.ok(cancel); }
/** * Subscribe a callback to a location. */ public void subscriber(String path, @Pin ServiceRefAmp serviceRef, Result<? super Cancel> result) { if (path.isEmpty()) { result.fail(new ServiceException(L.l("Invalid event location '{0}'", path))); return; } String address = address(path); EventNodeAsset node = lookupPubSubNode(address); Cancel cancel = node.subscribeImpl(serviceRef); result.ok(cancel); }
/** * Consume a callback to a location. */ public void consumer(String path, @Pin ServiceRefAmp serviceRef, Result<? super Cancel> result) { if (path.isEmpty()) { result.fail(new ServiceException(L.l("Invalid event location '{0}'", path))); return; } String address = address(path); EventNodeAsset node = lookupPubSubNode(address); Cancel cancel = node.consumeImpl(serviceRef); result.ok(cancel); }