Enable state persistence through simple file store
Proposal
Current implementation of State Extension works very well. However, there will be times when there's a need to persist state through restarts (For example, when upgrading WireMock version).
To tackle this, it would be great to save Caffeine's state separately to a file while running and reading them back after waking up.
References
https://stackoverflow.com/questions/71566146/cache-data-to-local-hdd-with-caffeine#comment126486444_71566146
Ahh, it seems that Store itself is configurable and just need to be reimplemented.
Wondering how should I configure it so that even when its standalone, the store used can still be configured to other than Caffeine
Currently, Wiremock does not provide a way to pass configuration options to extensions. While stores are configurable, I’m not aware of a way provide them in an extension-like mechanism. And I don’t think making persistence a default would be ok. one way I can think of to make it work with standalone is to provide an admin interface, so: you can turn options off/on and thus trigger loading of a state or a continuous persistence thereof. Not sure whether this would be an option for your use case.
Hi Dirk,
thanks for responding. That's a good suggestion that I might just look into! Agree on making persistence as a default would violate the need for interim mocking. While I've tried to implement the persistence layer via Sqlite, it seems that it would be hard to find a way to contribute this feature directly to this repo unless there's admin interface built-in and state-extension is able to be configured directly via the interface 🤔
https://github.com/willypt/wiremock-state-extension/pull/1
For reference of the above feature in case there are people looking for the idea of how to override the store quickly 👍🏻
A small update. I talked with the core wiremock team on both configuration and store options. Long term, the store system of WireMock will be configurable, e.g. by adding custom stores. This will be the way to go for establishing this feature in the end.
As intermediate solution, I'm thinking about adding some configuration options. These options will be phased out as soon as the store system is available though. The feature design for extension-specific configuration options is covered in issue wiremock/wiremock#2579 .
A small update. I talked with the core wiremock team on both configuration and store options. Long term, the store system of WireMock will be configurable, e.g. by adding custom stores. So any persistence will be covered by that mechanism.