[ https://issues.apache.org/jira/browse/KAFKA-12812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17347051#comment-17347051 ]
Guozhang Wang commented on KAFKA-12812: --------------------------------------- The reason I feel this is better is that, it could be less error prone as we do not have a call loop anymore, whereas in the past we have hit several bugs around this call trace. LMK WDYT [~cadonna] [~ableegoldman] > Consider refactoring state store registration path > -------------------------------------------------- > > Key: KAFKA-12812 > URL: https://issues.apache.org/jira/browse/KAFKA-12812 > Project: Kafka > Issue Type: Bug > Components: streams > Reporter: Guozhang Wang > Priority: Major > > Today our state store registration call path within the stateManager (both > local and global) is like this: > {code} > for each store: store.init(store, context) > -> context.register(root, callback) > -> stateManager.registerStore(store, callback) > {code} > One can see that, we have an awkward loop from stateManager back to > stateManager, and we require users to not forget calling > context.register(root, callback). We do this only in order to let users pass > the customized callback implementation to the stateManager. > What about a different path like this: > 1) We add a new interface in StateStore, like `StateRestoreCallback > getCallback()` that each impl class need to provide. > 2) We remove the `context.register(root, callback)` call; and because of > that, we do not need to pass in `root` in the store.init as well. > 3) stateManager just call `store.init(context)` (without the first > parameter), and then put the store along with its restore callback into the > map, without the separate `registerStore` function. -- This message was sent by Atlassian Jira (v8.3.4#803005)