Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'));
}
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'));
}
): Flowable> {
try {
if (payload.metadata == null) {
return Flowable.error(new Error('metadata is empty'));
}
const service = getService(payload.metadata);
const handler = this._registeredServices.get(service);
if (handler == null) {
return Flowable.error(new Error('can not find service ' + service));
}
return handler.requestStream(payload);
} catch (error) {
return Flowable.error(error);
}
}
requestChannel(
payloads: Flowable>,
): Flowable> {
return Flowable.error(new Error());
}
requestStream(
payload: Payload,
): Flowable> {
try {
if (payload.metadata == null) {
return Flowable.error(new Error('metadata is empty'));
}
const service = getService(payload.metadata);
const handler = this._registeredServices.get(service);
if (handler == null) {
return Flowable.error(new Error('can not find service ' + service));
}
return handler.requestStream(payload);
} catch (error) {
return Flowable.error(error);
}
}
new SwitchTransformOperator(s, (payload, flowable) => {
if (payload.metadata === undefined || payload.metadata === null) {
return Flowable.error(new Error('metadata is empty'));
} else {
const service = getService(payload.metadata);
const handler = this._registeredServices.get(service);
if (handler === undefined || handler === null) {
return Flowable.error(
new Error('can not find service ' + service),
);
} else {
return handler.requestChannel(flowable);
}
}
}),
);
requestStream(payload: Payload): Flowable> {
const leaseError = this._useLeaseOrError(this._requesterLeaseHandler);
if (leaseError) {
return Flowable.error(new Error(leaseError));
}
const streamId = this._getNextStreamId(this._receivers);
return new Flowable(
subscriber => {
this._receivers.set(streamId, subscriber);
let initialized = false;
subscriber.onSubscribe({
cancel: () => {
this._receivers.delete(streamId);
if (!initialized) {
return;
}
const cancelFrame = {
requestChannel(
payloads: Flowable>,
): Flowable> {
return Flowable.error(new Error());
}
requestChannel(payloads: Flowable>): Flowable> {
const leaseError = this._useLeaseOrError(this._requesterLeaseHandler);
if (leaseError) {
return Flowable.error(new Error(leaseError));
}
const streamId = this._getNextStreamId(this._receivers);
let payloadsSubscribed = false;
return new Flowable(
subscriber => {
try {
this._receivers.set(streamId, subscriber);
let initialized = false;
subscriber.onSubscribe({
cancel: () => {
this._receivers.delete(streamId);
if (!initialized) {
return;