-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Release/r97 knossos #3502
Release/r97 knossos #3502
Conversation
a442479
to
880db56
Compare
d4f9fd7
to
0f79268
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.
hey @knservis i did a first pass, here's my feedback:
- you need to bump spark enrich
- check the correspondance between the changelog, the commits, the issues
- you need to publish qa artifacts for sce (0.28.0-M1) and spark enrich (1.11.0-rc1)
- be a bit more mindful of code hygiene
👍
)).success | ||
} | ||
} | ||
} |
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.
can't we refactor those 2 nested failure/success into a for comprehension?
bodyMap.get("event") match { | ||
case None => s"No ${VendorName} event parameter provided: cannot determine event type".failNel | ||
case Some(eventType) => { | ||
(payloadBodyToEvent(bodyMap)) match { |
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.
unnecessary parens
try { | ||
val bodyMap = getBoundary(ct) | ||
.map(parseMultipartForm(body, _)) | ||
.getOrElse(toMap(URLEncodedUtils.parse(URI.create("http://localhost/?" + body), "UTF-8").toList)) |
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.
if we want to be consistent with other parts of the codebase this will look like:
val bodyMap = getBoundary(ct)
.map(parseMultipartForm(body, _))
.getOrElse(toMap(URLEncodedUtils.parse(URI.create("http://localhost/?" + body), "UTF-8").toList))
private def parseMultipartForm(body: String, boundary: String): Map[String, String] = | ||
body | ||
.split(s"--$boundary") | ||
.flatMap( _ match { |
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.
no need for _ match {
* Content-Disposition: form-data; anything="notllokingintothis"; name="key" | ||
* | ||
* value | ||
* |
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.
empty lines
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.
Actually the empty line above "value" is mandated by the RFC mentioned.
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.
ah my bad I thought it was some weird comment formatting
case NonFatal(e) => { | ||
val exception = JU.stripInstanceEtc(e.toString).orNull | ||
s"${VendorName} could not parse body: [${exception}]".failNel | ||
} |
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.
pls try to limit brackets here and in the other files too
val exception = JU.stripInstanceEtc(e.toString).orNull | ||
s"${VendorName} event string failed to parse into JSON: [${exception}]".failNel | ||
} | ||
case e: Exception => { |
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.
NonFatal
s"${VendorName} event body is empty: nothing to process".failNel | ||
} else { | ||
val qsParams = toMap(payload.querystring) | ||
try { |
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.
here and for the others too, can't we move the try/catch closer to what can actually throw an exception, I'm guessing the parse?
Also can't this logic be factored out? I feel like I'm seeing the same logic in all the adapters
// Schema for Unbounce event context | ||
private val ContextSchema = Map( | ||
"event_context" -> SchemaKey("com.unbounce", "event_context", "jsonschema", "1-0-0").toSchemaUri | ||
) |
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.
do we need a map here?
try { | ||
val bodyMap = toMap(URLEncodedUtils.parse(URI.create("http://localhost/?" + body), "UTF-8").toList) | ||
payloadBodyToContext(bodyMap) match { | ||
case Success(validatedBodyMap) => { |
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.
empty spaces
ad68f67
to
3ab93eb
Compare
3ab93eb
to
7284d64
Compare
fe49298
to
0fcbb97
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.
can't we refactor those nested matches as:
// ...
case Some(eventType) =>
for {
event <- payloadBodyToEvent(bodyMap).leftMap(_.wrapNel)
schemaUri <- lookupSchema(eventType.some, VendorName, EventSchemaMap)
} yield NonEmptyList(RawEvent(
api = payload.api,
parameters = toUnstructEventParams(TrackerVersion, params, schemaUri, cleanupJsonEventValues(
mutateMailgunEvent(event),
("event", eventType).some, "timestamp"), "srv"),
contentType = payload.contentType,
source = payload.source,
context = payload.context
))
this will be way more readable imo
case (Some(body), _) if (body.isEmpty) => s"${VendorName} event body is empty: nothing to process".failNel | ||
case (Some(body), Some(ct)) => { | ||
val params = toMap(payload.querystring) | ||
try { |
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.
can't we take the try/catch closer to what can actually throw?
} | ||
} catch { | ||
case NonFatal(e) => s"${VendorName} could not parse body: [${JU.stripInstanceEtc(e.getMessage).orNull}]".failNel | ||
} |
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.
same as before:
- for comp
- try/catch closer to what can throw
* | ||
* @param oTs olark timestamp string | ||
* @return Long msec | ||
* @throws MatchError and NumberFormatException |
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.
pls handle those at the lowest level possible, make this an option or a Validation
It shouldn't be the caller's responsibility to blindly handle a function's shortcomings.
bc4720b
to
aa02422
Compare
val exception = JU.stripInstanceEtc(e.getMessage).orNull | ||
s"${VendorName} incorrect event string : [${exception}]".fail | ||
} | ||
>>>>>>> 066c7f20... Spark Enrich: add test for Olark Adapter (closes #2792) |
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.
conflict
6ad7e57
to
b1d21ea
Compare
Great! Next step is to put the rc live on the standard canaries. |
Awesome, UA is the next step - getting the rc onto our canaries. @BenFradet let me know if you need any help with that. |
46d8c00
to
58cf7e2
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.
UA has gone fine on snplow2, so green tick from me.
58cf7e2
to
3b1f0dd
Compare
@knservis Could you rebase so that the the "Prepare for release" is last and remove rc commits? |
3b1f0dd
to
d39cf8e
Compare
@BenFradet done |
@knservis the date of the "Prepared for release" commit needs to be updated otherwise it's not chronological |
d39cf8e
to
98b79d4
Compare
…to release/r9x-knossos
Merged, closing |
Prepare for release: