Search in sources :

Example 71 with AsyncResult

use of io.vertx.core.AsyncResult in project vertx-proton by vert-x3.

the class ProtonSubscriberIntTest method createServer.

private ProtonServer createServer(Handler<ProtonConnection> serverConnHandler) throws InterruptedException, ExecutionException {
    ProtonServer server = ProtonServer.create(vertx);
    server.connectHandler(serverConnHandler);
    FutureHandler<ProtonServer, AsyncResult<ProtonServer>> handler = FutureHandler.asyncResult();
    server.listen(0, handler);
    handler.get();
    return server;
}
Also used : ProtonServer(io.vertx.proton.ProtonServer) AsyncResult(io.vertx.core.AsyncResult)

Example 72 with AsyncResult

use of io.vertx.core.AsyncResult in project vertx-proton by vert-x3.

the class ProtonPublisherIntTest method createServer.

private ProtonServer createServer(Handler<ProtonConnection> serverConnHandler) throws InterruptedException, ExecutionException {
    ProtonServer server = ProtonServer.create(vertx);
    server.connectHandler(serverConnHandler);
    FutureHandler<ProtonServer, AsyncResult<ProtonServer>> handler = FutureHandler.asyncResult();
    server.listen(0, handler);
    handler.get();
    return server;
}
Also used : ProtonServer(io.vertx.proton.ProtonServer) AsyncResult(io.vertx.core.AsyncResult)

Example 73 with AsyncResult

use of io.vertx.core.AsyncResult in project nem2-sdk-java by nemtech.

the class AccountRepositoryVertxImpl method getAccountsInfo.

@Override
public Observable<List<AccountInfo>> getAccountsInfo(List<Address> addresses) {
    AccountIds accountIds = new AccountIds().addresses(addresses.stream().map(Address::plain).collect(Collectors.toList()));
    Consumer<Handler<AsyncResult<List<AccountInfoDTO>>>> callback = handler -> getClient().getAccountsInfo(accountIds, handler);
    return exceptionHandling(call(callback).flatMapIterable(item -> item).map(this::toAccountInfo).toList().toObservable());
}
Also used : AccountDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountDTO) AccountOrderByEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountOrderByEnum) MapperUtils.toMosaicId(io.nem.symbol.core.utils.MapperUtils.toMosaicId) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) AccountType(io.nem.symbol.sdk.model.account.AccountType) SupplementalPublicKeysDTO(io.nem.symbol.sdk.openapi.vertx.model.SupplementalPublicKeysDTO) MapperUtils.toAddress(io.nem.symbol.core.utils.MapperUtils.toAddress) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountInfoDTO) ObjectUtils(org.apache.commons.lang3.ObjectUtils) AccountRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.AccountRoutesApi) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) ActivityBucket(io.nem.symbol.sdk.model.account.ActivityBucket) Observable(io.reactivex.Observable) AsyncResult(io.vertx.core.AsyncResult) AccountPage(io.nem.symbol.sdk.openapi.vertx.model.AccountPage) AccountIds(io.nem.symbol.sdk.openapi.vertx.model.AccountIds) ResolvedMosaic(io.nem.symbol.sdk.model.mosaic.ResolvedMosaic) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) List(java.util.List) SupplementalAccountKeys(io.nem.symbol.sdk.model.account.SupplementalAccountKeys) PublicKey(io.nem.symbol.core.crypto.PublicKey) AccountLinkPublicKeyDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO) AccountLinkVotingKey(io.nem.symbol.sdk.model.account.AccountLinkVotingKey) Address(io.nem.symbol.sdk.model.account.Address) AccountRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.AccountRoutesApiImpl) Handler(io.vertx.core.Handler) Collections(java.util.Collections) Page(io.nem.symbol.sdk.api.Page) AccountIds(io.nem.symbol.sdk.openapi.vertx.model.AccountIds) MapperUtils.toAddress(io.nem.symbol.core.utils.MapperUtils.toAddress) Address(io.nem.symbol.sdk.model.account.Address) Handler(io.vertx.core.Handler) List(java.util.List)

Example 74 with AsyncResult

use of io.vertx.core.AsyncResult in project nem2-sdk-java by nemtech.

the class AccountRepositoryVertxImpl method search.

