Setup Inngest. Create thumbhash Inngest function. #16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request (currently in draft) adds Inngest to the project, currently as a proof of concept. This PR can be used as a place to discuss changes and next steps.
Key changes and files
inngest
directory for Inngest client, events and functions. This follows the typical Inngest setup within Next.js app router projects.generateThumbhash
Inngest function. This function is triggered in batches whenever"book.created"
events are received. This would replace the need for thedb:seed-thumbhash
script to be run as the"book.created"
event would be sent every time a new book is added to the database. This allows the thumbhash to be generated asynchronously in the background. Batch and concurrency settings for this function are set as baseline values and may be subject to change due to performance and throughput considerations.seed-books.ts
now sends an Inngest event ("book.created"
) as each book is inserted. This triggers thegenerateThumbhash
function.Next steps
createEmbedding
function would be added triggered by the same"book.created"
event via "fan-out"seed-books.ts
script would be broken up into an inngest function calledinsertBooks
triggered by a"book.ingested"
(or similar) event. Theseed-books.ts
script would only be responsible for reading the JSON file of all books and sending a"book.ingested"
event for each book in the file. The Inngest functions would take care of all database interactions for seeding data.seed-authors.ts
"book.created"
event to re-use the thumbhash and embedding functions asynchronously.Discussion
Looking for questions and feedback on the current setup and the next steps going forward before completing that work. Thanks @leerob!