You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't like passing all the app logic as lambdas because it makes the codebase messy. It would be great if Restate used an annotation-based approach instead (or something else), which would mean moving the responsibility from the caller method to the called method
What if we created a @Run annotation instead of calling ctx.run()? For example:
Hi, the idea per se makes sense, but the way I see it the only approach where this would look good is through reflections, which is something I'm currently avoiding as much as possible in the SDK.
I agree with you about avoiding reflections as much as possible. However, is there any way to avoid forcing the client code to use lambdas excessively, at least in the caller code?
@slinkydeveloper An alternative programming model using protected methods + proxy generation would offer a better DX. As for context, if you are willing to require Java 25 in a future release then you can use ScopedValues.
Hey all, i've been exploring a solution that uses proxy generation, like: you provide any class, and all public methods will become "ctx.run wrapped". Something along the lines of:
var wrappedClient = Restate.runProxy(theClient[, retryOptions]);
wrappedClient.someMethod() // This becomes ctx.run("someMethod", () -> theClient.someMethod())
ofc this would require the return value of someMethod to be jackson serializable (futures and co would not work correctly for example). WDYT?
Activity
slinkydeveloper commentedon Sep 15, 2025
Hi, the idea per se makes sense, but the way I see it the only approach where this would look good is through reflections, which is something I'm currently avoiding as much as possible in the SDK.
zakaria-shahen commentedon Sep 17, 2025
I agree with you about avoiding reflections as much as possible. However, is there any way to avoid forcing the client code to use lambdas excessively, at least in the caller code?
Maybe like that:
slinkydeveloper commentedon Sep 18, 2025
This should work fine
zakaria-shahen commentedon Sep 18, 2025
That's great, thank you! But is there any way to fetch the Context via a static method?
ooraini commentedon Dec 8, 2025
@slinkydeveloper An alternative programming model using protected methods + proxy generation would offer a better DX. As for context, if you are willing to require Java 25 in a future release then you can use ScopedValues.
https://www.morling.dev/blog/building-durable-execution-engine-with-sqlite/
slinkydeveloper commentedon Jan 14, 2026
Hey all, i've been exploring a solution that uses proxy generation, like: you provide any class, and all public methods will become "ctx.run wrapped". Something along the lines of:
ofc this would require the return value of
someMethodto be jackson serializable (futures and co would not work correctly for example). WDYT?