Skip to content

Async Redis trigger#3435

Merged
itowlson merged 1 commit intospinframework:mainfrom
itowlson:async-redis-trigger
Mar 25, 2026
Merged

Async Redis trigger#3435
itowlson merged 1 commit intospinframework:mainfrom
itowlson:async-redis-trigger

Conversation

@itowlson
Copy link
Collaborator

This was too simple. It must be a trap.

(Well I say it was too simple, but it still took muggins here long enough to get all the bits to line up.)

Tested manually, initially with a SDK [redis_component]-based thingy to make sure the existing sync path still worked, and then with a wit-bindgen export binding, and calling async KV operations to make sure that async was working as expected. I haven't clobbered the concurrency side of things though, or error handling really.

@alexcrichton @dicej does this look as you would expect, or are there a bunch of subtleties that I should have been considering?

Copy link
Contributor

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable to me, especially if we can add some automated test coverage.

Signed-off-by: itowlson <ivan.towlson@fermyon.com>
@itowlson itowlson force-pushed the async-redis-trigger branch from 0b588da to 1655e70 Compare March 25, 2026 19:42
@itowlson itowlson marked this pull request as ready for review March 25, 2026 19:42
@itowlson
Copy link
Collaborator Author

Added a (fairly simple) test.


/// The full world of a guest targeting a redis-trigger
world redis-trigger {
include platform;
Copy link
Contributor

@dicej dicej Mar 25, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick note that this one line is super valuable. As I work on updating spin-go-sdk to work with modern Spin, I noticed that the existing fermyon:spin/redis-trigger world is so ancient it doesn't support any wasi:http imports (or wasi:$anything, for that matter), which makes supporting it in SDKs awkward, since we can't give the user access to e.g. outbound http except via the old fermyon:spin/http interface.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The WIT worlds are kind of untrue: we link everything unconditinally in the factors. My guess is that if a v1 Redis trigger used WASI P2 HTTP then it would work despite what the WIT world says...

use spin_trigger::{cli::NoCliArgs, App, Trigger, TriggerApp};
use spin_world::exports::fermyon::spin::inbound_redis;
use spin_world::exports::fermyon::spin::inbound_redis as v1;
use spin_world::exports::spin::redis::inbound_redis as v3;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per my other comment in this review, we should make sure we've added all the other spin:up/platform stuff to the linker, not just the old fermyon:spin/platform stuff. I don't think there's an easy way to do that only for the V3 case, so we'd be giving V1 components access to all that stuff, too, but that's not a huge problem, I'd imagine.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe RuntimeFactors (via the base trigger implementation) takes care of that. My test shows we have access to async KV (a very recent addition) and I didn't need to do anything to make that work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I just realized the error I was getting was from componentize-go rather than Spin, meaning you can ignore what I said above. Sorry for the noise!

@itowlson itowlson merged commit b776289 into spinframework:main Mar 25, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants