How to use the rsocket-flowable.Single function in rsocket-flowable

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 / ipc / src / IPCRSocketService.js View on Github external
fireAndForget(payload: Payload): void {
    const method: string = this._getMethod(payload);
    const spanContext = deserializeTraceData(this._tracer, payload.metadata);
    this._getMetricsWrapper(false, method)(
      new Single(subscriber => {
        this._getTracingWrapper(false, method)(spanContext)(
          new Single(innerSub => {
            const {data, metadata} = this._marshaller.unmarshall(payload);
            this._handler[method](data, metadata);
            innerSub.onSubscribe();
            innerSub.onComplete();
          }).subscribe({
            onSubscribe: () => {
              subscriber.onSubscribe();
            },
            onComplete: () => {
              subscriber.onComplete();
            },
          }),
        );
      }).subscribe(),
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / ipc / src / IPCRSocketClient.js View on Github external
fireAndForget(method: string, payload: Payload): void {
    const tracingMap = {};
    this._getMetricsWrapper(false, method)(
      new Single(subscriber => {
        this._getTracingWrapper(false, method)(tracingMap)(
          new Single(innerSub => {
            const {data} = this._marshaller.marshall(payload);
            const tracingMetadata = mapToBuffer(tracingMap);
            const metadata = encodeMetadata(
              this._service,
              method,
              tracingMetadata,
              payload.metadata || Buffer.alloc(0),
            );
            this._socket.fireAndForget({data, metadata});
            innerSub.onSubscribe();
            innerSub.onComplete();
          }),
        ).subscribe({
          onSubscribe: () => {
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / ipc / src / IPCRSocketService.js View on Github external
new Single(subscriber => {
        this._getTracingWrapper(false, method)(spanContext)(
          new Single(innerSub => {
            const {data, metadata} = this._marshaller.unmarshall(payload);
            this._handler[method](data, metadata);
            innerSub.onSubscribe();
            innerSub.onComplete();
          }).subscribe({
            onSubscribe: () => {
              subscriber.onSubscribe();
            },
            onComplete: () => {
              subscriber.onComplete();
            },
          }),
        );
      }).subscribe(),
    );
github scalecube / scalecube-js / packages / rsocket-ws-gateway / src / requestResponse.ts View on Github external
export const requestResponse = ({ data }, serviceCall, handler = singleHandler) => {
  return new Single(handler.bind(null, serviceCall, data));
};
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / core / src / RpcClient.js View on Github external
connect(): Single> {
    invariant(
      !this._connection,
      'RpcClient: Unexpected call to connect(), already connected.',
    );
    this._connection = new Single(subscriber => {
      const transport = this._config.transport;
      let subscription;
      transport.connectionStatus().subscribe({
        onNext: status => {
          if (status.kind === 'CONNECTED') {
            subscription && subscription.cancel();
            subscriber.onComplete(new RpcSocket(this._config, transport));
          } else if (status.kind === 'ERROR') {
            subscription && subscription.cancel();
            subscriber.onError(status.error);
          } else if (status.kind === 'CLOSED') {
            subscription && subscription.cancel();
            subscriber.onError(new Error('RpcClient: Connection closed.'));
          }
        },
        onSubscribe: _subscription => {
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / metrics / src / MetricsSingleSubscriber.js View on Github external
export default function embedMetricsSingleSubscriber(
  single: Single,
  next: Counter,
  complete: Counter,
  error: Counter,
  cancelled: Counter,
  timer: Timer,
): Single {
  return new Single(subscriber => {
    const metricsSubscriber = new MetricsSingleSubscriber(
      subscriber,
      next,
      complete,
      error,
      cancelled,
      timer,
    );
    single.subscribe(metricsSubscriber);
  });
}
github rsocket / rsocket-rpc-js / rsocket-rpc-js / packages / ipc / src / IPCRSocketClient.js View on Github external
requestResponse(
    method: string,
    payload: Payload,
  ): Single> {
    const tracingMap = {};
    return this._getMetricsWrapper(false, method)(
      this._getTracingWrapper(false, method)(tracingMap)(
        new Single(subscriber => {
          const {data} = this._marshaller.marshall(payload);
          const tracingMetadata = mapToBuffer(tracingMap);
          const metadata = encodeMetadata(
            this._service,
            method,
            tracingMetadata,
            payload.metadata || Buffer.alloc(0),
          );
          this._socket
            .requestResponse({data, metadata})
            .map(this._marshaller.unmarshall)
            .subscribe(subscriber);
        }),
      ),
    );
  }
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketMachine.js View on Github external
requestResponse(payload: Payload): Single> {
    const leaseError = this._useLeaseOrError(this._requesterLeaseHandler);
    if (leaseError) {
      return Single.error(new Error(leaseError));
    }

    const streamId = this._getNextStreamId(this._receivers);
    return new Single(subscriber => {
      this._receivers.set(streamId, {
        onComplete: emptyFunction,
        onError: error => subscriber.onError(error),
        onNext: data => subscriber.onComplete(data),
      });
      const data = this._serializers.data.serialize(payload.data);
      const metadata = this._serializers.metadata.serialize(payload.metadata);
      const frame = {
        data,
        flags: payload.metadata !== undefined ? FLAGS.METADATA : 0,
        metadata,
        streamId,
        type: FRAME_TYPES.REQUEST_RESPONSE,
      };
      this._connection.sendOne(frame);
github rsocket / rsocket-js / packages / rsocket-core / src / RSocketClient.js View on Github external
connect(): Single> {
    invariant(
      !this._connection,
      'RSocketClient: Unexpected call to connect(), already connected.',
    );
    this._connection = new Single(subscriber => {
      const transport = this._config.transport;
      let subscription;
      transport.connectionStatus().subscribe({
        onNext: status => {
          if (status.kind === 'CONNECTED') {
            subscription && subscription.cancel();
            subscriber.onComplete(
              new RSocketClientSocket(this._config, transport),
            );
          } else if (status.kind === 'ERROR') {
            subscription && subscription.cancel();
            subscriber.onError(status.error);
          } else if (status.kind === 'CLOSED') {
            subscription && subscription.cancel();
            subscriber.onError(new Error('RSocketClient: Connection closed.'));
          }