Skip to content

Commit

Permalink
use screaming snake case for path vars
Browse files Browse the repository at this point in the history
  • Loading branch information
himadieievsv committed Feb 5, 2024
1 parent 43f9adb commit 2e76397
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package com.himadieiev.redpulsar.core.common

import com.himadieiev.redpulsar.core.locks.abstracts.Backend

const val removeLockScriptPath = "lua/RemoveLockScript.lua"
const val setSemaphoreLockScriptPath = "lua/SetSemaphoreLockScript.lua"
const val cleanUpExpiredSemaphoreLocksScriptPath = "lua/CleanUpExpiredSemaphoreLocksScript.lua"
const val countDownLatchCountScriptPath = "lua/CountDownLatchCountScript.lua"
const val REMOVE_LOCK_SCRIPT_PATH = "lua/RemoveLockScript.lua"
const val SET_SEMAPHORE_LOCK_SCRIPT_PATH = "lua/SetSemaphoreLockScript.lua"
const val CLEAN_UP_EXPIRED_SEMAPHORE_LOCKS_SCRIPT_PATH = "lua/CleanUpExpiredSemaphoreLocksScript.lua"
const val COUNT_DOWN_LATCH_COUNT_SCRIPT_PATH = "lua/CountDownLatchCountScript.lua"

fun Backend.loadScript(scriptPath: String): String {
val resourceStream =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.himadieiev.redpulsar.jedis.locks.backends

import com.himadieiev.redpulsar.core.common.countDownLatchCountScriptPath
import com.himadieiev.redpulsar.core.common.COUNT_DOWN_LATCH_COUNT_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.loadScript
import com.himadieiev.redpulsar.core.locks.abstracts.backends.CountDownLatchBackend
import com.himadieiev.redpulsar.core.utils.failsafe
Expand All @@ -25,7 +25,7 @@ internal class JedisCountDownLatchBackend(private val jedis: UnifiedJedis) : Cou
initialCount: Int,
ttl: Duration,
): String? {
val luaScript = loadScript(countDownLatchCountScriptPath)
val luaScript = loadScript(COUNT_DOWN_LATCH_COUNT_SCRIPT_PATH)
return failsafe(null) {
convertToString(
jedis.eval(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.himadieiev.redpulsar.jedis.locks.backends

import com.himadieiev.redpulsar.core.common.cleanUpExpiredSemaphoreLocksScriptPath
import com.himadieiev.redpulsar.core.common.CLEAN_UP_EXPIRED_SEMAPHORE_LOCKS_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.REMOVE_LOCK_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.SET_SEMAPHORE_LOCK_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.loadScript
import com.himadieiev.redpulsar.core.common.removeLockScriptPath
import com.himadieiev.redpulsar.core.common.setSemaphoreLockScriptPath
import com.himadieiev.redpulsar.core.locks.abstracts.backends.LocksBackend
import com.himadieiev.redpulsar.core.utils.failsafe
import redis.clients.jedis.UnifiedJedis
Expand All @@ -27,7 +27,7 @@ internal class JedisLocksBackend(private val jedis: UnifiedJedis) : LocksBackend
resourceName: String,
clientId: String,
): String? {
val luaScript = loadScript(removeLockScriptPath)
val luaScript = loadScript(REMOVE_LOCK_SCRIPT_PATH)
return failsafe(null) {
convertToString(jedis.eval(luaScript, listOf(resourceName), listOf(clientId)))
}
Expand All @@ -40,7 +40,7 @@ internal class JedisLocksBackend(private val jedis: UnifiedJedis) : LocksBackend
maxLeases: Int,
ttl: Duration,
): String? {
val luaScript = loadScript(setSemaphoreLockScriptPath)
val luaScript = loadScript(SET_SEMAPHORE_LOCK_SCRIPT_PATH)
return failsafe(null) {
convertToString(
jedis.eval(
Expand Down Expand Up @@ -71,7 +71,7 @@ internal class JedisLocksBackend(private val jedis: UnifiedJedis) : LocksBackend
leasersKey: String,
leaserValidityKeyPrefix: String,
): String? {
val luaScript = loadScript(cleanUpExpiredSemaphoreLocksScriptPath)
val luaScript = loadScript(CLEAN_UP_EXPIRED_SEMAPHORE_LOCKS_SCRIPT_PATH)
return failsafe(null) {
convertToString(jedis.eval(luaScript, listOf(leasersKey), listOf(leaserValidityKeyPrefix)))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.himadieiev.redpulsar.lettuce.locks.backends

import com.himadieiev.redpulsar.core.common.countDownLatchCountScriptPath
import com.himadieiev.redpulsar.core.common.COUNT_DOWN_LATCH_COUNT_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.loadScript
import com.himadieiev.redpulsar.core.locks.abstracts.backends.CountDownLatchBackend
import com.himadieiev.redpulsar.core.utils.failsafe
Expand All @@ -27,7 +27,7 @@ internal class LettuceCountDownLatchBackend(private val redis: LettucePubSubPool
initialCount: Int,
ttl: Duration,
): String? {
val luaScript = loadScript(countDownLatchCountScriptPath)
val luaScript = loadScript(COUNT_DOWN_LATCH_COUNT_SCRIPT_PATH)
return failsafe(null) {
convertToString(
redis.sync { sync ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.himadieiev.redpulsar.lettuce.locks.backends

import com.himadieiev.redpulsar.core.common.cleanUpExpiredSemaphoreLocksScriptPath
import com.himadieiev.redpulsar.core.common.CLEAN_UP_EXPIRED_SEMAPHORE_LOCKS_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.REMOVE_LOCK_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.SET_SEMAPHORE_LOCK_SCRIPT_PATH
import com.himadieiev.redpulsar.core.common.loadScript
import com.himadieiev.redpulsar.core.common.removeLockScriptPath
import com.himadieiev.redpulsar.core.common.setSemaphoreLockScriptPath
import com.himadieiev.redpulsar.core.locks.abstracts.backends.LocksBackend
import com.himadieiev.redpulsar.core.utils.failsafe
import com.himadieiev.redpulsar.lettuce.LettucePooled
Expand All @@ -30,7 +30,7 @@ internal class LettuceLocksBackend(private val redis: LettucePooled<String, Stri
resourceName: String,
clientId: String,
): String? {
val luaScript = loadScript(removeLockScriptPath)
val luaScript = loadScript(REMOVE_LOCK_SCRIPT_PATH)
return failsafe(null) {
convertToString(
redis.sync { sync -> sync.eval(luaScript, ScriptOutputType.INTEGER, arrayOf(resourceName), clientId) },
Expand All @@ -45,7 +45,7 @@ internal class LettuceLocksBackend(private val redis: LettucePooled<String, Stri
maxLeases: Int,
ttl: Duration,
): String? {
val luaScript = loadScript(setSemaphoreLockScriptPath)
val luaScript = loadScript(SET_SEMAPHORE_LOCK_SCRIPT_PATH)
return failsafe(null) {
convertToString(
redis.sync { sync ->
Expand Down Expand Up @@ -80,7 +80,7 @@ internal class LettuceLocksBackend(private val redis: LettucePooled<String, Stri
leasersKey: String,
leaserValidityKeyPrefix: String,
): String? {
val luaScript = loadScript(cleanUpExpiredSemaphoreLocksScriptPath)
val luaScript = loadScript(CLEAN_UP_EXPIRED_SEMAPHORE_LOCKS_SCRIPT_PATH)
return failsafe(null) {
convertToString(
redis.sync { sync ->
Expand Down

0 comments on commit 2e76397

Please sign in to comment.