Skip to main content

What are host interfaces?

A host interface is a system call your Function makes into the host runtime to do something it can't do inside the WebAssembly sandbox. Functions has several families of host interfaces. Each is exposed as a separate Rust crate you import only if you need it. This keeps your webassembly as trim as your Function workflow.

Host interfaces are how Functions holds the sandbox boundary tight while balancing usability. Connection pools, auth caches, and SDK clients all live on the host; your Function makes syscalls to use them.

Why host interfaces exist

The architecture gives your Function no filesystem, no sockets, and no stdio. To get anything done, you have to reach out through the host. That restriction lets us provide you the lightest and most focused web function experience.

The tradeoff is that you can only call dependencies with interfaces that are supported by Functions. HTTP is supported though, which covers quite a bit! If a capability you need isn't exposed, reach out — support@momentohq.com — and we'll talk about expanding the platform.

Host interface categories

Momento

These talk directly to Momento services on the platform you're already running on. They're the fastest way to interact with Momento.

AWS

These reach into your AWS account using a federated IAM role you specify at invocation time (or explicit credentials if that's how you roll). The host keeps warm AWS clients pooled outside your sandbox.

General-purpose

What you import vs. what you use

You only pay for what you import. A pong Function pulls in momento-functions-bytes and momento-functions-guest-web and nothing else. Adding cache reads costs you a momento-functions-cache import; adding outbound HTTP costs you momento-functions-http. Each crate is its own focused module — see Project setup for the standard shape.

Trying them out

The Functions repo examples/ directory has examples for many interfaces. Feel free to clone an example, change the parts you care about, and deploy it — see Deploy and invoke.