To replace the current long polling technique
just subscribe to the topic stream changed and notify when data.length > 0 (from notify request payload) and the date saved on some sort of storage file is not the same as data.started_at (since there is no way to filter only stream goes online event)
This will increase notification reliability, introduces realtime capabilities and decrease the usage of GitHub Actions quota
But GH Actions as storage can no longer be used due to webhook callback constraint (Vercel Now, Netlify, MongoDB Stitch, Supabase Function & storage. And keeping state between serveless function invocations will be a problem. To solve this we can use the free tier of Upstash (Redis-as-a-service), or a Database-as-a-service like: mLab, FaunaDB cloud, Railway, PlanetScale, or even the free tier of Qovery to host the entire Nodejs app + using Redis as the main database.
GH Actions could be used to renew the webhook subscriptions since "All subscriptions have an expiration time, which cannot exceed 10 days."
Besides that, we'll can implement a notification for multiple Twitch channels and update the message sent by the bot as well :smiley:
Note that we're looking for a more dependecy-free and slim solution here to reduce the serverless cold start latency -- https://moiva.io to rescue!
The happy path workflow will be somewhat like this:
Client: our temporary HTTP client just send a subscription request (besides the fact that subscriptions should be renew due to its expiration time)
Helix API: https://api.twitch.tv/helix endpoint
Twitch: the twitch webhook server
Server: our serverless function that will be used as webhook (hub.callbackX value in 1, following this spec)
TODO to close this issue
[ ] Choose a serverless host provider for the new serverless/lambda function ~ must be free
[ ] If the serverless host plataform doesn't comes with some free state management feature, choose one cloud-based (or use GitHub Actions artifacts)
[ ] Implement the code for the serverless function (to handle GET / and POST / requests from Twitch, and other personal routes for eg: GET /listen/{channel} to subscribe using Helix and Webhook APIs). Including the server communication with the storage mechanism
[ ] Write the GitHub Action that will renew subscriptions ~ using schedule to run every 10 days since some well defined day (the last run)
[ ] Add a human-friendly diagram to describe HOW IT WORKS
To replace the current long polling technique just subscribe to the topic stream changed and notify when
data.length > 0
(from notify request payload) and the date saved on some sort of storage file is not the same asdata.started_at
(since there is no way to filter only stream goes online event)This will increase notification reliability, introduces realtime capabilities and decrease the usage of GitHub Actions quota
But GH Actions as storage can no longer be used due to webhook callback constraint (Vercel Now, Netlify, MongoDB Stitch, Supabase Function & storage. And keeping state between serveless function invocations will be a problem. To solve this we can use the free tier of Upstash (Redis-as-a-service), or a Database-as-a-service like: mLab, FaunaDB cloud, Railway, PlanetScale, or even the free tier of Qovery to host the entire Nodejs app + using Redis as the main database.
Maybe we can use External events:
repository_dispatch
(via GitHub API) to trigger the workflow run that will use an artifact to keep the state. See Async workflows with repository dispatch - GitHub Satellite 2020GH Actions could be used to renew the webhook subscriptions since "All subscriptions have an expiration time, which cannot exceed 10 days."
Besides that, we'll can implement a notification for multiple Twitch channels and update the message sent by the bot as well :smiley:
Note that we're looking for a more dependecy-free and slim solution here to reduce the serverless cold start latency -- https://moiva.io to rescue!
The happy path workflow will be somewhat like this:
TODO to close this issue
GET /
andPOST /
requests from Twitch, and other personal routes for eg:GET /listen/{channel}
to subscribe using Helix and Webhook APIs). Including the server communication with the storage mechanismExample of incoming request from Twitch (step 5):