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 aecor.data | |
import aecor.data.ActionT.{ActionFailure, ActionResult} | |
import cats.data._ | |
import cats.implicits._ | |
import cats.{Applicative, Functor, Monad, ~>} | |
final class ActionT[F[_], S, E, R, A] private ( | |
val unsafeRun: (S, (S, E) => Folded[S], Chain[E]) => F[ActionResult[R, E, A]] | |
) extends AnyVal { |
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._ | |
import cats.{ Applicative, Monad } | |
// Операции над контекстом | |
trait ContextWriter[F[_]] { | |
def put(key: String, value: String): F[Unit] | |
} | |
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
// Tagless Encoding | |
trait Counter[F[_]] { | |
def increment(value: Int): F[Unit] | |
def decrement(value: Int): F[Unit] | |
def value: F[Int] | |
} | |
// Free Encoding |
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.Applicative | |
import cats.effect.Sync | |
import com.evotor.common.logging.Logger.Level | |
import org.slf4j.LoggerFactory | |
import scala.reflect.ClassTag | |
trait Logger[F[_]] { | |
def log(level: Level.Value, msg: => String, throwable: Throwable): F[Unit] |
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.data.EitherT | |
import cats.effect.Timer | |
import cats.implicits._ | |
import cats.{ApplicativeError, Foldable, Functor, Monad, MonadError} | |
import scala.concurrent.duration.FiniteDuration | |
trait Observable[F[_], A] { outer => | |
def subscribe[O](observer: Observer[F, A, O]): F[O] | |
final def foldLeft[O](o: O)(f: (O, A) => O)( |
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 | |
import java.util.{Collections, UUID} | |
import cats.effect.{Async, Timer} | |
import io.evotor.webhooks.common.Committable | |
import fs2._ | |
import org.apache.kafka.clients.consumer._ | |
import org.apache.kafka.common.TopicPartition | |
import org.apache.kafka.common.serialization.Deserializer | |
import scala.concurrent.blocking |
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
// Tired of subtyping and `extends Product with Serializable`? | |
// It is impossible to instantiate a concrete subtype of `Root` | |
// It preserves pattern matching exhaustiveness check | |
sealed abstract class Root | |
object Root { | |
private final case class LeafInt(i: Int) extends Root | |
object LeafInt { def apply(i: Int): Root = new LeafInt(i) } | |
private final case class LeafString(s: String) extends Root | |
object LeafString { def apply(s: String): Root = new LeafString(s) } |
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
object Cache { | |
def apply[A, B](ttl: FiniteDuration)(f: A => Task[B]): A => Task[B] = { | |
val mvar = MVar(Map.empty[A, B]) | |
a => | |
for { | |
cached <- mvar.read.map(_.get(a)) | |
out <- cached match { | |
case Some(b) => Task.pure(b) | |
case None => | |
for { |
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
#!/bin/bash | |
app=$1 | |
chosen_one=$(kubectl get pods -l app=$app | tail -1 | awk '{print $1}') | |
echo "Keeping alive $chosen_one" | |
while true; do | |
pods=$(kubectl get pods -l app=$app | tail -n +2 | awk '{print $1}') | |
for pod in $pods; do |
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
#!/bin/bash | |
working_dir="$( cd "$1" && pwd )" | |
chart_name=$(basename $(pwd)) | |
unamestr=$(uname) | |
if [[ "$unamestr" == 'Darwin' ]]; then | |
sha='shasum' | |
elif [[ "$unamestr" == 'Linux' ]]; then | |
sha='sha1sum' |