Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
package zio | |
case class ZKleisli[-R, +E, -A, +B]( | |
run: A => ZIO[R, E, B] | |
) { self => | |
// compose with a ZIO not lifted into a Kleisli | |
def mapZIO[R1 <: R, E1 >: E, A1 <: A, C1](bc: B => ZIO[R1, E1, C1]): ZKleisli[R1, E1, A, C1] = | |
ZKleisli(self.run(_).flatMap(bc)) | |
// Modify the output of the Kleisli function with `f` |
import cats.{Applicative, Functor} | |
import cats.syntax.all._ | |
/** Is this the proper Scala encoding for the Haskell snippet in comments ? */ | |
/** from : https://doisinkidney.com/pdfs/algebras-for-weighted-search.pdf */ | |
/** with help from @Odomontois */ | |
// newtype Cayley f a = Cayley {runC :: ∀b. f b → f (a, b) } | |
trait Cayley[F[_], A] { |
import cats.{ Applicative, Functor } | |
import cats.syntax.all._ | |
/** Is this the proper Scala encoding for the Haskell snippet in comments ? */ | |
/** from : https://doisinkidney.com/pdfs/algebras-for-weighted-search.pdf */ | |
// newtype Cayley f a = Cayley {runC :: ∀b. f b → f (a, b) } | |
sealed trait Cayley[F[_], A] { | |
def apply[B](fb: F[B]): F[(A, B)] | |
} |
package interview | |
object DominoInterview extends App { | |
/** | |
|1|2|3| | |
|4|5|6| | |
|7|8|9| | |
|*|0|#| | |
Problem: |
// Inspired by a tweet from @trautonen 1/13/2016 | |
// Use Source.unfoldAsync to turn paginated database results into an akka-streams Source | |
// unfold is the inverse of fold | |
case class Page[T](pageNumber:Long, totalPages:Long, contents:List[T]) | |
case class Thing(id: Long, name: String = "foo") | |
val totalPages = 5 // | |
val pageSize = 3 |
import org.scalatest._ | |
import org.scalatest.concurrent.ScalaFutures | |
import scala.concurrent.Future | |
// from https://github.com/d6y/scalatest-future-failure/blob/master/src/test/scala/example.scala | |
class ExampleSpec extends FlatSpec with Matchers with ScalaFutures { | |
sealed trait Boom extends Throwable | |
final case class ExampleFail() extends Boom |
import * as pulumi from '@pulumi/pulumi'; | |
import * as gcp from '@pulumi/gcp'; | |
import * as k8s from '@pulumi/kubernetes'; | |
import * as k8sInputApi from '@pulumi/kubernetes/types/input'; | |
const serviceAccountKeys = new Map<string, gcp.serviceAccount.Key>(); | |
/** | |
* Creates a service account and key, and sets the cloudsql.client role in IAM. | |
*/ |
import java.net.URI | |
import cats.effect._ | |
object Main extends IOApp { | |
override def run(args: List[String]): IO[ExitCode] = | |
RedisClient.makeWithURI[IO](new URI("http://localhost:6379")).use { cmd => | |
import cmd._ | |
val result = for { |
import cats.data.ValidatedNec | |
import cats.implicits._ | |
import eu.timepit.refined._ | |
import eu.timepit.refined.api.Refined | |
import eu.timepit.refined.auto._ | |
import eu.timepit.refined.numeric._ | |
import eu.timepit.refined.collection._ | |
object person { |