From 9023d4c5325f944a4a3bef390f6d196096cbeee1 Mon Sep 17 00:00:00 2001 From: Jesse Kelly Date: Fri, 7 Jun 2024 23:23:07 +0200 Subject: [PATCH] removed unnecessary Effect.fail call --- packages/cluster-node/src/PodsRpc.ts | 8 ++++---- packages/cluster/src/internal/entityManager.ts | 2 +- packages/cluster/src/internal/shardManager.ts | 2 +- packages/cluster/src/internal/sharding.ts | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/cluster-node/src/PodsRpc.ts b/packages/cluster-node/src/PodsRpc.ts index bc4ee0e..416f261 100644 --- a/packages/cluster-node/src/PodsRpc.ts +++ b/packages/cluster-node/src/PodsRpc.ts @@ -39,7 +39,7 @@ export function podsRpc( Effect.catchAllDefect((e) => pipe( Effect.logError(e), - Effect.zipRight(Effect.fail(new ShardingException.PodUnavailableException({ podAddress }))) + Effect.zipRight(new ShardingException.PodUnavailableException({ podAddress })) ) ) ) @@ -51,7 +51,7 @@ export function podsRpc( Effect.catchAllDefect((e) => pipe( Effect.logError(e), - Effect.zipRight(Effect.fail(new ShardingException.PodUnavailableException({ podAddress }))) + Effect.zipRight(new ShardingException.PodUnavailableException({ podAddress })) ) ) ) @@ -64,7 +64,7 @@ export function podsRpc( pipe( Effect.logError(e), Effect.zipRight( - Effect.fail(new ShardingException.PodUnavailableException({ podAddress })) + new ShardingException.PodUnavailableException({ podAddress }) ) ) ) @@ -77,7 +77,7 @@ export function podsRpc( Effect.catchAllDefect((e) => pipe( Effect.logError(e), - Effect.zipRight(Effect.fail(new ShardingException.PodUnavailableException({ podAddress }))) + Effect.zipRight(new ShardingException.PodUnavailableException({ podAddress })) ) ) ) diff --git a/packages/cluster/src/internal/entityManager.ts b/packages/cluster/src/internal/entityManager.ts index 9cde103..f8cca06 100644 --- a/packages/cluster/src/internal/entityManager.ts +++ b/packages/cluster/src/internal/entityManager.ts @@ -222,7 +222,7 @@ export function make( Effect.flatMap(sharding.isShuttingDown, (isGoingDown) => { if (isGoingDown) { // don't start any fiber while sharding is shutting down - return Effect.fail(new ShardingException.EntityNotManagedByThisPodException({ recipientAddress })) + return new ShardingException.EntityNotManagedByThisPodException({ recipientAddress }) } else { // offer doesn't exist, create a new one return Effect.gen(function*(_) { diff --git a/packages/cluster/src/internal/shardManager.ts b/packages/cluster/src/internal/shardManager.ts index 9b303a1..cd649cb 100644 --- a/packages/cluster/src/internal/shardManager.ts +++ b/packages/cluster/src/internal/shardManager.ts @@ -182,7 +182,7 @@ function make( ) { return RefSynchronized.updateEffect(stateRef, (state) => { if (Option.isSome(pod) && !HashMap.has(state.pods, pod.value)) { - return Effect.fail(new ShardingException.PodNoLongerRegisteredException({ podAddress: pod.value })) + return new ShardingException.PodNoLongerRegisteredException({ podAddress: pod.value }) } return Effect.succeed({ ...state, diff --git a/packages/cluster/src/internal/sharding.ts b/packages/cluster/src/internal/sharding.ts index 2ef5ea6..e671409 100644 --- a/packages/cluster/src/internal/sharding.ts +++ b/packages/cluster/src/internal/sharding.ts @@ -189,7 +189,7 @@ function make( Effect.flatMap((_) => Unify.unify(Option.match(_, { onNone: () => - Effect.fail(new ShardingException.EntityTypeNotRegisteredException({ entityType, podAddress: address })), + new ShardingException.EntityTypeNotRegisteredException({ entityType, podAddress: address }), onSome: (entityManager) => Effect.succeed(entityManager as EntityManager.EntityManager) })) ) @@ -508,7 +508,7 @@ function make( Unify.unify(pipe( state, MessageState.match({ - onAcknowledged: () => Effect.fail(new ShardingException.NoResultInProcessedMessageStateException()), + onAcknowledged: () => new ShardingException.NoResultInProcessedMessageStateException(), onProcessed: (state) => Effect.succeed(state.result) }) )) @@ -539,7 +539,7 @@ function make( Effect.flatMap((pod) => Option.isSome(pod) ? Effect.succeed(pod.value) - : Effect.fail(new ShardingException.EntityNotManagedByThisPodException({ recipientAddress })) + : new ShardingException.EntityNotManagedByThisPodException({ recipientAddress }) ), Effect.flatMap((pod) => sendMessageToPodWithoutRetries( @@ -638,7 +638,7 @@ function make( state, MessageState.match({ onAcknowledged: () => - Effect.fail(new ShardingException.NoResultInProcessedMessageStateException()), + new ShardingException.NoResultInProcessedMessageStateException(), onProcessed: (state) => Effect.succeed(state.result) }) ))