Conversation
| @@ -110,9 +110,9 @@ inline fun <reified T : Any> keyOf(a: KClass<out Annotation>?): Key<T> = keyOf(a | |||
| */ | |||
| inline fun <reified T : Any> keyOf(qualifier: BindingQualifier? = null): Key<T> = | |||
There was a problem hiding this comment.
I realized while using keyOf in my tests that this didn't support parameterized types properly, which IMO seems like a bit of a footgun.
6ed4b99 to
c9c8ee6
Compare
`ActionScopeListener` allows developers to hook in to the `close()` method of `ActionScope`, and perform actions immediately before the scope is closed. For example, you could buffer logs while the scope is open, and then dedupe and flush them before it's closed. Currently `ActionScopeListener` only supports `onClose()`, but in the future could support `onEnter()` as well.
c9c8ee6 to
a77496e
Compare
| override fun close() { | ||
| threadLocalInstance.remove() | ||
| try { | ||
| listeners.get().forEach { it.onClose() } |
There was a problem hiding this comment.
Is there a concern if any of these throw? Should each be wrapped in a try..catch and log errors?
There was a problem hiding this comment.
I considered that, but didn't want to indiscriminately catch exceptions if the developer actually wants their exception to propagate. I did keep the finally though so that we don't forget to clean up the ThreadLocal.
| * For example: an action-scoped HTTP Request Body may still be transmitting to the client despite the scope being | ||
| * closed. | ||
| */ | ||
| fun onClose() |
There was a problem hiding this comment.
Should the scope being closed be passed into the listener?
There was a problem hiding this comment.
Generally you're not using the ActionScope directly, you're dealing with ActionScoped<T>. If they need it, they can just inject ActionScope in to their listener, but I don't expect many to usages to need it.
ActionScopeListenerallows developers to hook in to theclose()method ofActionScope, and perform actions immediately before the scope is closed. For example, you could buffer logs while the scope is open, and then dedupe and flush them before it's closed. CurrentlyActionScopeListeneronly supportsonClose(), but in the future could supportonEnter()as well.