How to use rsocket-flowable - 10 common examples

To help you get started, we’ve selected a few rsocket-flowable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / ipc / src / IPCRSocketService.js View on Github external
requestResponse(
    payload: Payload,
  ): Single> {
    const method: string = this._getMethod(payload);
    const spanContext = deserializeTraceData(this._tracer, payload.metadata);
    return this._getMetricsWrapper(false, method)(
      this._getTracingWrapper(false, method)(spanContext)(
        new Single(subscriber => {
          const {data, metadata} = this._marshaller.unmarshall(payload);
          return (
            this._handler[method](data, metadata)
              .map(this._marshaller.marshall)
              // $FlowFixMe
              .subscribe(subscriber)
          );
        }),
      ),
    );
  }
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / core / src / RpcClient.js View on Github external
constructor(config: ClientConfig, connection: DuplexConnection) {
    this._machine = createClientMachine(
      connection,
      subscriber => connection.receive().subscribe(subscriber),
      config.serializers,
      config.responder,
    );

    // Send SETUP
    connection.sendOne(this._buildSetupFrame(config));

    // Send KEEPALIVE frames
    const {keepAlive} = config.setup;
    const keepAliveFrames = every(keepAlive).map(() => ({
      data: null,
      flags: FLAGS.RESPOND,
      lastReceivedPosition: 0,
      streamId: CONNECTION_STREAM_ID,
      type: FRAME_TYPES.KEEPALIVE,
    }));
    connection.send(keepAliveFrames);
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketClient.js View on Github external
this._machine = createClientMachine(
      connection,
      subscriber => connection.receive().subscribe(subscriber),
      lifetime,
      config.serializers,
      config.responder,
      config.errorHandler,
      requesterLeaseHandler,
      responderLeaseHandler,
    );

    // Send SETUP
    connection.sendOne(this._buildSetupFrame(config));

    // Send KEEPALIVE frames
    const keepAliveFrames = every(keepAlive).map(() => ({
      data: null,
      flags: FLAGS.RESPOND,
      lastReceivedPosition: 0,
      streamId: CONNECTION_STREAM_ID,
      type: FRAME_TYPES.KEEPALIVE,
    }));
    connection.send(keepAliveFrames);
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
metadataPush(payload: Payload): Single {
    let error: ?Error;
    if (this._responder.metadataPush) {
      try {
        return this._responder.metadataPush(payload);
      } catch (_error) {
        console.error('metadataPush threw an exception', _error);
        error = _error;
      }
    }
    return Single.error(error || new Error('not implemented'));
  }
}
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
requestResponse(payload: Payload): Single> {
    let error: ?Error;
    if (this._responder.requestResponse) {
      try {
        return this._responder.requestResponse(payload);
      } catch (_error) {
        console.error('requestResponse threw an exception', _error);
        error = _error;
      }
    }
    return Single.error(error || new Error('not implemented'));
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
requestChannel(payloads: Flowable>): Flowable> {
    let error: ?Error;
    if (this._responder.requestChannel) {
      try {
        return this._responder.requestChannel(payloads);
      } catch (_error) {
        console.error('requestChannel threw an exception', _error);
        error = _error;
      }
    }
    return Flowable.error(error || new Error('not implemented'));
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
requestStream(payload: Payload): Flowable> {
    let error: ?Error;
    if (this._responder.requestStream) {
      try {
        return this._responder.requestStream(payload);
      } catch (_error) {
        console.error('requestStream threw an exception', _error);
        error = _error;
      }
    }
    return Flowable.error(error || new Error('not implemented'));
  }
github rsocket / rsocket-js / packages / rsocket-examples / src / SimpleCli.js View on Github external
function doOperation(
  socket: ReactiveSocket,
  operation: string,
  payload: string,
): Flowable> {
  switch (operation) {
    case 'none':
      return Flowable.never();
    case 'stream':
    default:
      console.log(`Requesting stream with payload: ${payload}`);
      return socket.requestStream({
        data: payload,
        metadata: '',
      });
  }
}
github netifi / spring-demo / browser-ranking / src / main / js / index.js View on Github external
rank: function(rankingRequest, metadata){
            rankingRequest.getRecordsList().forEach(record => {
                console.log(record.getId() + "  " + record.getData().getSupername());
            });
            console.log("....");
            let resp = new RankingResponse();
            resp.setId(rankingRequest.getRecordsList()[0].getId());
            return Single.of(resp);
        }
    };
github rsocket / rsocket-js / packages / rsocket-websocket-server / src / RSocketWebSocketServer.js View on Github external
connectionStatus(): Flowable {
    return new Flowable(subscriber => {
      subscriber.onSubscribe({
        cancel: () => {
          this._statusSubscribers.delete(subscriber);
        },
        request: () => {
          this._statusSubscribers.add(subscriber);
          subscriber.onNext(this._status);
        },
      });
    });
  }