-
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
Reuters poller business logic #92
Conversation
3ce7d8c
to
7030e94
Compare
1d949b5
to
4889fdc
Compare
fb0920c
to
f6de1a7
Compare
c983801
to
684492e
Compare
d644737
to
ef43389
Compare
ef43389
to
04a5b6c
Compare
04a5b6c
to
8a7e365
Compare
8a7e365
to
e358ff1
Compare
In conversation with Reuters they said that there's currently no way of requesting just the stories that have changed since last request ('endCursor' shouldn't be relied upon for this). So we should search for a time period that overlaps with our last request, and page through the results. The ingestion lambda handles deduplication now, so no need to deduplicate here unless we spot performance issues, for instance.
|
||
let accessToken = ACCESS_TOKEN ?? (await auth(CLIENT_ID, CLIENT_SECRET)); | ||
|
||
async function fetchWithReauth(query: string) { |
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.
this function is defined within the scope of the main poller function so that it can read and mutate accessToken
.
I went back and forth on whether to handle this in a more 'pure' way, but as mentioned in the PR description this felt like a good balance in context. Open to other perspectives though!
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.
lgtm! great work!
'https://api.thomsonreuters.com/auth/reutersconnect.contentapi.read https://api.thomsonreuters.com/auth/reutersconnect.contentapi.write'; | ||
const authUrl = 'https://auth.thomsonreuters.com/oauth/token'; | ||
const grantType = 'client_credentials'; | ||
const audience = '7a14b6a2-73b8-4ab2-a610-80fb9f40f769'; |
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.
just double checking that this value is fine to be made public? iirc it's a value that's shared by all customers, is that right?
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.
yep that's right -- it's from the Reuters API documentation 👍
Add more fields to JSON view in UI
What does this change?
First pass at business logic for Reuters feed.
Steps:
1. Auth
2. Request feed via search for the last
n*1.2
seconds, wheren
is the frequency at which the poller runs.3. Pass the most recent auth token back
The poller lambda wrapper, as of #99, will check this value and update the Secret value if needed.
The implementation of (1) adds a little complexity and mutation that it would be nice to avoid, but the API guidelines suggest we shouldn't request new access tokens too often, so we should respect that. It could be refactored so that e.g.
fetchWithReauth
andfetchAllPages
were defined outside the scope of the main function, and hadaccessToken
passed as an argument, but on reflection it felt to me as though declaringaccessToken
vialet
makes it more explicit a) that it can mutate, and b) which functions can mutate it. I'm open to other perspectives though.Script
Also adds a script to help get raw item data from the Reuters API, to help with debugging.
How to test
How can we measure success?
Have we considered potential risks?
Images
Accessibility