tzulitai opened a new pull request #125: URL: https://github.com/apache/flink-statefun/pull/125
## User usage This PR introduces a new state primitive in Stateful Functions, called `PersistedStateRegistry`. Users can use a state registry to dynamically register state like so: ``` public MyStateFn implements StatefulFunction { @Persisted private final PersistedStateRegistry registry = new PersistedStateRegistry(); public MyStateFn() { PersistedValue<String> valueState = registry.getValue(...); } void invoke(Object input) { PersistedValue<String> anotherValueState = registry.getValue(...); } } ``` Notice how the registry may be used to register state prior to the instantiation of the function instance, as well as after instantiation. State registered either way will be bound to the system (i.e. Flink state backends). ## Binding the registry A `PersistedStateRegistry` contains a `StateBinder` (now a SDK interface) which binds state to the system. In local execution (e.g. in tests), this `StateBinder` is essentially a no-op binder; the registered states are used as is with their non-fault tolerant accessors. In actual execution, when a function is loaded and the runtime discovers a `PersistedStateRegistry` field, the registry object is bound with an actual fault-tolerant `StateBinder` that binds state to Flink state backends. ## Verifying the change New unit tests have been added for: - Demonstrating the example usage of the new SDK classes. - Verifying that `PersistedStateRegistry` fields are picked up, and state registered using the registry is correctly bound. ## Brief changelog - 2693f95 Removes an unused class which conflicts with the support of dynamic state registration - 23c8df1 Cleans up the responsibilities of the original Flink state `StateBinder`. - 2eb4aab Introduces the new SDK class `PersistedStateRegistry`. This also introduces a new `StateBinder` interface in the SDK, which is used internally by the system. - d54a66e Refactors the original Flink state `StateBinder` to extend the SDK `StateBinder`. - c72e87c Makes `PersistedStateRegistry` discoverable when loading a function instance. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org