You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tailscale/util/eventbus
M. J. Fromberger 0a33aae823
util/eventbus: run subscriber functions in a goroutine (#17510)
With a channel subscriber, the subscription processing always occurs on another
goroutine. The SubscriberFunc (prior to this commit) runs its callbacks on the
client's own goroutine. This changes the semantics, though: In addition to more
directly pushing back on the publisher, a publisher and subscriber can deadlock
in a SubscriberFunc but succeed on a Subscriber. They should behave
equivalently regardless which interface they use.

Arguably the caller should deal with this by creating its own goroutine if it
needs to. However, that loses much of the benefit of the SubscriberFunc API, as
it will need to manage the lifecycle of that goroutine. So, for practical
ergonomics, let's make the SubscriberFunc do this management on the user's
behalf. (We discussed doing this in #17432, but decided not to do it yet).  We
can optimize this approach further, if we need to, without changing the API.

Updates #17487

Change-Id: I19ea9e8f246f7b406711f5a16518ef7ff21a1ac9
Signed-off-by: M. J. Fromberger <fromberger@tailscale.com>
2 months ago
..
assets util/eventbus: add a debug HTTP handler for the bus 9 months ago
debug-demo cmd/tailscaled, ipn/localapi, util/eventbus: don't link in regexp when debug is omitted 2 months ago
eventbustest health: remove direct callback and replace with eventbus (#17199) 3 months ago
bench_test.go util/eventbus: add basic throughput benchmarks (#15284) 9 months ago
bus.go util/eventbus: flesh out docs a bit 2 months ago
bus_test.go util/eventbus: add a function-based subscriber type (#17432) 2 months ago
client.go util/eventbus: add a function-based subscriber type (#17432) 2 months ago
debug.go cmd/tailscaled, ipn/localapi, util/eventbus: don't link in regexp when debug is omitted 2 months ago
debughttp.go cmd/tailscaled, ipn/localapi, util/eventbus: don't link in regexp when debug is omitted 2 months ago
debughttp_off.go cmd/tailscaled, ipn/localapi, util/eventbus: don't link in regexp when debug is omitted 2 months ago
doc.go util/eventbus: add test helpers to simplify testing events (#16294) 5 months ago
fetch-htmx.go util/eventbus: add a debug HTTP handler for the bus 9 months ago
monitor.go util/eventbus: add a Done method to the Monitor type (#17263) 2 months ago
publish.go util/eventbus: flesh out docs a bit 2 months ago
queue.go util/eventbus: make internal queue a generic type 9 months ago
subscribe.go util/eventbus: run subscriber functions in a goroutine (#17510) 2 months ago