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
package flake | |
import java.math.BigInteger | |
import java.nio.ByteBuffer | |
import java.util | |
import java.util.Base64 | |
import java.util.concurrent.atomic.AtomicReference | |
/** UUID in 'flake' format. | |
* <p>Flake ids are 128-bits wide described here from most significant to least significant bits. |
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
implicit object TaskAsync extends korolev.Async[Task] { | |
override def pureStrict[A](value: A): Task[A] = Task.now(value) | |
override def pure[A](value: => A): Task[A] = Task.now(value) | |
override def fork[A](value: => A): Task[A] = Task(value) | |
override def unit: Task[Unit] = Task.unit | |
override def fromTry[A](value: => Try[A]): Task[A] = Task.fromTry(value) | |
override def promise[A]: korolev.Async.Promise[Task, A] = { | |
val promise = scala.concurrent.Promise[A]() | |
korolev.Async.Promise(Task.fromFuture(promise.future), a => { promise.complete(a); () }) | |
} |
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
import cats.implicits._ | |
object CollectFirstM { | |
implicit class CollectFirstMSyntax[F[_], A](val xs: Seq[A]) extends AnyVal { | |
def collectFirstM[B, M[_]](f: A => M[Option[B]])(implicit M: Monad[M]): M[Option[B]] = | |
M.tailRecM(xs) { | |
case x +: rest => f(x).map { | |
case some@Some(_) => Right(some) |
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
import java.util.concurrent.atomic.AtomicReference | |
import java.util.function.UnaryOperator | |
import org.reactivestreams.{Publisher, Subscriber, Subscription} | |
import scala.concurrent.ExecutionContext.Implicits.global | |
import scala.concurrent.Future | |
import scala.util.control.NonFatal | |
class AsyncPublisher[T](next: () => Future[Option[T]], |
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
import cats.{Monad, StackSafeMonad} | |
import cats.effect.{IO, LiftIO} | |
trait Session { | |
def close(): Unit | |
} | |
case class SessionContext[T](exec: Session => IO[T]) { | |
def runSession(newSession: () => Session): IO[T] = { |
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
import org.reactivestreams.{Publisher, Subscriber, Subscription} | |
import scala.util.control.NonFatal | |
/** Iterator-based Reactive Streams publisher. | |
* @param iterator iterator | |
* @param onDone done callback */ | |
class CloseableIteratorPublisher[T](iterator: Iterator[T], onDone: () => Unit) | |
extends Publisher[T] { |
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
package com.rms.miu.common.db.slick | |
import java.time.{Duration, LocalDateTime} | |
import cats.{Monad, ~>} | |
object simple { | |
object common { |
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
package io.treev.eventsourcing | |
import cats.data.Xor | |
import enumeratum.{CirceEnum, Enum, EnumEntry} | |
import io.circe.Encoder | |
import io.circe.generic.auto._ | |
import io.treev.eventsourcing.model.Context | |
import io.treev.model._ | |
import monix.eval.Task |
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
package io.treev.common.util | |
import java.math.BigInteger | |
import java.net.NetworkInterface | |
import java.nio.ByteBuffer | |
import java.util | |
import java.util.Base64 | |
import java.util.concurrent.atomic.AtomicReference | |
/** UUID in 'flake' format. |