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
{ | |
"curly4s": { | |
"repositories": [ | |
"central" | |
], | |
"dependencies": [ | |
"io.chrisdavenport::curly4s:latest.release" | |
] | |
}, | |
"shellserve": { |
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
// https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-ratelimit-headers | |
trait RateLimiter[F[_], K]{ | |
def get(id: K): F[RateLimit] | |
def getAndDecrement(id: K): F[RateLimit] | |
def rateLimit(id: K): F[RateLimit] // Fails Request at this step, to be handled to 429 Too Many Requests and include a RetryAfter header | |
} | |
case class QuotaComment(token: String, value: Either[Long, String]) | |
case class QuotaPolicy(limit: Long, timeWindowSeconds: Long, comments: List[QuotaComment]) |
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 cats.syntax.all._ | |
import org.typelevel.keypool._ | |
import io.chrisdavenport.mapref._ | |
import scala.concurrent.duration._ | |
import cats.effect.kernel._ | |
import scala.collection.immutable.Queue | |
object KeypoolAdvanced { |
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 cats.syntax.all._ | |
object EmojiEncoding { | |
private val range_min = 127744 | |
private val range_max = 129782 | |
private val range_min_2 = 126980 | |
private val range_max_2 = 127569 | |
private val range_min_3 = 169 |
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 cats._ | |
import cats.syntax.all._ | |
import cats.data.Kleisli | |
import cats.effect._ | |
import cats.effect.syntax._ | |
import cats.effect.kernel.Outcome.Canceled | |
import cats.effect.kernel.Outcome.Errored | |
import cats.effect.kernel.Outcome.Succeeded | |
import java.util.concurrent.CancellationException |
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 cats._ | |
import cats.syntax.all._ | |
import cats.data._ | |
import cats.effect._ | |
import cats.effect.syntax.all._ | |
import cats.effect.std.Semaphore | |
trait Lock[F[_]]{ self => | |
def lock: F[Unit] | |
def unlock: F[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
object Test extends ResourceApp.Simple { | |
def run = for { | |
ep <- Jaeger.entryPoint("server")(_ => IO(Configuration.fromEnv().getTracerBuilder().build())) | |
root <- ep.root("run") | |
ioLocal <- Resource.eval(IOLocal(root)) | |
trace = MyTrace.fromIOLocal(ioLocal) | |
spanning = MyServer.ioTraceOverride(ep, ioLocal) | |
_ <- MyServer.inF(spanning)(Async[IO], trace) | |
} yield () |
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 Test extends ResourceApp.Simple { | |
def run = for { | |
ep <- Resource.eval( | |
Jaeger.globalTracerEntryPoint[IO](None).flatMap(_.toRight(new Throwable("No Global")).liftTo[IO]) | |
) | |
root <- ep.root("run") | |
fiberLocal <- Resource.eval(GenFiberLocal[IO].local(root)) | |
trace = MyTrace.fromFiberLocal(fiberLocal) | |
spanning = MyServer.myMiddleware(ep, fiberLocal) |
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 FiberLocal[F[_], A]{ | |
def get: F[A] | |
def set(value: A): F[Unit] | |
def reset: F[Unit] | |
def update(f: A => A): F[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
object EmberRetryFix { | |
import cats.syntax.all._ | |
import scala.concurrent.duration._ | |
import org.http4s._ | |
import org.http4s.client._ | |
import org.http4s.ember.core.EmberException | |
import org.http4s.client.middleware._ | |
import org.http4s.headers.`Idempotency-Key` | |