-
Notifications
You must be signed in to change notification settings - Fork 1
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
poller-lambdas
#83
poller-lambdas
#83
Conversation
8fea04d
to
5d23daf
Compare
ff6b7b2
to
a10d330
Compare
a678b5c
to
aa48010
Compare
fc4d5df
to
9f8ca92
Compare
32d6100
to
5142877
Compare
9f8ca92
to
f5e149e
Compare
5142877
to
914790e
Compare
914790e
to
b206dd2
Compare
7ce1fd0
to
c23494a
Compare
stage: 'PROD', | ||
domainName: 'newswires.gutools.co.uk', | ||
enableMonitoring: false, | ||
sourceQueue: prodWiresFeeds.sourceQueue, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a particular reason for creating the source queue as part of a different stack?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think because FIP have a reference to it, so I think we wanted to decouple, such that we could theoretically tear down the newswires stack without impacting FIP writing to the queue. @andrew-nowak could probably confirm...
@@ -1,5 +1,5 @@ | |||
{ | |||
"app": "tsx bin/cdk.ts", | |||
"app": "ts-node-dev bin/cdk.ts", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we discussed off-thread that the reason for using ts-node-dev
here is because tsx
restarts if the user presses Enter, which doesn't work with the current CLI setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, swapped out the top-level dependency on tsx
so needed to change it in cdk.json
too (worth noting GuCDK intialised this command to one using npx which seemed a shame so I can see why it was changed to tsx at one point)
|
||
Poller lambdas have their own SQS queues to facilitate long-polling and to allow invoking on a frequency faster than the once per minute allowed by CloudWatch/EventBridge rules. | ||
|
||
## Adding a new poller lambda |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💜🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tested locally and read through the code and this looks good to me. Great work! Should make it very easy to get the AP and Reuters pollers set up 👍
…ueue messages since that queue is not FIFO (see https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html)
792dbea
to
b9bc81b
Compare
f40ce49
to
7260e5c
Compare
…adds complexity and potential race conditions
7260e5c
to
e90dcf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great work! all looks well thought-out and documented. I've left just a couple of non-blocking thoughts and questions
…actually assert not nullish at runtime
16db2ae
to
f914a11
Compare
…r using FIFO queues
910b766
to
ca67cb9
Compare
…nded and will be changing the code away from what's in VCS
This PR introduces the concept of and an abstraction for 'polling' any data source we like and queuing things up for ingestion (via the existing
ingestion-lambda
).This abstraction takes care of the infrastructure (see below), build, deployment and boiler plate (obtaining secrets, writing to ingestion queue etc.) so that each 'poller-lambda' implementation (in the new
poller-lambdas/src/pollers
directory) is focussed purely on the business logic of requesting from the supplier and transforming items with proprietary shape into one or more of our sharedIngestorPayload
s.It supports both 'long-polling' and the more traditional fixed-frequency polling (with a frequency in seconds, not constrained by min. 1 min frequency of Cloudwatch/Evenbridge rules). In both cases, it can pass a string output from the invocation to be used as the input for the next (e.g. for passing a pointer id/timestamp etc, but theoretically anything via stringified JSON, albeit transferred in plain text).
It has a useful interactive local run mode, launched by
npm run dev
in thepoller-lambdas
directory, to facilitate easy iteration when onboarding new suppliers (see README).Infrastructure
For every poller (defined in
POLLERS_CONFIG
inshared/pollers.ts
), the following CDK resources are provisioned and wired together...Each lambda is given permission to read the secret and to write to the ingestion queue and its own queue.
Each lambda has alarms for errors & throttling (both zero-tolerance) plus custom alarms for when the invocation rate is too high or low, which might indicate something has gone haywire.
Thanks to GuCDK, plus a bit of tinkering with the
contentDirectory
(incdk/bin/cdk.ts
) for the auto-generatedriff-raff.yaml
the deployment is also abstracted for all pollers.Any other TODOs are things to be explored in future, not in this PR.