Skip to content

Commit

Permalink
[ALL][ISSUE-85]: fixing access modifiers, model modification (#86) (#87)
Browse files Browse the repository at this point in the history
* [ALL][ISSUE-85]: added access modifier to core, urlHttp module

* [ALL][ISSUE-85]: added headers, fixing access modifier in urlHttp module

* [ALL][ISSUE-85]: fixing access modifiers in akka an async modules

* [ALL][ISSUE-85]: fixing compile error

* [CORE][ISSUE-85]: fix influx formatter

* [CORE][ISSUE-85]: fixing execution scope

* [CORE][ISSUE-85]: another compiler error on tests
  • Loading branch information
fsanaulla authored Jul 13, 2018
1 parent 4d6484b commit cf36457
Show file tree
Hide file tree
Showing 125 changed files with 2,287 additions and 329 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka

import akka.actor.ActorSystem
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.api

import _root_.akka.actor.ActorSystem
Expand All @@ -20,12 +36,12 @@ import scala.reflect.ClassTag
* Date: 27.08.17
*/
final class Database(dbName: String,
val credentials: Option[InfluxCredentials],
private[chronicler] val credentials: Option[InfluxCredentials],
gzipped: Boolean)
(protected implicit val actorSystem: ActorSystem,
override protected implicit val mat: ActorMaterializer,
override protected implicit val ex: ExecutionContext,
override protected implicit val connection: Connection)
(private[akka] implicit val actorSystem: ActorSystem,
private[akka] implicit val mat: ActorMaterializer,
private[chronicler] implicit val ex: ExecutionContext,
private[akka] implicit val connection: Connection)
extends DatabaseIO[Future, RequestEntity](dbName)
with AkkaWriter
with AkkaReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.api

import _root_.akka.actor.ActorSystem
Expand All @@ -22,10 +38,10 @@ final class Measurement[E: ClassTag](dbName: String,
measurementName: String,
val credentials: Option[InfluxCredentials],
gzipped: Boolean)
(protected implicit val actorSystem: ActorSystem,
protected implicit val mat: ActorMaterializer,
protected implicit val ex: ExecutionContext,
protected implicit val connection: Connection)
(private[akka] implicit val actorSystem: ActorSystem,
private[akka] implicit val mat: ActorMaterializer,
private[chronicler] implicit val ex: ExecutionContext,
private[akka] implicit val connection: Connection)
extends MeasurementIO[Future, E, RequestEntity]
with AkkaWriter
with AkkaReader
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.clients

import _root_.akka.actor.ActorSystem
Expand Down Expand Up @@ -32,18 +48,19 @@ final class AkkaFullClient(host: String,
with HasCredentials
with AutoCloseable {

override def mapTo[B](resp: Future[HttpResponse], f: HttpResponse => Future[B]): Future[B] = resp.flatMap(f)
private[chronicler] override def mapTo[B](resp: Future[HttpResponse],
f: HttpResponse => Future[B]): Future[B] = resp.flatMap(f)

protected implicit val mat: ActorMaterializer = ActorMaterializer()
protected implicit val connection: Connection = Http().outgoingConnection(host, port) recover {
private[akka] implicit val mat: ActorMaterializer = ActorMaterializer()
private[akka] implicit val connection: Connection = Http().outgoingConnection(host, port) recover {
case ex: StreamTcpException => throw new ConnectionException(ex.getMessage)
case unknown => throw new UnknownConnectionException(unknown.getMessage)
}

def database(dbName: String): Database =
override def database(dbName: String): Database =
new Database(dbName, credentials, gzipped)

def measurement[A: ClassTag](dbName: String,
override def measurement[A: ClassTag](dbName: String,
measurementName: String): Measurement[A] =
new Measurement[A](dbName, measurementName, credentials, gzipped)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.clients

import _root_.akka.actor.ActorSystem
Expand All @@ -20,12 +36,11 @@ final class AkkaIOClient(host: String,
(implicit val ex: ExecutionContext, val system: ActorSystem)
extends IOClient[Future, RequestEntity] with AutoCloseable {

protected implicit val mat: ActorMaterializer = ActorMaterializer()
protected implicit val connection: Connection = Http().outgoingConnection(host, port) recover {
private[akka] implicit val mat: ActorMaterializer = ActorMaterializer()
private[akka] implicit val connection: Connection = Http().outgoingConnection(host, port) recover {
case ex: StreamTcpException => throw new ConnectionException(ex.getMessage)
case unknown => throw new UnknownConnectionException(unknown.getMessage)
}

override def database(dbName: String): Database =
new Database(dbName, credentials, gzipped)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.clients

import _root_.akka.actor.ActorSystem
Expand All @@ -24,11 +40,11 @@ final class AkkaManagementClient(host: String,
with Mappable[Future, HttpResponse]
with AutoCloseable {

override def mapTo[B](resp: Future[HttpResponse],
f: HttpResponse => Future[B]): Future[B] = resp.flatMap(f)
private[chronicler] override def mapTo[B](resp: Future[HttpResponse],
f: HttpResponse => Future[B]): Future[B] = resp.flatMap(f)

protected implicit val mat: ActorMaterializer = ActorMaterializer()
protected implicit val connection: Connection = Http().outgoingConnection(host, port) recover {
private[akka] implicit val mat: ActorMaterializer = ActorMaterializer()
private[akka] implicit val connection: Connection = Http().outgoingConnection(host, port) recover {
case ex: StreamTcpException => throw new ConnectionException(ex.getMessage)
case unknown => throw new UnknownConnectionException(unknown.getMessage)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.handlers

import _root_.akka.http.scaladsl.model.{HttpEntity, HttpResponse}
Expand All @@ -18,10 +34,10 @@ import scala.concurrent.Future
*/
private[akka] trait AkkaJsonHandler extends JsonHandler[Future, HttpResponse] with Executable {

protected implicit val mat: ActorMaterializer
private[akka] implicit val mat: ActorMaterializer

/** Custom Unmarshaller for Jawn JSON */
implicit val unm: Unmarshaller[HttpEntity, JValue] = {
private implicit val unm: Unmarshaller[HttpEntity, JValue] = {
Unmarshaller.withMaterializer {
implicit ex =>
implicit mat =>
Expand All @@ -32,13 +48,13 @@ private[akka] trait AkkaJsonHandler extends JsonHandler[Future, HttpResponse] wi
}
}

override def getResponseBody(response: HttpResponse): Future[JValue] =
private[chronicler] override def getResponseBody(response: HttpResponse): Future[JValue] =
Unmarshal(response.entity).to[JValue]

override def getResponseError(response: HttpResponse): Future[String] =
private[chronicler]override def getResponseError(response: HttpResponse): Future[String] =
getResponseBody(response).map(_.get("error").asString)

override def getOptResponseError(response: HttpResponse): Future[Option[String]] =
private[chronicler]override def getOptResponseError(response: HttpResponse): Future[Option[String]] =
getResponseBody(response)
.map(_.get("results").arrayValue.flatMap(_.headOption))
.map(_.flatMap(_.get("error").getString))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.handlers

import _root_.akka.http.scaladsl.model.Uri
Expand All @@ -11,6 +27,6 @@ import com.github.fsanaulla.chronicler.core.model.HasCredentials
*/
private[akka] trait AkkaQueryHandler extends QueryHandler[Uri] { self: HasCredentials =>

override def buildQuery(uri: String, queryParams: Map[String, String]): Uri =
private[chronicler] override def buildQuery(uri: String, queryParams: Map[String, String]): Uri =
Uri(uri).withQuery(Uri.Query(queryParams))
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/*
* Copyright 2017-2018 Faiaz Sanaulla
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.github.fsanaulla.chronicler.akka.handlers

import _root_.akka.http.scaladsl.model._
Expand All @@ -17,11 +33,11 @@ import scala.language.implicitConversions
private[akka] trait AkkaRequestHandler
extends RequestHandler[Future, HttpRequest, HttpResponse, Uri] {

protected implicit val mat: ActorMaterializer
protected implicit val connection: Connection
private[akka] implicit val mat: ActorMaterializer
private[akka] implicit val connection: Connection

override implicit def req(uri: Uri): HttpRequest = HttpRequest(uri = uri)
private[chronicler] override implicit def req(uri: Uri): HttpRequest = HttpRequest(uri = uri)

override def execute(request: HttpRequest): Future[HttpResponse] =
private[chronicler] override def execute(request: HttpRequest): Future[HttpResponse] =
Source.single(request).via(connection).runWith(Sink.head)
}
Loading

0 comments on commit cf36457

Please sign in to comment.