pub struct LambdaRuntime { /* private fields */ }Implementations§
Source§impl LambdaRuntime
impl LambdaRuntime
Sourcepub fn from_backend(backend: Arc<dyn LambdaBackend>) -> Self
pub fn from_backend(backend: Arc<dyn LambdaBackend>) -> Self
Construct a runtime over the supplied backend. Callers that want
auto-detection should use Self::auto_detect_docker or
Self::new.
Sourcepub fn auto_detect_docker(server_port: u16) -> Option<Self>
pub fn auto_detect_docker(server_port: u16) -> Option<Self>
Auto-detect Docker or Podman. Returns None if neither is available.
Override with FAKECLOUD_CONTAINER_CLI env var.
Sourcepub fn new(server_port: u16) -> Option<Self>
pub fn new(server_port: u16) -> Option<Self>
Backwards-compatible alias for Self::auto_detect_docker.
Callers across the workspace use ContainerRuntime::new(port).
Sourcepub async fn new_k8s(
server_port: u16,
internal_token: String,
) -> Result<Self, K8sBackendError>
pub async fn new_k8s( server_port: u16, internal_token: String, ) -> Result<Self, K8sBackendError>
Construct a runtime backed by the Kubernetes backend. Reads
configuration from env vars (FAKECLOUD_K8S_SELF_URL,
FAKECLOUD_K8S_NAMESPACE, etc.) and connects to the cluster
via in-cluster service account or kubeconfig. Hard-fails on
any configuration or connectivity issue — we don’t silently
fall back to Docker because the operator explicitly opted in
to K8s.
internal_token is the bearer token the artifact endpoints on
the fakecloud server expect from Pod init containers — caller
must register the same token on those endpoints.
pub fn cli_name(&self) -> &str
Sourcepub async fn prepull_for_function(
&self,
func: &LambdaFunction,
) -> Option<Result<(), RuntimeError>>
pub async fn prepull_for_function( &self, func: &LambdaFunction, ) -> Option<Result<(), RuntimeError>>
Background pre-warm hook: pull the image a Zip-package function
will need at invoke time, or the ImageUri of an Image-package
function. The first cold pull of an AWS base image (~700 MB)
frequently exceeds the AWS CLI default 60s read timeout, surfacing
to users as Connection was closed (issue #1539). Call after
CreateFunction persists so the warm path is ready before the
caller turns around and calls Invoke.
Returns None if the function has no resolvable image (e.g. an
unsupported runtime string we can’t map to a base image).
Otherwise returns the result of the backend’s prepull_image —
callers log failures and move on, since invoke time still
re-attempts the pull as a fallback.
Sourcepub async fn invoke(
&self,
func: &LambdaFunction,
payload: &[u8],
layers: &[Vec<u8>],
) -> Result<Vec<u8>, RuntimeError>
pub async fn invoke( &self, func: &LambdaFunction, payload: &[u8], layers: &[Vec<u8>], ) -> Result<Vec<u8>, RuntimeError>
Invoke a Lambda function, starting an instance if needed. Layer
ZIPs are extracted into /opt of the runtime sandbox; AWS base
images already include /opt/python, /opt/nodejs/node_modules,
/opt/lib, and /opt/bin on the right import paths.
Sourcepub async fn invoke_streaming(
&self,
func: &LambdaFunction,
payload: &[u8],
layers: &[Vec<u8>],
) -> Result<StreamingInvocation, RuntimeError>
pub async fn invoke_streaming( &self, func: &LambdaFunction, payload: &[u8], layers: &[Vec<u8>], ) -> Result<StreamingInvocation, RuntimeError>
Invoke a Lambda function and yield the raw HTTP body as a stream of byte chunks. Each chunk corresponds to one HTTP frame the RIE flushed to the wire — for streaming-aware handlers this preserves the chunk boundaries the function emitted. Buffered handlers come back as a single chunk, which is still a valid streamed response.
Sourcepub async fn stop_container(&self, function_name: &str)
pub async fn stop_container(&self, function_name: &str)
Stop and remove a warm instance for a specific function.
Sourcepub async fn stop_all(&self)
pub async fn stop_all(&self)
Stop and remove all warm instances (used on server shutdown or reset).
Sourcepub fn list_warm_containers(
&self,
lambda_state: &SharedLambdaState,
) -> Vec<Value>
pub fn list_warm_containers( &self, lambda_state: &SharedLambdaState, ) -> Vec<Value>
List all warm instances and their metadata for introspection.
Sourcepub async fn evict_container(&self, function_name: &str) -> bool
pub async fn evict_container(&self, function_name: &str) -> bool
Evict (stop and remove) the warm instance for a specific function. Returns true if an instance was found and evicted.
Sourcepub async fn run_cleanup_loop(self: Arc<Self>, ttl: Duration)
pub async fn run_cleanup_loop(self: Arc<Self>, ttl: Duration)
Background loop that stops instances idle longer than ttl.
Auto Trait Implementations§
impl !Freeze for LambdaRuntime
impl !RefUnwindSafe for LambdaRuntime
impl Send for LambdaRuntime
impl Sync for LambdaRuntime
impl Unpin for LambdaRuntime
impl UnsafeUnpin for LambdaRuntime
impl !UnwindSafe for LambdaRuntime
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> 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more