/*
 * Copyright 2014 Red Hat, Inc.
 *
 * Red Hat licenses this file to you under the Apache License, version 2.0
 * (the "License"); you may not use this file except in compliance with the
 * License.  You may obtain a copy of the License at:
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 * License for the specific language governing permissions and limitations
 * under the License.
 */

package io.vertx.rxjava.servicediscovery.types;

import rx.Observable;
import rx.Single;
import io.vertx.rx.java.RxHelper;
import io.vertx.rx.java.WriteStreamSubscriber;
import io.vertx.rx.java.SingleOnSubscribeAdapter;
import java.util.Map;
import java.util.Set;
import java.util.List;
import java.util.Iterator;
import java.util.function.Function;
import java.util.stream.Collectors;
import io.vertx.core.Handler;
import io.vertx.core.AsyncResult;
import io.vertx.core.json.JsonObject;
import io.vertx.core.json.JsonArray;
import io.vertx.lang.rx.RxGen;
import io.vertx.lang.rx.TypeArg;
import io.vertx.lang.rx.MappingIterator;

Service type for data producer. Providers are publishing data to a specific event bus address.

NOTE: This class has been automatically generated from the original non RX-ified interface using Vert.x codegen.
/** * Service type for data producer. Providers are publishing data to a specific event bus address. * * <p/> * NOTE: This class has been automatically generated from the {@link io.vertx.servicediscovery.types.MessageSource original} non RX-ified interface using Vert.x codegen. */
@RxGen(io.vertx.servicediscovery.types.MessageSource.class) public class MessageSource { @Override public String toString() { return delegate.toString(); } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; MessageSource that = (MessageSource) o; return delegate.equals(that.delegate); } @Override public int hashCode() { return delegate.hashCode(); } public static final TypeArg<MessageSource> __TYPE_ARG = new TypeArg<>( obj -> new MessageSource((io.vertx.servicediscovery.types.MessageSource) obj), MessageSource::getDelegate ); private final io.vertx.servicediscovery.types.MessageSource delegate; public MessageSource(io.vertx.servicediscovery.types.MessageSource delegate) { this.delegate = delegate; } public MessageSource(Object delegate) { this.delegate = (io.vertx.servicediscovery.types.MessageSource)delegate; } public io.vertx.servicediscovery.types.MessageSource getDelegate() { return delegate; }
Create a record representing a data producer.
Params:
  • name – the name of the service
  • address – the address on which the data is sent
  • type – the type of payload (fully qualified name of the class)
  • metadata – additional metadata
Returns:the created record
/** * Create a record representing a data producer. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload (fully qualified name of the class) * @param metadata additional metadata * @return the created record */
public static io.vertx.servicediscovery.Record createRecord(String name, String address, String type, JsonObject metadata) { io.vertx.servicediscovery.Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type, metadata); return ret; }
Same as createRecord without additional metadata.
Params:
  • name – the name of the service
  • address – the address on which the data is sent
  • type – the type of payload
Returns:the created record
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata. * @param name the name of the service * @param address the address on which the data is sent * @param type the type of payload * @return the created record */
public static io.vertx.servicediscovery.Record createRecord(String name, String address, String type) { io.vertx.servicediscovery.Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address, type); return ret; }
Same as createRecord without additional metadata, and no type for the payload.
Params:
  • name – the name of the service
  • address – the address on which the data is sent.
Returns:the created record
/** * Same as {@link io.vertx.rxjava.servicediscovery.types.MessageSource#createRecord} without additional metadata, and no type for * the payload. * @param name the name of the service * @param address the address on which the data is sent. * @return the created record */
public static io.vertx.servicediscovery.Record createRecord(String name, String address) { io.vertx.servicediscovery.Record ret = io.vertx.servicediscovery.types.MessageSource.createRecord(name, address); return ret; }
Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.
Params:
  • discovery – The service discovery instance
  • filter – The filter, optional
  • resultHandler – The result handler
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, optional * @param resultHandler The result handler */
public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, JsonObject filter, Handler<AsyncResult<io.vertx.rxjava.core.eventbus.MessageConsumer<T>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery.getDelegate(), filter, new Handler<AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>>>() { public void handle(AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.eventbus.MessageConsumer.newInstance((io.vertx.core.eventbus.MessageConsumer)ar.result(), TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.
Params:
  • discovery – The service discovery instance
  • filter – The filter, optional
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, optional */
public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, JsonObject filter) { getConsumer(discovery, filter, ar -> { }); }
Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.
Params:
  • discovery – The service discovery instance
  • filter – The filter, optional
Returns:
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, optional * @return */
public static <T> Single<io.vertx.rxjava.core.eventbus.MessageConsumer<T>> rxGetConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, JsonObject filter) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { getConsumer(discovery, filter, fut); })); }
Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.
Params:
  • discovery – The service discovery instance
  • filter – The filter, must not be null
  • resultHandler – The result handler
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, must not be <code>null</code> * @param resultHandler The result handler */
public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, Function<io.vertx.servicediscovery.Record, Boolean> filter, Handler<AsyncResult<io.vertx.rxjava.core.eventbus.MessageConsumer<T>>> resultHandler) { io.vertx.servicediscovery.types.MessageSource.getConsumer(discovery.getDelegate(), filter, new Handler<AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>>>() { public void handle(AsyncResult<io.vertx.core.eventbus.MessageConsumer<T>> ar) { if (ar.succeeded()) { resultHandler.handle(io.vertx.core.Future.succeededFuture(io.vertx.rxjava.core.eventbus.MessageConsumer.newInstance((io.vertx.core.eventbus.MessageConsumer)ar.result(), TypeArg.unknown()))); } else { resultHandler.handle(io.vertx.core.Future.failedFuture(ar.cause())); } } }); }
Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.
Params:
  • discovery – The service discovery instance
  • filter – The filter, must not be null
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, must not be <code>null</code> */
public static <T> void getConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, Function<io.vertx.servicediscovery.Record, Boolean> filter) { getConsumer(discovery, filter, ar -> { }); }
Convenient method that looks for a message source and provides the configured . The async result is marked as failed is there are no matching services, or if the lookup fails.
Params:
  • discovery – The service discovery instance
  • filter – The filter, must not be null
Returns:
/** * Convenient method that looks for a message source and provides the configured . The * async result is marked as failed is there are no matching services, or if the lookup fails. * @param discovery The service discovery instance * @param filter The filter, must not be <code>null</code> * @return */
public static <T> Single<io.vertx.rxjava.core.eventbus.MessageConsumer<T>> rxGetConsumer(io.vertx.rxjava.servicediscovery.ServiceDiscovery discovery, Function<io.vertx.servicediscovery.Record, Boolean> filter) { return Single.create(new SingleOnSubscribeAdapter<>(fut -> { getConsumer(discovery, filter, fut); })); }
Unknown type.
/** * Unknown type. */
public static final String UNKNOWN = io.vertx.servicediscovery.types.MessageSource.UNKNOWN; public static final String TYPE = io.vertx.servicediscovery.types.MessageSource.TYPE; public static MessageSource newInstance(io.vertx.servicediscovery.types.MessageSource arg) { return arg != null ? new MessageSource(arg) : null; } }