Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup Inngest. Create thumbhash Inngest function. #16

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

djfarrelly
Copy link
Contributor

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

  • New inngest directory for Inngest client, events and functions. This follows the typical Inngest setup within Next.js app router projects.
  • New generateThumbhash Inngest function. This function is triggered in batches whenever "book.created" events are received. This would replace the need for the db: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 the generateThumbhash function.

Next steps

  • A new createEmbedding function would be added triggered by the same "book.created" event via "fan-out"
  • The seed-books.ts script would be broken up into an inngest function called insertBooks triggered by a "book.ingested" (or similar) event. The seed-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.
  • The same would then happen for seed-authors.ts
  • In the future, a management UI would trigger the "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!

Copy link

vercel bot commented Sep 6, 2024

@djfarrelly is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

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.

1 participant