From 5ec270aa98b806f32338fa25357abdf45dd0625b Mon Sep 17 00:00:00 2001 From: Jakob Odersky Date: Wed, 22 Aug 2018 12:51:36 -0700 Subject: Trait-based initialization and other utilities Adds the concept of a 'platform', a centralized place in which environment-specific information will be managed, and provides common initialization logic for most "standard" apps. As part of the common initialization, other parts of core have also been reworked: - HTTP-related unmarshallers and path matchers have been factored out from core.json to a new core.rest.directives package (core.json extends those unmarshallers and matchers for backwards compatibility) - CORS handling has also been moved to a dedicated utility trait - Some custom headers have been moved from raw headers to typed ones in core.rest.headers - The concept of a "reporter" has been introduced. A reporter is a context-aware combination of tracing and logging. It is intended to issue diagnostic messages that can be traced across service boundaries. Closes #192 Closes #195 --- .../scala/xyz/driver/core/rest/HttpRestServiceTransport.scala | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/main/scala/xyz/driver/core/rest/HttpRestServiceTransport.scala') diff --git a/src/main/scala/xyz/driver/core/rest/HttpRestServiceTransport.scala b/src/main/scala/xyz/driver/core/rest/HttpRestServiceTransport.scala index 788729a..c3b6bff 100644 --- a/src/main/scala/xyz/driver/core/rest/HttpRestServiceTransport.scala +++ b/src/main/scala/xyz/driver/core/rest/HttpRestServiceTransport.scala @@ -10,7 +10,6 @@ import com.typesafe.scalalogging.Logger import org.slf4j.MDC import xyz.driver.core.Name import xyz.driver.core.rest.errors.{ExternalServiceException, ExternalServiceTimeoutException} -import xyz.driver.core.time.provider.TimeProvider import scala.concurrent.{ExecutionContext, Future} import scala.util.{Failure, Success} @@ -20,8 +19,7 @@ class HttpRestServiceTransport( applicationVersion: String, actorSystem: ActorSystem, executionContext: ExecutionContext, - log: Logger, - time: TimeProvider) + log: Logger) extends ServiceTransport { protected implicit val execution: ExecutionContext = executionContext @@ -30,7 +28,7 @@ class HttpRestServiceTransport( def sendRequestGetResponse(context: ServiceRequestContext)(requestStub: HttpRequest): Future[HttpResponse] = { - val requestTime = time.currentTime() + val requestTime = System.currentTimeMillis() val request = requestStub .withHeaders(context.contextHeaders.toSeq.map { @@ -51,11 +49,11 @@ class HttpRestServiceTransport( response.onComplete { case Success(r) => - val responseLatency = requestTime.durationTo(time.currentTime()) + val responseLatency = System.currentTimeMillis() - requestTime log.debug(s"Response from ${request.uri} to request $requestStub is successful in $responseLatency ms: $r") case Failure(t: Throwable) => - val responseLatency = requestTime.durationTo(time.currentTime()) + val responseLatency = System.currentTimeMillis() - requestTime log.warn(s"Failed to receive response from ${request.method} ${request.uri} in $responseLatency ms", t) }(executionContext) -- cgit v1.2.3