-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use builder syntax for configuration (#25)
- Loading branch information
Showing
4 changed files
with
52 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
core/src/main/scala/org/ivovk/connect_rpc_scala/Configuration.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.ivovk.connect_rpc_scala | ||
|
||
import cats.Endo | ||
import io.grpc.{ManagedChannelBuilder, ServerBuilder} | ||
import scalapb.json4s.Printer | ||
|
||
import scala.concurrent.duration.* | ||
|
||
object Configuration { | ||
val default: Configuration = Configuration() | ||
} | ||
|
||
case class Configuration private( | ||
jsonPrinterConfigurator: Endo[Printer] = identity, | ||
serverBuilderConfigurator: Endo[ServerBuilder[_]] = identity, | ||
channelBuilderConfigurator: Endo[ManagedChannelBuilder[_]] = identity, | ||
waitForShutdown: Duration = 5.seconds, | ||
) { | ||
|
||
def withJsonPrinterConfigurator(jsonPrinterConfigurer: Endo[Printer]): Configuration = | ||
copy(jsonPrinterConfigurator = jsonPrinterConfigurer) | ||
|
||
def withServerBuilderConfigurator(serverBuilderConfigurer: Endo[ServerBuilder[_]]): Configuration = | ||
copy(serverBuilderConfigurator = serverBuilderConfigurer) | ||
|
||
def withChannelBuilderConfigurator(channelBuilderConfigurer: Endo[ManagedChannelBuilder[_]]): Configuration = | ||
copy(channelBuilderConfigurator = channelBuilderConfigurer) | ||
|
||
def withWaitForShutdown(waitForShutdown: Duration): Configuration = | ||
copy(waitForShutdown = waitForShutdown) | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters