-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add onFailure to EnrichedMergeableStore #200
Conversation
@@ -49,4 +49,17 @@ class EnrichedMergeableStore[K, V](store: MergeableStore[K, V]) { | |||
|
|||
def convert[K1, V1](fn: K1 => K)(implicit bij: ImplicitBijection[V1, V]): MergeableStore[K1, V1] = | |||
MergeableStore.convert(store)(fn) | |||
|
|||
def onFailure(rescueException: Throwable => Unit): MergeableStore[K, V] = new MergeableStore[K, V] { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we rename "onMergeFailure"+
Can you change this (should be less code) to use the proxy pattern in #202 ? |
for instance, close was not plumbed through here. |
yea. that's the reason it's useful. All delegation is handled for you so you don't forget things. Like closing a network connection cleanly! you could probably do def onMergeFailure(rescueException: Throwable => Unit): MergeableStore[K, V] =
new MergeableStoreProxy(store) {
override def merge(kv: (K, V)) = self.merge(kv).onFailure(rescueException)
override def multiMerge[K1 <: K](kvs: Map[K1, V]) =
self.multiMerge(kvs).mapValues { _.onFailure(rescueException) }
} shorter and safer |
@singhala ? Any update? Can we talk you into using the pattern above? |
ping |
Sorry I lost track of this while on vacation. Yes, I'll update this diff with the new pattern later today. |
add onFailure to EnrichedMergeableStore
override def self = store | ||
override def merge(kv: (K, V)) = store.merge(kv).onFailure(rescueException) | ||
override def multiMerge[K1 <: K](kvs: Map[K1, V]) = | ||
store.multiMerge(kvs).mapValues { _.onFailure(rescueException) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapValues is lazy. This is not being applied if any keys are not accessed.
No description provided.