-
Notifications
You must be signed in to change notification settings - Fork 9
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
Merge plugins #43
Merge plugins #43
Conversation
# Conflicts: # project/ProjectPlugin.scala
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.
👍
|
||
lazy val muSrcGenCompendiumServerPort: SettingKey[Int] = | ||
settingKey[Int]("Port of the compendium server") | ||
|
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.
suggestion: I think it worth specifying what are the default values for every new setting. Thoughts?
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.
I have to update documentation too, which has (or should have) the default values. But it's not a bad idea
project/ProjectPlugin.scala
Outdated
@@ -17,6 +17,7 @@ object ProjectPlugin extends AutoPlugin { | |||
lazy val V = new { | |||
val avrohugger: String = "1.0.0-RC22" | |||
val circe: String = "0.13.0" | |||
val hammock = "0.10.0" |
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.
Hammock 0.10.0
is bringing circe 0.12.1
, as you can see here. However, that will provoke a collision with the circe version we are using in this build: 0.13.0.
My suggestion would be using an http4s
client, as it is evolving at the same time as typelevel ecosystem does. The other option would be to work on Hammock and try to make it updated and released with the latest dependency versions.
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.
ready, please take a look @juanpedromoreno
project/ProjectPlugin.scala
Outdated
@@ -25,6 +25,7 @@ object ProjectPlugin extends AutoPlugin { | |||
val scalatestplusScheck: String = "3.1.0.0-RC2" | |||
val skeuomorph: String = "0.0.23" | |||
val slf4j: String = "1.7.30" | |||
val http4s: String = "0.21.1" |
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.
val http4s: String = "0.21.1" | |
val http4s: String = "0.21.4" |
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.
I'll put all the changes in the same commit
F: Sync[F] | ||
def apply[F[_]: Sync]( | ||
clientF: Client[F], | ||
clientConfig: HttpConfig | ||
): CompendiumClient[F] = | ||
new CompendiumClient[F] { | ||
|
||
val baseUrl: String = s"http://${clientConfig.host}:${clientConfig.port}" |
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.
suggestion: I'd parametrize the http
part of the Url (it could be https
).
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.
Or merge both in a single property called "connectionUrl" or something like that
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.
Yeah I would put the whole URL, including the port number, into a single property (connectionUrl
? serverUrl
?). Fewer things for the user to configure, and no assumptions about how they want to host the server.
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.
for now, it could be merged. It was split because we had, at least, two endpoints to call.
So, does this work for both of you?
val versionParam = version.fold("")(v => s"?version=${v.show}")
val connectionUrl = s"https://${clientConfig.host}:${clientConfig.port}/v0/protocol/$identifier$versionParam"
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.
Sorry, I wasn't very clear. My suggestion was to have the server's base URL (e.g. https://devtools.mycorp.com:1234/compendium
) passed in as a single property inside HttpConfig
. Inside this method we would construct the full URL:
val connectionUrl = s"${clientConfig.serverUrl}/v0/protocol/$identifier$versionParam"
case Status.OK => request.as[RawProtocol].map(Option(_)).exec[F] | ||
clientF.get(uri)(res => | ||
res.status match { | ||
case Status.Ok => res.as[RawProtocol].map(Option(_)) | ||
case Status.NotFound => Sync[F].pure(None) |
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.
question: If something is not found, it worth to notify the user?
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.
With the current development, it raises an error:
case None =>
Async[F].raiseError[File](
ProtocolNotFound(s"Protocol ${protocolAndVersion.name} not found in Compendium. ")
)
on run
function
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.
I think it makes sense to just return None
at this point, because we are just an HTTP client and we don't know what we are being used for. It's pretty reasonable to try to get a resource which might not exist, so it's not an exceptional circumstance.
Whoever is using the client can decide whether a missing resource should be an error or not.
|
||
final case class ProtocolAndVersion(name: String, version: Option[String]) | ||
final case class FilePrintWriter(file: File, pw: PrintWriter) | ||
|
||
case class CompendiumMode[F[_]: Async]( | ||
case class CompendiumMode[F[_]: Async: ConcurrentEffect]( |
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.
case class CompendiumMode[F[_]: Async: ConcurrentEffect]( | |
final case class CompendiumMode[F[_]: ConcurrentEffect]( |
@@ -1,46 +1,52 @@ | |||
package higherkindness.mu.rpc.srcgen.compendium | |||
|
|||
import java.io.{File, PrintWriter} | |||
import cats.effect.{Async, Resource, Sync} | |||
|
|||
import cats.effect.{Async, ConcurrentEffect, Resource, Sync} |
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.
import cats.effect.{Async, ConcurrentEffect, Resource, Sync} | |
import cats.effect.{Resource, ConcurrentEffect} |
I think you have a mix of effects here, but I believe that you are just requesting ConcurrentEffect
for the client resource usage.
path = path | ||
) | ||
case None => | ||
Async[F].raiseError[File]( |
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.
Async[F].raiseError[File]( | |
ConcurrentEffect[F].raiseError[File]( |
) | ||
} | ||
} yield file | ||
}) |
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.
You will need to replace the Sync[F]
below by ConcurrentEffect[F]
(writeTempFile
function).
* @param version optional protocol version number | ||
* @return a protocol | ||
*/ | ||
def retrieveProtocol(identifier: String, version: Option[Int]): F[Option[RawProtocol]] |
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.
Should we make the version a String or something, in anticipation of higherkindness/compendium#284 ?
) | ||
|
||
lazy val muSrcGenCompendiumServerUrl: SettingKey[String] = | ||
settingKey[String]("Url of the compendium server. By default, `http://localhost:47047`.") |
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.
settingKey[String]("Url of the compendium server. By default, `http://localhost:47047`.") | |
settingKey[String]("Url of the compendium server. By default, `https://localhost:47047`.") |
project/ProjectPlugin.scala
Outdated
@@ -17,13 +17,15 @@ object ProjectPlugin extends AutoPlugin { | |||
lazy val V = new { | |||
val avrohugger: String = "1.0.0-RC22" | |||
val circe: String = "0.13.0" | |||
val hammock = "0.10.0" |
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.
val hammock = "0.10.0" |
muSrcGenStreamingImplementation := Fs2Stream, | ||
muSrcGenExecutionMode := Local, | ||
muSrcGenCompendiumProtocolIdentifiers := Nil, | ||
muSrcGenCompendiumServerUrl := "https://localhost:47047" |
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.
Is the server likely to use HTTPS if it's running on localhost?
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.
ok, just checked aaaand nop. At least not by default 😞
) | ||
|
||
lazy val muSrcGenCompendiumServerUrl: SettingKey[String] = | ||
settingKey[String]("Url of the compendium server. By default, `https://localhost:47047`.") |
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.
settingKey[String]("Url of the compendium server. By default, `https://localhost:47047`.") | |
settingKey[String]("Url of the compendium server. By default, `http://localhost:47047`.") |
muSrcGenStreamingImplementation := Fs2Stream, | ||
muSrcGenExecutionMode := Local, | ||
muSrcGenCompendiumProtocolIdentifiers := Nil, | ||
muSrcGenCompendiumServerUrl := "https://localhost:47047" |
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.
muSrcGenCompendiumServerUrl := "https://localhost:47047" | |
muSrcGenCompendiumServerUrl := "http://localhost:47047" |
case Status.InternalServerError => | ||
Sync[F].raiseError(UnknownError(s"Error in compendium server")) | ||
case _ => | ||
Sync[F].raiseError(UnknownError(s"Unknown error with status code ${res.status.code}")) |
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.
case Status.InternalServerError => | |
Sync[F].raiseError(UnknownError(s"Error in compendium server")) | |
case _ => | |
Sync[F].raiseError(UnknownError(s"Unknown error with status code ${res.status.code}")) | |
case s => Sync[F].raiseError(UnexpectedStatus(s)) |
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.
ConcurrentEffect[F].raiseError[File]( | ||
ProtocolNotFound(s"Protocol ${protocolAndVersion.name} not found in Compendium. ") | ||
) |
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.
ConcurrentEffect[F].raiseError[File]( | |
ProtocolNotFound(s"Protocol ${protocolAndVersion.name} not found in Compendium. ") | |
) | |
ProtocolNotFound(s"Protocol ${protocolAndVersion.name} not found in Compendium. ") | |
.raiseError[F, File] |
Issue related: https://github.com/47deg/marlow/issues/635