snowplow / snowplow-scala-tracker

Snowplow event tracker for Scala. Add analytics to your Scala, Akka and Play apps and servers
http://snowplowanalytics.com
8 stars 14 forks source link

Add a action ADT to signal different messages to the emitter #147

Closed istreeter closed 3 years ago

istreeter commented 4 years ago

The AsyncEmitter needs to signal to its worker thread when it is time to flush all events and gracefully shutdown. Currently this is done via awkward thread-safe boolean flags (AtomicBooleans). A neater pattern is to use a ADT, so the queue of events signals various actions the worker thread should perform:

This is a more robust method of implementing cross-thread communication, and it is more extensible to other emitters (see the forthcoming http4s emitter)