Skip to content

Commit

Permalink
test subs warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubwro committed Oct 6, 2023
1 parent 670c0c9 commit eeb6473
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/pubsub/subscribe.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,7 @@ function _start_tasks(f::Function, async_handlers::Bool, subject::String, channe
async_handlers || wait(handler_task)
end
catch err
if err isa InvalidStateException
# This is fine, subscription is unsubscribed.
@debug "Task for subscription on $subject finished."
else
@error "Unexpected subscription error." err
end
err isa InvalidStateException || rethrow()
end
end)
else
Expand All @@ -85,12 +80,7 @@ function _start_tasks(f::Function, async_handlers::Bool, subject::String, channe
Threads.atomic_sub!(handlers_running, 1)
end
catch err
if err isa InvalidStateException
# This is fine, subscription is unsubscribed.
@debug "Task for subscription on $subject finished."
else
@error "Unexpected subscription error." err
end
err isa InvalidStateException || rethrow()
end
end)
end
Expand Down
23 changes: 23 additions & 0 deletions test/connection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,4 +138,27 @@ end
nonce = "HiA_hND1AV-DjmM"
sig = "g4HDazX_ZZig_FOFBzhorLSYCEDRlv20Y5vErFjDlTRZMqaaF27ImP16es_GI83Fn59xr9V98Ux5GlEvvaeADQ"
@test NATS.sign(nonce, seed) == sig
end


@testset "Subscription warnings" begin
nc = NATS.connect()

subscribe("too_many_handlers", async_handlers = true) do msg
sleep(21)
end

for _ in 1:1001
publish("too_many_handlers")
end

subscribe("overload_channel", async_handlers = false, channel_size = 100) do msg
sleep(21)
end

for _ in 1:81
publish("too_many_handlers")
end

sleep(21)
end

0 comments on commit eeb6473

Please sign in to comment.