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

Adds Finatra for skeleton api #45

Merged
merged 11 commits into from
Feb 9, 2017
Merged

Adds Finatra for skeleton api #45

merged 11 commits into from
Feb 9, 2017

Conversation

kenoir
Copy link
Contributor

@kenoir kenoir commented Feb 1, 2017

Addresses #16

}
}

object ElasticClientModule extends TwitterModule {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jamesgorrie take a look at how Finatra does dependency injection ... it's beautiful.

Copy link
Contributor

@alexwlchan alexwlchan left a comment

Choose a reason for hiding this comment

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

A few comments/questions from an initial skim.

app/build.sbt Outdated
"com.typesafe" % "config" % "1.3.1",
"org.elasticsearch" % "elasticsearch" % "5.1.2",
"com.sksamuel.elastic4s" %% "elastic4s-core" % "5.1.5",
"com.sksamuel.elastic4s" %% "elastic4s-xpack-security" % "5.1.5",
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason we don’t incorporate these versions into the versions field above?

calmService: CalmService
) extends Controller {

val apiBaseUrl = "/api/v0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Not that it’s hugely important right now, but I think the consensus was we drop the /api from URLs, as it’s all being served from api.wc.org.

val recordCollectionPair = for {
recordOption <- calmService.findRecordByAltRefNo(request.altRefNo)
collectionOption <- calmService.findParentCollectionByAltRefNo(request.altRefNo)
} yield RecordCollectionPair(recordOption, collectionOption)
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I right in thinking that recordOption and collectionOption are futures here, so we don’t hit the yield until both have resolved? Or does RecordCollectionPair become its own future?

title=data("Title").toString,
materialType=data("Material").toString,
date=data.get("Date").map(_.toString),
acquisition=data.get("Acquisition").map(_.toString)
Copy link
Contributor

Choose a reason for hiding this comment

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

What’s the difference between foo.toString and foo.map(_.toString)? Is it something to do with futures (and if so, why are only some of the fields futures?). Or because some of the fields are absent/null?

server.httpGet(
path = "/",
andExpect = Ok,
withBody = "{\"message\":\"success\"}")
Copy link
Contributor

Choose a reason for hiding this comment

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

tests!

:D

override def toResponse(request: Request, exception: ElasticsearchException): Response = {
val errorResponse = ErrorResponse(exception.getMessage)

response.internalServerError.json(errorResponse)
Copy link
Contributor

Choose a reason for hiding this comment

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

This exposes error messages from the Elasticsearch library to end-users. It would be better if this logged the error message, and then we just returned a generic 500 error.

elasticsearchService.client
.execute { clusterHealth() }
.map { response.ok.json }
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Open Q: do we want to expose these management endpoints? To end-users: definitely not. To internal staff: we should talk to James et al. about what they’re doing with healthcheck/monitoring and so on.

collection: Option[Collection]
)

case class RecordResponse(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider defining these elsewhere?


@Singleton
class MainController @Inject()(
calmService: CalmService
Copy link
Contributor

Choose a reason for hiding this comment

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

Open Q: how does an instance of CalmService actually appear here?

Robert Kenny added 5 commits February 3, 2017 17:38
Adds a BuildEnv plugin and an configS3JavaOpts plugin.

The latter retrives configuration in the typesage config library format
from S3 and returns a series of Java option flags suitable for passing
to sbt-native-packager.

The result is that when building a docker image for this application it
will bake configuration from S3 in the Typesafe config format into the
image for the appropriate environment in a format that Finatra
processes as flags.
- Fix test package namespaces
- Add resolvers for elasticsearch xpack
- Use common version for elastic4s packages
@kenoir kenoir changed the title [WIP] Adds Finatra for skeleton api Adds Finatra for skeleton api Feb 9, 2017
@kenoir kenoir merged commit 1cf6f93 into master Feb 9, 2017
@alexwlchan alexwlchan deleted the add-finatra branch April 4, 2017 07:45
alexwlchan added a commit that referenced this pull request Jun 9, 2017
Slightly tidy some of the Terraform
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.

2 participants