Search in sources :

Example 56 with IPromise

use of org.nustaq.kontraktor.IPromise in project kontraktor by RuedigerMoeller.

the class JNPM method getDistributions.

// map of tag => version
protected IPromise<JsonObject> getDistributions(String module) {
    Promise res = new Promise();
    // http://registry.npmjs.org/-/package/react/dist-tags
    http.getContent(config.getRepo() + "/-/package/" + module + "/dist-tags").then((cont, err) -> {
        if (cont != null) {
            JsonObject parse = Json.parse(cont).asObject();
            res.resolve(parse);
        } else {
            res.reject(err);
        }
    });
    return res;
}
Also used : Promise(org.nustaq.kontraktor.Promise) IPromise(org.nustaq.kontraktor.IPromise) JsonObject(com.eclipsesource.json.JsonObject)

Example 57 with IPromise

use of org.nustaq.kontraktor.IPromise in project kontraktor by RuedigerMoeller.

the class RemotingTest method fromRemote.

private void fromRemote(ConnectableActor con) {
    RemotingTA remote = (RemotingTA) con.connect().await();
    IPromise fin = new Promise();
    AtomicInteger count = new AtomicInteger();
    Integer expect = remote.sayHello(10, (str, err) -> {
        if (Actors.isCont(err)) {
            System.out.println("received:" + str);
            count.incrementAndGet();
        } else {
            fin.complete();
        }
    }).await();
    fin.await();
    Assert.assertTrue(expect.intValue() == count.intValue());
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) TCPConnectable(org.nustaq.kontraktor.remoting.tcp.TCPConnectable) SerializerType(org.nustaq.kontraktor.remoting.encoding.SerializerType) TCPPublisher(org.nustaq.kontraktor.remoting.tcp.TCPPublisher) Test(org.junit.Test) Promise(org.nustaq.kontraktor.Promise) WebSocketPublisher(org.nustaq.kontraktor.remoting.http.undertow.WebSocketPublisher) IPromise(org.nustaq.kontraktor.IPromise) HttpPublisher(org.nustaq.kontraktor.remoting.http.undertow.HttpPublisher) ConnectableActor(org.nustaq.kontraktor.remoting.base.ConnectableActor) Http4K(org.nustaq.kontraktor.remoting.http.undertow.Http4K) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Actors(org.nustaq.kontraktor.Actors) HttpConnectable(org.nustaq.kontraktor.remoting.http.HttpConnectable) TCPNIOPublisher(org.nustaq.kontraktor.remoting.tcp.TCPNIOPublisher) WebSocketConnectable(org.nustaq.kontraktor.remoting.websockets.WebSocketConnectable) Assert(org.junit.Assert) Promise(org.nustaq.kontraktor.Promise) IPromise(org.nustaq.kontraktor.IPromise) IPromise(org.nustaq.kontraktor.IPromise) AtomicInteger(java.util.concurrent.atomic.AtomicInteger)

Example 58 with IPromise

use of org.nustaq.kontraktor.IPromise in project kontraktor by RuedigerMoeller.

the class _JSR356ServerConnector method Publish.

public static IPromise<ActorServer> Publish(Actor facade, String path, Coding coding) {
    _JSR356ServerConnector connector = new _JSR356ServerConnector();
    try {
        ActorServer actorServer = new ActorServer(connector, facade, coding);
        actorServer.start();
        ContainerProvider.getWebSocketContainer().connectToServer(connector, /*new DefaultClientEndpointConfig(),*/
        new URI(path));
        return new Promise<>(actorServer);
    } catch (Exception e) {
        e.printStackTrace();
        return new Promise<>(null, e);
    }
}
Also used : Promise(org.nustaq.kontraktor.Promise) IPromise(org.nustaq.kontraktor.IPromise) ActorServer(org.nustaq.kontraktor.remoting.base.ActorServer) URI(java.net.URI) IOException(java.io.IOException)

Aggregations

IPromise (org.nustaq.kontraktor.IPromise)58 Promise (org.nustaq.kontraktor.Promise)56 Remoted (org.nustaq.kontraktor.annotations.Remoted)6 Actor (org.nustaq.kontraktor.Actor)5 JsonObject (com.eclipsesource.json.JsonObject)4 IOException (java.io.IOException)4 Test (org.junit.Test)4 ByteBuffer (java.nio.ByteBuffer)3 KeyManagementException (java.security.KeyManagementException)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 CertificateException (java.security.cert.CertificateException)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 Consumer (java.util.function.Consumer)3 TableSpaceActor (org.nustaq.reallive.impl.tablespace.TableSpaceActor)3 JsonValue (com.eclipsesource.json.JsonValue)2 ArrayList (java.util.ArrayList)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 ArchiveException (org.apache.commons.compress.archivers.ArchiveException)2 HttpPost (org.apache.http.client.methods.HttpPost)2 StringEntity (org.apache.http.entity.StringEntity)2