This file contains hidden or 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
Reader compatibility type | Intuition | Writer changes allowed | Writer changes forbidden | |
---|---|---|---|---|
'BACKWARD' | Clients can keep decoding the responses for their requests | Add fields & Delete optional fields & Shrink types | Delete fields & Widen types |
This file contains hidden or 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
"DateTimeInterval.relate" should { | |
"return Disjoint" in new Fixture { | |
val a = "+---+ " | |
val b = " +--+" | |
a.relateTo(b) shouldBe Disjoint | |
b.relateTo(a) shouldBe Disjoint | |
} | |
"return IncludedBy and Includes" in new Fixture { | |
val a = " +-------+ " |
This file contains hidden or 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
builder | |
.startSystemDependent(SomeEtcdService()) | |
.thenStartHttp( | |
HttpServiceDefinition( | |
new AkkaControllers().routes, | |
serverConfig.host, | |
serverConfig.port, | |
serverConfig.hardDeadline, | |
serverConfig.unbindingDelay | |
) |
This file contains hidden or 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
def getBlocksForResource[F[_, _]: BifunctorMonadError: Bilogger] | |
(resourceID: ResourceID, timeFilter: TimeFilter) | |
(implicit resourceRepo: ResourceRepo[F], blockRepo: BlockRepo[F]): F[ResourceBlockError, List[Block]] = | |
(for { | |
resource <- resourceRepo.get(resourceID) | |
blocks <- blockRepo.blocksForResource(resource, timeFilter) | |
_ <- F.info(show"Successfully generated ${blocks.size} blocks for resource $resourceID in interval $timeFilter") | |
} yield blocks).onLeft { | |
case repositoryError: RepositoryError => F.error(repositoryError.message) | |
case blockError: BlockError => F.error(blockError.message) |
This file contains hidden or 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
implicit class RichLazyStringList(list: LazyList[String]) { | |
def productWith(other: LazyList[String]): LazyList[String] = | |
for { | |
a <- list | |
b <- other | |
} yield a + b | |
} | |
LazyList | |
.from(1) |
This file contains hidden or 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
trait Service extends Stoppable[Either[E, Unit]] { | |
def start(): Future[E, Unit] | |
def name: String | |
} |
This file contains hidden or 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
def stopService(service: Service): Task[Either[ServiceStopError, Service]] = | |
Task.deferFuture { | |
service.triggerStop() | |
service.stopped.map(_.map(_ => service)) | |
}.timeout(duration).onErrorRecover { | |
case _: TimeoutException => ServiceStopTimeoutError(service, duration).asLeft | |
} |
This file contains hidden or 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
object CoordinatedShutdownHttpHelpers { | |
implicit class FluentHttpCoordinatedShutdown(coordinatedShutdown: CoordinatedShutdown)( | |
implicit val system: ActorSystem | |
) { | |
private implicit val executionContext: ExecutionContext = system.dispatcher | |
def addHttpBinding( | |
binding: Http.ServerBinding, | |
pendingRequestsHardDeadline: FiniteDuration, | |
unbindingDelay: FiniteDuration |
This file contains hidden or 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
import scala.concurrent.{ ExecutionContext, Future, Promise } | |
/** | |
* Stoppable[T]: represents a process with a | |
* termination function of type `T` | |
*/ | |
trait Stoppable[T] { | |
protected implicit def executionContext: ExecutionContext | |
private val stoppedPromise = Promise[T]() | |
private val stopTriggeredPromise = Promise[Unit]() |
This file contains hidden or 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
implicit class FluentCoordinatedShutdown(coordinatedShutdown: CoordinatedShutdown) { | |
/** | |
* The first pre-defined phase that applications can add tasks to. | |
*/ | |
def beforeServiceUnbind(task: () => Future[Done], name: String): CoordinatedShutdown = | |
withTask(CoordinatedShutdown.PhaseBeforeServiceUnbind, task, name) | |
/** | |
* Stop accepting new incoming connections. |