Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-12812

Consider refactoring state store registration path

    XMLWordPrintableJSON

Details

    Description

      Today our state store registration call path within the stateManager (both local and global) is like this:

      for each store: store.init(store, context)
         -> context.register(root, callback)
         -> stateManager.registerStore(store, callback)
      

      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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            guozhang Guozhang Wang
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: