Skip to content

Conversation

@shentongmartin
Copy link
Contributor

Async Lambda Node in Eino Graph

This example demonstrates an "async node" implemented as a normal lambda in an Eino graph.
It covers two realistic business scenarios:

  • Report Generation (invokable): a long-running background job that produces a document URL.
  • Live Transcription (streamable): a stream of tokens produced over time and converted via StreamReaderWithConvert.

Files

  • service.go: mocked services (generateReport, transcribeLive).
  • main.go: graph wiring, lambda nodes, and run flows.

How It Works

  • The invokable lambda starts generateReport in a goroutine and blocks on a channel until completion or cancellation.
  • The streamable lambda obtains a live StreamReader[string] and wraps it with StreamReaderWithConvert to transform tokens.

Run

cd compose/graph/async_node
go run .

You will see:

  • A report URL logged from the invokable path.
  • A stream of uppercase tokens from the transcription path until EOF.

Notes

  • The services inject errors when inputs contain the word error, to showcase error propagation.
  • Cancellation is respected via context.Context.

Change-Id: I1e5af39c3ac197017ef809d7e68eb4911266925d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants