Skip to content

Commit

Permalink
Fix bad value from publish listener
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjos committed Jun 20, 2024
1 parent ee5bcea commit 402712a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
16 changes: 6 additions & 10 deletions lib/absinthe/subscription.ex
Original file line number Diff line number Diff line change
Expand Up @@ -214,16 +214,12 @@ defmodule Absinthe.Subscription do

@doc false
def publish_remote(pubsub, mutation_result, subscribed_fields) do
{:ok, pool_size} =
pubsub
|> registry_name
|> Registry.meta(:pool_size)

shard = :erlang.phash2(mutation_result, pool_size)

proxy_topic = Subscription.Proxy.topic(shard)

:ok = pubsub.publish_mutation(proxy_topic, mutation_result, subscribed_fields)
:ok =
pubsub.publish_mutation(
"__absinthe__:subscription:mutation_published",
mutation_result,
subscribed_fields
)
end

## Middleware callback
Expand Down
4 changes: 2 additions & 2 deletions lib/absinthe/subscription/mutation_publish_listener.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ defmodule Absinthe.Subscription.MutationPublishListener do
|> Map.put(:queue, :queue.new())
|> Map.put(:pending_demand, pending_demand)

{:no_reply, events_to_send, state}
{:noreply, events_to_send, state}
else
# if we do have enough to satisfy demand, then send what's asked for
{events_to_send_queue, remaining_events_queue} = :queue.split(demand, state.queue)
Expand All @@ -83,7 +83,7 @@ defmodule Absinthe.Subscription.MutationPublishListener do
|> Map.put(:queue, remaining_events_queue)
|> Map.put(:pending_demand, pending_demand)

{:no_reply, events_to_send, state}
{:noreply, events_to_send, state}
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/absinthe/subscription/mutation_publish_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule Absinthe.Subscription.MutationPublishSupervisor do

def init({pubsub, max_demand, max_queue_length}) do
unique_producer_name =
:"#{Absinthe.Subscription.LocalProducer}.#{:erlang.unique_integer([:monotonic])}"
:"#{Absinthe.Subscription.MutationPublishListener}.#{:erlang.unique_integer([:monotonic])}"

children = [
{Absinthe.Subscription.MutationPublishListener,
Expand Down

0 comments on commit 402712a

Please sign in to comment.