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
{{ message }}
Repository navigation
Add accessors for the observed and desired XR and composed resources #34
Found while building composition functions on function-sdk-rust 0.3.1.
Today. Functions reach into the request and response through Option chains, and the two most common ones already appear twice in the SDK's own docs and the CLI template:
Go.request.GetObservedCompositeResource and GetObservedComposedResources, and response.SetDesiredCompositeResource and SetDesiredComposedResources. These accessors are parity with Go, not new surface.
Proposed. Four borrowing accessors with no conversion. Typed reads stay one call through resource::get::<T>.
// requestpubfnobserved_composite(req:&RunFunctionRequest) -> Option<&Resource>;pubfnobserved_composed<'a>(req:&'aRunFunctionRequest,name:&str) -> Option<&'aResource>;// response: insert an empty resource when the response has nonepubfndesired_composite(rsp:&mutRunFunctionResponse) -> &mutResource;pubfndesired_composed(rsp:&mutRunFunctionResponse,name:implInto<String>) -> &mutResource;
let xr:Xr = resource::get(request::observed_composite(&req))?;
resource::update(response::desired_composed(&mut rsp,"bucket"),&bucket)?;
resource::update_status(response::desired_composite(&mut rsp),&status)?;
The template, the README and the example would switch to these in the same change. The response accessors modify the entry in place, so with #31 an updated Resource keeps its unknown fields. Go also has request.GetDesiredCompositeResource and GetDesiredComposedResources; read-only request::desired_composite and request::desired_composed could follow if a function needs them, but nothing in the template or docs does today.
Prototyped against v0.3.1 with tests; clippy is clean.
Activity