keenlabs / KeenClient-Java

Official Java client for the Keen IO API. Build analytics features directly into your Java apps.
https://keen.io/docs
MIT License
74 stars 43 forks source link

KeenClient graceful shutdown #62

Closed xaviarias closed 9 years ago

xaviarias commented 9 years ago

The class KeenClient allows to add events asynchronously with the addEventAsync methods. However, there is no way to know if the KeenClient is still processing tasks.

Could you add a method that awaits for task finalization, or a method to know if the task queue is empty?

Geeber commented 9 years ago

This is technically possible today, by calling getPublishExecutor on the client and then casting it to an ExecutorService. You can see an example of this here: https://github.com/keenlabs/KeenClient-Java-Sample/blob/master/src/main/java/io/keen/sample/java/Main.java#L151

It's unfortunately slightly brittle as we don't technically guarantee that the publish executor will be an ExecutorService in future versions of the SDK, but it should be pretty reliable for now. Does that satisfy your use case?

xaviarias commented 9 years ago

Sorry I had not seen this method ! This is exactly what I was looking for, thanks.