core / pragma.utils /

Package pragma.utils #

Types #

NameSummary

AlertingMutex

open class AlertingMutex(name: String, locked: Boolean = false) : Mutex

AlertingMutex is an implementation of the Mutex interface that will log a warning if it cannot obtain a lock after 1 minute.

JumpHash

class JumpHash

Algorithm from: https://arxiv.org/ftp/arxiv/papers/1406/1406.2294.pdf.

MetrickingMutex

class MetrickingMutex(name: String, metricsManager: MetricsManager, timerProxyFactory: TimerProxyFactory = TimerProxyFactory(metricsManager), metricsTagName: String, locked: Boolean = false) : AlertingMutex

MetrickingMutex is an implementation of the Mutex interface that will log a warning and increment the "pragma.engine.mutex.waitingForLock" metric every 60s if it cannot obtain a lock.

MetrickingPragmaSemaphore

open class MetrickingPragmaSemaphore(initialPermits: Int, metricName: String, metricsManager: MetricsManager, loggerName: String, logger: Logger = LoggerFactory.getLogger("PragmaSemaphore-${loggerName}")) : PragmaSemaphore

A PragmaSemaphore that registers a metrics gauge for getActiveAndWaitingBlockCount.

ProcessBuilderFactory

class ProcessBuilderFactory

Simple wrapper around ProcessBuilder to allow for dependency injection for testing.

Functions #

NameSummary

cancellationCheck

fun CoroutineContext.cancellationCheck(block: () -> Unit)

Checks the cancellation status of the coroutine context. If the coroutine context is active, this function is a no-op. If the coroutine context is cancelled, runs the block of code and throws a CancellationException. This block cannot contain suspend calls as it is only executed in the case of a cancelling coroutine.

fun CoroutineScope.cancellationCheck(block: () -> Unit)

Checks the cancellation status of the coroutine context. If the coroutine context is active, this function is a no-op. If the coroutine context is cancelled, it runs the block of code and throws a CancellationException. This block cannot contain suspend calls as it is only executed in the case of a cancelling coroutine.

receiveEncodedTextUsingIOContext

suspend fun ApplicationCall.receiveEncodedTextUsingIOContext(): String

Receive the request as a string.

removePrefixIgnoreCase

fun String.removePrefixIgnoreCase(prefix: CharSequence): String

If this string starts with the given prefix (ignoring case), returns a copy of this string with the prefix removed. Otherwise, returns this string.

removeSuffixIgnoreCase

fun String.removeSuffixIgnoreCase(suffix: CharSequence): String

If this string ends with the given suffix (ignoring case), returns a copy of this string with the suffix removed. Otherwise, returns this string.