pub struct GrainRef { /* private fields */ }Expand description
A handle to a specific grain (interface + grain type + key) on which methods can be invoked.
GrainRef is cheap to clone and carries optional per-grain overrides for
request context and timeout.
Implementations§
Source§impl GrainRef
impl GrainRef
Sourcepub fn interface_name(&self) -> &str
pub fn interface_name(&self) -> &str
The grain interface name this reference targets.
Sourcepub fn grain_type(&self) -> &str
pub fn grain_type(&self) -> &str
The grain type alias this reference targets.
Sourcepub fn with_context(self, context: RequestContext) -> Self
pub fn with_context(self, context: RequestContext) -> Self
Return a copy of this reference with request-context entries that are applied to every call made through it.
Sourcepub fn with_timeout(self, timeout: Duration) -> Self
pub fn with_timeout(self, timeout: Duration) -> Self
Return a copy of this reference with a per-call deadline override.
Sourcepub async fn invoke(
&self,
method: &str,
payload: Vec<u8>,
codec: &str,
) -> Result<RawResponse, OrleansError>
pub async fn invoke( &self, method: &str, payload: Vec<u8>, codec: &str, ) -> Result<RawResponse, OrleansError>
Invoke method with an opaque, already-encoded payload under codec.
This is the lowest-level entry point; prefer GrainRef::invoke_json
for typical use.
§Errors
Returns an OrleansError on transport failure, timeout, or a
structured bridge error.
Sourcepub async fn invoke_json<Req, Resp>(
&self,
method: &str,
request: &Req,
) -> Result<Resp, OrleansError>
pub async fn invoke_json<Req, Resp>( &self, method: &str, request: &Req, ) -> Result<Resp, OrleansError>
Invoke method, serializing request to JSON and deserializing the
JSON response.
Use a unit value (&()) for methods that take no argument.
§Errors
Returns OrleansError::Serialization if (de)serialization fails, or a
transport/bridge error otherwise.
Sourcepub async fn invoke_json_with_context<Req, Resp>(
&self,
method: &str,
request: &Req,
) -> Result<(Resp, HashMap<String, String>), OrleansError>
pub async fn invoke_json_with_context<Req, Resp>( &self, method: &str, request: &Req, ) -> Result<(Resp, HashMap<String, String>), OrleansError>
Like GrainRef::invoke_json, but also returns the response-context
entries the grain produced.
§Errors
Sourcepub async fn invoke_protobuf<Req, Resp>(
&self,
method: &str,
request: &Req,
) -> Result<Resp, OrleansError>
pub async fn invoke_protobuf<Req, Resp>( &self, method: &str, request: &Req, ) -> Result<Resp, OrleansError>
Invoke method with a protobuf-encoded request and response.
The payload bytes are opaque to the bridge transport; the bridge’s grain invoker is responsible for decoding them.
§Errors
Returns OrleansError::Serialization on decode failure, or a
transport/bridge error otherwise.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for GrainRef
impl !RefUnwindSafe for GrainRef
impl Send for GrainRef
impl Sync for GrainRef
impl Unpin for GrainRef
impl UnsafeUnpin for GrainRef
impl !UnwindSafe for GrainRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request