@Override
public Observable<Page<AccountInfo>> search(AccountSearchCriteria criteria) {
    Integer pageSize = criteria.getPageSize();
    Integer pageNumber = criteria.getPageNumber();
    String offset = criteria.getOffset();
    Order order = toDto(criteria.getOrder());
    AccountOrderByEnum orderBy = criteria.getOrderBy() == null ? null : AccountOrderByEnum.fromValue(criteria.getOrderBy().getValue());
    String mosaicId = criteria.getMosaicId() == null ? null : criteria.getMosaicId().getIdAsHex();
    Consumer<Handler<AsyncResult<AccountPage>>> callback = (handler) -> getClient().searchAccounts(pageSize, pageNumber, offset, order, orderBy, mosaicId, handler);
    return exceptionHandling(call(callback).map(page -> this.toPage(page.getPagination(), page.getData().stream().map(this::toAccountInfo).collect(Collectors.toList()))));
}
Also used : Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountOrderByEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountOrderByEnum) AccountDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountDTO) AccountOrderByEnum(io.nem.symbol.sdk.openapi.vertx.model.AccountOrderByEnum) MapperUtils.toMosaicId(io.nem.symbol.core.utils.MapperUtils.toMosaicId) AccountRepository(io.nem.symbol.sdk.api.AccountRepository) AccountType(io.nem.symbol.sdk.model.account.AccountType) SupplementalPublicKeysDTO(io.nem.symbol.sdk.openapi.vertx.model.SupplementalPublicKeysDTO) MapperUtils.toAddress(io.nem.symbol.core.utils.MapperUtils.toAddress) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) AccountInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountInfoDTO) ObjectUtils(org.apache.commons.lang3.ObjectUtils) AccountRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.AccountRoutesApi) AccountInfo(io.nem.symbol.sdk.model.account.AccountInfo) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) ActivityBucket(io.nem.symbol.sdk.model.account.ActivityBucket) Observable(io.reactivex.Observable) AsyncResult(io.vertx.core.AsyncResult) AccountPage(io.nem.symbol.sdk.openapi.vertx.model.AccountPage) AccountIds(io.nem.symbol.sdk.openapi.vertx.model.AccountIds) ResolvedMosaic(io.nem.symbol.sdk.model.mosaic.ResolvedMosaic) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) AccountSearchCriteria(io.nem.symbol.sdk.api.AccountSearchCriteria) Collectors(java.util.stream.Collectors) Consumer(java.util.function.Consumer) List(java.util.List) SupplementalAccountKeys(io.nem.symbol.sdk.model.account.SupplementalAccountKeys) PublicKey(io.nem.symbol.core.crypto.PublicKey) AccountLinkPublicKeyDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountLinkPublicKeyDTO) AccountLinkVotingKey(io.nem.symbol.sdk.model.account.AccountLinkVotingKey) Address(io.nem.symbol.sdk.model.account.Address) AccountRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.AccountRoutesApiImpl) Handler(io.vertx.core.Handler) Collections(java.util.Collections) Page(io.nem.symbol.sdk.api.Page) AccountPage(io.nem.symbol.sdk.openapi.vertx.model.AccountPage) Handler(io.vertx.core.Handler)

Example 75 with AsyncResult

use of io.vertx.core.AsyncResult in project nem2-sdk-java by nemtech.

the class NamespaceRepositoryVertxImpl method getNamespaceNames.

