Skip to content

Conversation

raymondjacobson
Copy link
Member

This was painful!

  • Fix S3 polling so that we do things in order and never process an update/delete before the original message (increase batch size and sort files in chronological order)
  • Add presigned s3 urls to load UI faster for debugging (instead of proxying files through local disk)
  • Fix acknowledgement message formatting, particularly make sure to include release info in failure message
  • Fix deal parsing for ddex 4.0 Release / TrackRelease fields
  • Add "problems" for InvalidFirstPublicationDate and InvalidDealDate
  • Add "problems" to the UI for better debugging

Tested via prod s3 dump.

npm run worker

using the correct source config

Manually reviewed recent dump

// MessageRecipient (Source)
const messageRecipient = $('<MessageRecipient></MessageRecipient>')
messageRecipient.append($(`<PartyId>${source.toUpperCase()}</PartyId>`))
const resolvedRecipient = recipientPartyId || (source === 'sme' ? 'PADPIDA2007040502I' : source.toUpperCase())

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what our prototype/roughness comfort level is in this repo. But this seems like it should be a constant and/or some kind of function that can determine the value. Having the source check for a particular label hard-coded in here feels cryptic and hard to maintain :-D

if (isSuccess) {
releaseStatus.append($('<ReleaseStatus>SuccessfullyIngestedByReleaseDistributor</ReleaseStatus>'))
const acknowledgement = $('<Acknowledgement></Acknowledgement>')
acknowledgement.append($('<MessageType>NewReleaseMessage</MessageType>'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know why it feels wild to me that we're doing all of these lines with string literals for tag names to incrementally build XML. This def feels like something that could eventually be append(Tags.MessageType, Types.NewRelease) etc...
But again, probably not that point in dev for this repo...

isSuccess: false,
error: errorMessage
error: errorMessage,
recipientPartyId: source === 'sme' ? 'PADPIDA2007040502I' : undefined

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now that I've seen it thrice, definitely should be a helper

// Handle case where there are common prefixes (folder structure)
if (prefixes && prefixes.length > 0) {
const batchSize = 20
const batchSize = 100

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super curious how many simultaneous connections the node server can have open to a single host and whether 100 things will actually fire off at once.

})
)

// Process all files in chronological order

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will admit I was at first confused as to how this is ensuring chronological ordering haha. But I see that's in the implementation details of processS3Contents

.sort((a, b) => {
const timestampA = a!.messageTimestamp || ''
const timestampB = b!.messageTimestamp || ''
return timestampA.localeCompare(timestampB)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resisting the urge to go down a rabbit hole to determine if locale actually matters when comparing timestamps strings.
Also, feels like we maybe shouldn't do that lexicographically but should parse them to actual numbers and do the comparison with plain ole gt/lt

for (const file of sortedFiles) {
const xmlUrl = `s3://` + join(bucket, file!.key)
console.log('parsing', xmlUrl, 'timestamp:', file!.messageTimestamp)
const releases = (await parseDdexXml(source, xmlUrl, file!.xml)) || []

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So just curious, the parsing of the files changes based on the order you parse them in? Or is it just the processing of them afterwards that matters? Feels like a serial process of parsing files is slower than it could be. But if this is doing more than parsing, I could see why it matters.

const Bucket = s3url.host
const Key = s3url.pathname.substring(1)
const source = sources.findByXmlUrl(xmlUrl)
const s3 = dialS3(source)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

call 1-900-my-buckt today, act now!

const source = sources.findByXmlUrl(xmlUrl)
const s3 = dialS3(source)
const command = new GetObjectCommand({ Bucket, Key })
const signed = await getSignedUrl(s3 as any, command as any, {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

por que anys

releases: DDEXRelease[],
isSuccess: boolean,
error?: string
error?: string,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this typical TS? or some other kind of error?

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.

3 participants