Skip to content
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

Closed
wants to merge 27 commits into from
Closed

Release/r97 knossos #3502

wants to merge 27 commits into from

Conversation

knservis
Copy link
Contributor

@knservis knservis commented Nov 15, 2017

Prepare for release:

@knservis knservis force-pushed the release/r9x-knossos branch 5 times, most recently from a442479 to 880db56 Compare November 16, 2017 21:11
@knservis knservis changed the title Release/r9x knossos Release/r97 knossos Nov 27, 2017
@alexanderdean alexanderdean removed the request for review from chuwy November 27, 2017 13:21
Copy link
Contributor

@BenFradet BenFradet left a 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
}
}
}
Copy link
Contributor

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 {
Copy link
Contributor

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))
Copy link
Contributor

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 {
Copy link
Contributor

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
*
Copy link
Contributor

Choose a reason for hiding this comment

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

empty lines

Copy link
Contributor Author

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.

Copy link
Contributor

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
}
Copy link
Contributor

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 => {
Copy link
Contributor

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 {
Copy link
Contributor

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
)
Copy link
Contributor

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) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

empty spaces

@knservis knservis force-pushed the release/r9x-knossos branch 3 times, most recently from ad68f67 to 3ab93eb Compare November 30, 2017 15:57
}
}
}
}
Copy link
Contributor

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 {
Copy link
Contributor

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
}
Copy link
Contributor

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
Copy link
Contributor

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.

@knservis knservis force-pushed the release/r9x-knossos branch 3 times, most recently from bc4720b to aa02422 Compare December 7, 2017 18:24
val exception = JU.stripInstanceEtc(e.getMessage).orNull
s"${VendorName} incorrect event string : [${exception}]".fail
}
>>>>>>> 066c7f20... Spark Enrich: add test for Olark Adapter (closes #2792)
Copy link
Contributor

Choose a reason for hiding this comment

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

conflict

@knservis knservis force-pushed the release/r9x-knossos branch 2 times, most recently from 6ad7e57 to b1d21ea Compare December 13, 2017 17:43
@alexanderdean
Copy link
Member

Great! Next step is to put the rc live on the standard canaries.

@alexanderdean
Copy link
Member

Awesome, UA is the next step - getting the rc onto our canaries. @BenFradet let me know if you need any help with that.

@knservis knservis force-pushed the release/r9x-knossos branch 2 times, most recently from 46d8c00 to 58cf7e2 Compare December 14, 2017 16:51
Copy link
Member

@alexanderdean alexanderdean left a 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.

@BenFradet
Copy link
Contributor

@knservis Could you rebase so that the the "Prepare for release" is last and remove rc commits?

@knservis
Copy link
Contributor Author

@BenFradet done

@BenFradet
Copy link
Contributor

@knservis the date of the "Prepared for release" commit needs to be updated otherwise it's not chronological

@BenFradet
Copy link
Contributor

Merged, closing

@BenFradet BenFradet closed this Dec 18, 2017
@BenFradet BenFradet deleted the release/r9x-knossos branch December 18, 2017 15:29
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.

None yet

6 participants