@Override
public Observable<List<NamespaceName>> getNamespaceNames(List<NamespaceId> namespaceIds) {
    NamespaceIds ids = new NamespaceIds().namespaceIds(namespaceIds.stream().map(NamespaceId::getIdAsHex).collect(Collectors.toList()));
    Consumer<Handler<AsyncResult<List<NamespaceNameDTO>>>> callback = handler -> client.getNamespacesNames(ids, handler);
    return exceptionHandling(call(callback).flatMapIterable(item -> item).map(this::toNamespaceName).toList().toObservable());
}
Also used : AliasTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.AliasTypeEnum) NamespaceInfo(io.nem.symbol.sdk.model.namespace.NamespaceInfo) NamespaceDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceDTO) Addresses(io.nem.symbol.sdk.openapi.vertx.model.Addresses) NamespaceRepository(io.nem.symbol.sdk.api.NamespaceRepository) NamespaceRoutesApi(io.nem.symbol.sdk.openapi.vertx.api.NamespaceRoutesApi) ArrayList(java.util.ArrayList) Order(io.nem.symbol.sdk.openapi.vertx.model.Order) MapperUtils.toNamespaceId(io.nem.symbol.core.utils.MapperUtils.toNamespaceId) NamespaceSearchCriteria(io.nem.symbol.sdk.api.NamespaceSearchCriteria) ObjectUtils(org.apache.commons.lang3.ObjectUtils) MerkleStateInfo(io.nem.symbol.sdk.model.blockchain.MerkleStateInfo) MosaicAlias(io.nem.symbol.sdk.model.namespace.MosaicAlias) Observable(io.reactivex.Observable) AsyncResult(io.vertx.core.AsyncResult) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId) MosaicNamesDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicNamesDTO) MapperUtils(io.nem.symbol.core.utils.MapperUtils) Alias(io.nem.symbol.sdk.model.namespace.Alias) ApiClient(io.nem.symbol.sdk.openapi.vertx.invoker.ApiClient) MosaicsNamesDTO(io.nem.symbol.sdk.openapi.vertx.model.MosaicsNamesDTO) NamespaceName(io.nem.symbol.sdk.model.namespace.NamespaceName) NamespacePage(io.nem.symbol.sdk.openapi.vertx.model.NamespacePage) MosaicNames(io.nem.symbol.sdk.model.mosaic.MosaicNames) NamespaceNameDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceNameDTO) MosaicId(io.nem.symbol.sdk.model.mosaic.MosaicId) NamespaceRegistrationTypeEnum(io.nem.symbol.sdk.openapi.vertx.model.NamespaceRegistrationTypeEnum) EmptyAlias(io.nem.symbol.sdk.model.namespace.EmptyAlias) Collectors(java.util.stream.Collectors) NamespaceRoutesApiImpl(io.nem.symbol.sdk.openapi.vertx.api.NamespaceRoutesApiImpl) MosaicIds(io.nem.symbol.sdk.openapi.vertx.model.MosaicIds) NamespaceIds(io.nem.symbol.sdk.openapi.vertx.model.NamespaceIds) AccountNames(io.nem.symbol.sdk.model.account.AccountNames) NamespaceRegistrationType(io.nem.symbol.sdk.model.namespace.NamespaceRegistrationType) Consumer(java.util.function.Consumer) NamespaceInfoDTO(io.nem.symbol.sdk.openapi.vertx.model.NamespaceInfoDTO) List(java.util.List) AccountNamesDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountNamesDTO) AliasType(io.nem.symbol.sdk.model.namespace.AliasType) AccountsNamesDTO(io.nem.symbol.sdk.openapi.vertx.model.AccountsNamesDTO) Optional(java.util.Optional) Address(io.nem.symbol.sdk.model.account.Address) Handler(io.vertx.core.Handler) Page(io.nem.symbol.sdk.api.Page) AddressAlias(io.nem.symbol.sdk.model.namespace.AddressAlias) Handler(io.vertx.core.Handler) ArrayList(java.util.ArrayList) List(java.util.List) NamespaceIds(io.nem.symbol.sdk.openapi.vertx.model.NamespaceIds) MapperUtils.toNamespaceId(io.nem.symbol.core.utils.MapperUtils.toNamespaceId) NamespaceId(io.nem.symbol.sdk.model.namespace.NamespaceId)

Aggregations

AsyncResult (io.vertx.core.AsyncResult)162 Handler (io.vertx.core.Handler)106 Test (org.junit.Test)72 JsonObject (io.vertx.core.json.JsonObject)68 CountDownLatch (java.util.concurrent.CountDownLatch)62 Future (io.vertx.core.Future)59 List (java.util.List)49 RequestParameter (io.vertx.ext.web.api.RequestParameter)48 RequestParameters (io.vertx.ext.web.api.RequestParameters)48 HashMap (java.util.HashMap)45 Map (java.util.Map)42 IOException (java.io.IOException)41 ArrayList (java.util.ArrayList)40 Vertx (io.vertx.core.Vertx)35 Collectors (java.util.stream.Collectors)35 RoutingContext (io.vertx.ext.web.RoutingContext)28 Buffer (io.vertx.core.buffer.Buffer)24 StandardCharsets (java.nio.charset.StandardCharsets)23 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)23 Consumer (java.util.function.Consumer)23