Skip to main content

Executor

Trait Executor 

Source
pub trait Executor:
    Send
    + Sync
    + 'static {
    // Required method
    fn execute_method<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        payload: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        payload: Bytes,
    ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn execute_value<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        payload: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn execute_value_traced<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        payload: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(Value, Arc<str>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn execute_streamed<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        payload: Value,
    ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn execute_streamed_with_body<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        payload: Value,
        body_rx: Receiver<Bytes>,
    ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn execute_streamed_with_parts<'life0, 'life1, 'async_trait>(
        &'life0 self,
        method: &'life1 str,
        payload: Value,
        parts_rx: Receiver<RequestPart>,
    ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
}
Expand description

Sends a serialized payload to a PHP worker and returns the response.

Plugins call this; they never see the worker pool directly.

Required Methods§

Source

fn execute_method<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send payload to a worker using a specific RPC method name.

Provided Methods§

Source

fn execute<'life0, 'async_trait>( &'life0 self, payload: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Send payload to a worker and return the response bytes. Uses the RPC method name “dispatch” by default.

Source

fn execute_value<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send structured data directly (no serialization).

The default implementation falls back to JSON serialization via Self::execute_method. Extension runtimes override this to pass values through the channel without JSON encode/decode.

Source

fn execute_value_traced<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<(Value, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like Self::execute_value, but also returns the request_id under which the request was executed — the same id exposed to PHP via folk_request_id().

Plugins that maintain an access log (e.g. HTTP) use this to record the id for log correlation. The default implementation calls Self::execute_value and returns an empty id (runtimes that don’t track one).

Source

fn execute_streamed<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Send a request and receive the response as a stream of ResponseChunks.

The returned receiver emits zero or more ResponseChunk::Body chunks preceded by a ResponseChunk::Headers chunk, and terminated by ResponseChunk::End. The Arc<str> is the request_id (UUID v7) for log correlation — the same id exposed to PHP via folk_request_id().

Callers must drain the receiver to completion (End or channel close) to allow the worker to accept the next request.

The default implementation wraps Self::execute_value_traced into a single-shot stream for runtimes that do not support true streaming. The value is emitted verbatim as a ResponseChunk::Return — consumers (HTTP / gRPC / jobs) interpret it themselves.

Source

fn execute_streamed_with_body<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, body_rx: Receiver<Bytes>, ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like Self::execute_streamed, but the request body is delivered to PHP as a stream of Bytes chunks rather than embedded in payload.

body_rx yields raw body chunks as they arrive from the transport; PHP pulls them via folk_read() / folk_read_all(). The channel closing signals end-of-body. This is the request-side counterpart to the ResponseChunk response stream.

The default implementation does not support request body streaming: it discards body_rx and delegates to Self::execute_streamed. Runtimes backed by a real worker pool override this to thread body_rx to the worker.

Source

fn execute_streamed_with_parts<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, parts_rx: Receiver<RequestPart>, ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Like execute_streamed_with_body, but the request body is a parsed multipart/form-data stream rather than opaque bytes.

parts_rx yields RequestParts (Start / Data / End per field); PHP pulls them via folk_next_part() + folk_part_read(). The channel closing signals “no more parts”.

The default implementation discards parts_rx and delegates to execute_streamed; the worker-pool runtime overrides it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Executor + ?Sized> Executor for Arc<T>

Blanket impl: an Arc<dyn Executor> is also an Executor.

Source§

fn execute<'life0, 'async_trait>( &'life0 self, payload: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn execute_method<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Bytes, ) -> Pin<Box<dyn Future<Output = Result<Bytes>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn execute_value<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<Value>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn execute_value_traced<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<(Value, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn execute_streamed<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn execute_streamed_with_body<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, body_rx: Receiver<Bytes>, ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

fn execute_streamed_with_parts<'life0, 'life1, 'async_trait>( &'life0 self, method: &'life1 str, payload: Value, parts_rx: Receiver<RequestPart>, ) -> Pin<Box<dyn Future<Output = Result<(Receiver<ResponseChunk>, Arc<str>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§