Connection.scala 3.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
package zio.redis.options

import java.net.InetAddress

import zio.duration.Duration

trait Connection {

  sealed abstract class ClientType(val name: String)

  object ClientType {

    case object Master extends ClientType("master")

    case object Normal extends ClientType("normal")

    case object PubSub extends ClientType("pubsub")

    case object Replica extends ClientType("replica")

  }

  sealed trait ClientKillFilter

  object ClientKillFilter {

    sealed case class Address(ip: InetAddress, port: Int) extends ClientKillFilter

    sealed case class LocalAddress(ip: InetAddress, port: Int) extends ClientKillFilter

    sealed case class Id(id: Long) extends ClientKillFilter

    sealed case class Type(clientType: ClientType) extends ClientKillFilter

    sealed case class User(username: String) extends ClientKillFilter

    sealed case class SkipMe(skip: Boolean) extends ClientKillFilter

  }

  sealed trait ClientFlag

  object ClientFlag {
    case object ToBeClosedAsap              extends ClientFlag
    case object Blocked                     extends ClientFlag
    case object ToBeClosedAfterReply        extends ClientFlag
    case object WatchedKeysModified         extends ClientFlag
    case object IsMaster                    extends ClientFlag
    case object MonitorMode                 extends ClientFlag
    case object PubSub                      extends ClientFlag
    case object ReadOnlyMode                extends ClientFlag
    case object Replica                     extends ClientFlag
    case object Unblocked                   extends ClientFlag
    case object UnixDomainSocket            extends ClientFlag
    case object MultiExecContext            extends ClientFlag
    case object KeysTrackingEnabled         extends ClientFlag
    case object TrackingTargetClientInvalid extends ClientFlag
    case object BroadcastTrackingMode       extends ClientFlag
  }

L
Lachlan O'Dea 已提交
61
  sealed case class ClientEvents(readable: Boolean = false, writable: Boolean = false)
62 63 64

  sealed case class ClientInfo(
    id: Long,
L
Lachlan O'Dea 已提交
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    name: Option[String] = None,
    address: Option[InetAddress] = None,
    localAddress: Option[InetAddress] = None,
    fileDescriptor: Option[Long] = None,
    age: Option[Duration] = None,
    idle: Option[Duration] = None,
    flags: Set[ClientFlag] = Set.empty,
    databaseId: Option[Long] = None,
    subscriptions: Int = 0,
    patternSubscriptions: Int = 0,
    multiCommands: Int = 0,
    queryBufferLength: Option[Int] = None,
    queryBufferFree: Option[Int] = None,
    outputBufferLength: Option[Int] = None,
    outputListLength: Option[Int] = None,
    outputBufferMem: Option[Long] = None,
    events: ClientEvents = ClientEvents(),
    lastCommand: Option[String] = None,
    argvMemory: Option[Long] = None,
    totalMemory: Option[Long] = None,
    redirectionClientId: Option[Long] = None,
    user: Option[String] = None
87 88
  )

L
Lachlan O'Dea 已提交
89 90 91 92 93 94 95 96
  sealed abstract class ClientTrackingRedirect

  object ClientTrackingRedirect {
    case object NotEnabled                         extends ClientTrackingRedirect
    case object NotRedirected                      extends ClientTrackingRedirect
    sealed case class RedirectedTo(clientId: Long) extends ClientTrackingRedirect
  }

L
Lachlan O'Dea 已提交
97 98 99 100 101 102 103 104
  sealed abstract class ClientTrackingMode

  object ClientTrackingMode {
    case object OptIn     extends ClientTrackingMode
    case object OptOut    extends ClientTrackingMode
    case object Broadcast extends ClientTrackingMode
  }

105
}