v0.13.0
New features π
- Use context manager together with service handlers:
@contextvar
@asynccontextmanager
async def my_resource_manager():
yield "hello"
@greeter.handler(invocation_context_managers=[my_resource_manager])
async def greet_with_cm(ctx: Context, name: str) -> str:
return my_resource_manager.value- Add
msgspecsupport, works out of the box when addingrestate_sdk[serde]dependency:
# models
class GreetingRequest(msgspec.Struct):
name: str
class Greeting(msgspec.Struct):
message: str
msgspec_greeter = Service("msgspec_greeter")
@msgspec_greeter.handler()
async def greet(ctx: Context, req: GreetingRequest) -> Greeting:
return Greeting(message=f"Hello {req.name}!")- Add extension modules for Google ADK and OpenAI, more info soon!
What's Changed
- Add current_context() extension point by @igalshilman in #148
- Add context manager support by @igalshilman in #149
- Rename to invocation_context_managers by @igalshilman in #150
- Rethrow TerminalError/SdkBaseException accidentally wrapped by @igalshilman in #151
- feat: add msgspec support by @v1gnesh in #154
- Consolidate msgspec conditional imports into a single place by @igalshilman in #155
- Use DefaultSerde instead of JsonSerde for promise() default parameter by @Gustavo-Hagenbeck in #157
- Support
union | Nonereturn types by @igalshilman in #158 - Use HttpError for the typed ingress client by @igalshilman in #159
- Replace traceback.print_exc() with logger.exception() for proper logging by @Gustavo-Hagenbeck in #160
- Add an optional extension module for Google ADK integration by @igalshilman in #161
- Add an optional ext module for openai by @igalshilman in #162
New Contributors
- @v1gnesh made their first contribution in #154
- @Gustavo-Hagenbeck made their first contribution in #157
Full Changelog: v0.12.0...v0.13.0