Skip to content

anitabee/hello-spin-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hello-spin-redis

A simple Redis message handler using TinyGo and Fermyon Spin to demonstrate event-driven WebAssembly applications.

What it does

This application listens for messages published to a Redis channel and processes them using a WebAssembly component compiled with TinyGo.

Prerequisites

  • Spin CLI
  • Go 1.20.5+
  • TinyGo 0.33.0+
  • Docker (for running Redis)

Quick Start

1. Install dependencies

# Install Spin
curl -fsSL https://developer.fermyon.com/downloads/install.sh | bash
sudo mv ./spin /usr/local/bin/

# Install/upgrade Go
brew update && brew upgrade go

# Install TinyGo
brew tap tinygo-org/tools
brew install tinygo

2. Start Redis

docker run --name redis-server -d -p 6379:6379 redis

3. Build and run

spin build --up

You should see:

Active Channels on redis://127.0.0.1:6379:
redis://127.0.0.1:6379:hello-messages: [hello-message-handler]

4. Test it

In another terminal, publish a message:

docker exec -it redis-server redis-cli
127.0.0.1:6379> PUBLISH hello-messages "Hello from Redis!"

The message will appear in your Spin application logs.

Project Structure

  • main.go - Message handler implementation
  • spin.toml - Spin application configuration
  • main.wasm - Compiled WebAssembly binary (generated)

Configuration

The app listens to Redis at 127.0.0.1:6379 on the hello-messages channel. You can modify these settings in spin.toml.

Learn More

Read the full writeup: Taking TinyGo for a Spin

Author

Anita Bendelja (@anitabee)

About

A Redis message handler using TinyGo and Fermyon Spin experiment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages