未验证 提交 3792875d 编写于 作者: D Dejan Mijić 提交者: GitHub

Ensure naming consistency (#791)

上级 e49ea4aa
......@@ -18,11 +18,11 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v3.3.0
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v3.9.0
with:
distribution: temurin
java-version: 17
......@@ -41,11 +41,11 @@ jobs:
if: ${{ ((github.event_name == 'release') && (github.event.action == 'published')) || (github.event_name == 'workflow_dispatch') }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v3.3.0
with:
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v3.9.0
with:
distribution: temurin
java-version: 17
......@@ -65,12 +65,12 @@ jobs:
if: ${{ (github.event_name == 'push') || ((github.event_name == 'release') && (github.event.action == 'published')) }}
steps:
- name: Git Checkout
uses: actions/checkout@v3.5.0
uses: actions/checkout@v3.3.0
with:
ref: ${{ github.head_ref }}
fetch-depth: '0'
- name: Setup Scala
uses: actions/setup-java@v3.11.0
uses: actions/setup-java@v3.9.0
with:
distribution: temurin
java-version: 17
......
......@@ -23,7 +23,7 @@ import scala.util.control.NoStackTrace
sealed trait ApiError extends NoStackTrace { self =>
import ApiError._
final def toResponse: Response =
final def asResponse: Response =
self match {
case CorruptedData | GithubUnreachable => Response.fromHttpError(HttpError.InternalServerError())
case CacheMiss(key) => Response.fromHttpError(HttpError.NotFound((Path.empty / key).encode))
......
......@@ -26,7 +26,7 @@ object Api {
Http.collectZIO { case Method.GET -> !! / "repositories" / owner / name / "contributors" =>
ZIO
.serviceWithZIO[ContributorsCache](_.fetchAll(Repository(Owner(owner), Name(name))))
.mapBoth(_.toResponse, r => Response.json(r.toJson))
.mapBoth(_.asResponse, r => Response.json(r.toJson))
.merge
}
}
......@@ -47,7 +47,7 @@ final class ClusterExecutor private (
def executeSafe(keySlot: Slot) = {
val recover = execute(keySlot).flatMap {
case e: RespValue.Error => ZIO.fail(e.toRedisError)
case e: RespValue.Error => ZIO.fail(e.asRedisError)
case success => ZIO.succeed(success)
}.catchSome {
case e: RedisError.Ask => executeAsk(e.address)
......
......@@ -32,7 +32,7 @@ sealed trait Output[+A] { self =>
private[redis] final def unsafeDecode(respValue: RespValue): A =
respValue match {
case error: RespValue.Error => throw error.toRedisError
case error: RespValue.Error => throw error.asRedisError
case success => tryDecode(success)
}
}
......
......@@ -45,13 +45,13 @@ private[redis] object RespCommandArgument {
}
final case class Key(bytes: Chunk[Byte]) extends RespCommandArgument {
lazy val value: RespValue.BulkString = RespValue.BulkString(bytes)
lazy val asCRC16: Int = {
val betweenBraces = bytes.dropWhile(b => b != '{').drop(1).takeWhile(b => b != '}')
val key = if (betweenBraces.isEmpty) bytes else betweenBraces
CRC16.get(key)
}
lazy val value: RespValue.BulkString = RespValue.BulkString(bytes)
}
object Key {
......
......@@ -51,7 +51,7 @@ private[redis] object RespValue {
final case class SimpleString(value: String) extends RespValue
final case class Error(value: String) extends RespValue {
def toRedisError: RedisError =
def asRedisError: RedisError =
if (value.startsWith("ERR")) RedisError.ProtocolError(value.drop(3).trim)
else if (value.startsWith("WRONGTYPE")) RedisError.WrongType(value.drop(9).trim)
else if (value.startsWith("BUSYGROUP")) RedisError.BusyGroup(value.drop(9).trim)
......@@ -72,9 +72,9 @@ private[redis] object RespValue {
final case class Integer(value: Long) extends RespValue
final case class BulkString(value: Chunk[Byte]) extends RespValue {
private[redis] def asString: String = decode(value)
def asLong: Long = internal.unsafeReadLong(asString, 0)
private[redis] def asLong: Long = internal.unsafeReadLong(asString, 0)
def asString: String = decode(value)
}
final case class Array(values: Chunk[RespValue]) extends RespValue
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册