orbit-util
Module Contents
alltypes
Module Contents
object
AnnotationUtils
Module Contents
fun
<
A
:
Annotation
>
findAnnotationInTree
(
clazz
:
Class
<
*
>
,
annotation
:
Class
<
A
>
)
:
A
?
fun
<
A
:
Annotation
>
isAnnotationInTree
(
clazz
:
Class
<
*
>
,
annotation
:
Class
<
A
>
)
:
Boolean
interface
AsyncMap
<
K
,
V
>
Module Contents
abstract
suspend
fun
compareAndSet
(
key
:
K
,
initialValue
:
V
?
,
newValue
:
V
?
)
:
Boolean
open
suspend
fun
count
(
)
:
Int
abstract
suspend
fun
entries
(
)
:
Iterable
<
Pair
<
K
,
V
>
>
abstract
suspend
fun
get
(
key
:
K
)
:
V
?
open
suspend
fun
getOrPut
(
key
:
K
,
block
:
suspend
(
)
->
V
)
:
V
open
suspend
fun
getValue
(
key
:
K
)
:
V
open
suspend
fun
manipulate
(
key
:
K
,
block
:
(
V
?
)
->
V
?
)
:
V
?
abstract
suspend
fun
remove
(
key
:
K
)
:
Boolean
abstract
suspend
fun
set
(
key
:
K
,
value
:
V
)
:
Unit
open
suspend
fun
values
(
)
:
List
<
V
>
class
Clock
Module Contents
Clock
(
)
fun
advanceTime
(
offset
:
TimeMs
)
:
Unit
val
currentTime
:
TimeMs
fun
inFuture
(
time
:
Timestamp
)
:
Boolean
fun
inPast
(
time
:
Timestamp
)
:
Boolean
fun
now
(
)
:
Instant
!
fun
nowOrPast
(
time
:
Timestamp
)
:
Boolean
fun
resetToNow
(
)
:
Unit
object
ClockUtils
Module Contents
fun
currentTimeMillis
(
)
:
Long
class
ComponentContainer
Module Contents
ComponentContainer
(
)
inline
fun
configure
(
config
:
ComponentContainerRoot
.
(
)
->
Unit
)
:
Unit
fun
<
T
>
construct
(
concreteClass
:
Class
<
out
T
>
)
:
T
fun
<
reified
T
>
construct
(
)
:
T
fun
<
reified
R
:
Any
>
inject
(
)
:
Lazy
<
R
>
fun
<
T
:
Any
>
register
(
type
:
Class
<
T
>
,
factory
:
(
ComponentContainer
)
->
T
)
:
Unit
data
class
Registration
<
T
>
Module Contents
Registration
(
type
:
Class
<
T
>
,
factory
:
(
ComponentContainer
)
->
T
)
val
factory
:
(
ComponentContainer
)
->
T
val
type
:
Class
<
T
>
fun
<
T
>
resolve
(
type
:
Class
<
T
>
)
:
T
fun
<
reified
R
:
Any
>
resolve
(
)
:
R
class
ComponentContainerRoot
Module Contents
ComponentContainerRoot
(
container
:
ComponentContainer
)
val
container
:
ComponentContainer
fun
<
reified
T
:
Any
>
externallyConfigured
(
config
:
ExternallyConfigured
<
T
>
)
:
Unit
fun
<
reified
T
:
Any
>
instance
(
instance
:
T
)
:
Unit
inline
fun
<
reified
T
:
Any
>
register
(
crossinline
body
:
(
ComponentContainer
)
->
T
)
:
Unit
inline
fun
<
reified
T
:
Any
>
register
(
crossinline
body
:
(
)
->
T
)
:
Unit
fun
<
reified
T
:
Any
>
resolve
(
)
:
T
fun
<
reified
T
:
Any
>
singleton
(
clazz
:
Class
<
out
T
>
)
:
Unit
fun
<
reified
T
:
Any
>
singleton
(
)
:
Unit
class
ConstantTicker
Module Contents
ConstantTicker
(
scope
:
CoroutineScope
,
targetTickRate
:
Long
,
clock
:
Clock
,
logger
:
KLogger
?
=
null
,
exceptionHandler
:
(
(
Throwable
)
->
Unit
)
?
=
null
,
autoStart
:
Boolean
=
false
,
onTick
:
suspend
(
)
->
Unit
,
onSlowTick
:
suspend
(
)
->
Unit
=
{}
)
fun
start
(
)
:
Unit
fun
stop
(
)
:
Unit
data
class
ElapsedAndResult
<
T
>
Module Contents
ElapsedAndResult
(
elapsed
:
TimeMs
,
result
:
T
)
val
elapsed
:
TimeMs
val
result
:
T
interface
ExternallyConfigured
<
T
>
Module Contents
abstract
val
instanceType
:
Class
<
out
T
>
abstract
class
HashMapBackedAsyncMap
<
K
,
V
>
:
AsyncMap
<
K
,
V
>
Module Contents
HashMapBackedAsyncMap
(
)
open
suspend
fun
compareAndSet
(
key
:
K
,
initialValue
:
V
?
,
newValue
:
V
?
)
:
Boolean
open
suspend
fun
entries
(
)
:
Iterable
<
Pair
<
K
,
V
>
>
open
suspend
fun
get
(
key
:
K
)
:
V
?
abstract
val
map
:
ConcurrentHashMap
<
K
,
V
>
open
suspend
fun
remove
(
key
:
K
)
:
Boolean
open
suspend
fun
set
(
key
:
K
,
value
:
V
)
:
Unit
io.micrometer.core.instrument.Timer
Module Contents
suspend
fun
<
R
>
Timer
.
recordSuspended
(
f
:
suspend
(
)
->
R
)
:
R
java.time.Instant
Module Contents
fun
Instant
.
toTimestamp
(
)
:
Timestamp
java.util.concurrent.atomic.AtomicReference
Module Contents
inline
fun
<
T
>
AtomicReference
<
T
>
.
atomicSet
(
crossinline
block
:
(
T
)
->
T
)
:
T
kotlin.collections.Collection
Module Contents
fun
<
E
>
Collection
<
E
>
.
randomOrNull
(
)
:
E
?
object
Pools
Module Contents
@JvmStatic
fun
createCachedPool
(
threadPrefix
:
String
)
:
CoroutineDispatcher
@JvmStatic
@JvmOverloads
fun
createFixedPool
(
threadPrefix
:
String
,
maxThreads
:
Int
=
defaultParallelism
)
:
CoroutineDispatcher
@JvmStatic
val
defaultParallelism
:
Int
class
RailWorker
<
T
>
Module Contents
RailWorker
(
scope
:
CoroutineScope
,
buffer
:
Int
=
10_000
,
railCount
:
Int
=
128
,
logger
:
KLogger
?
=
null
,
autoStart
:
Boolean
=
false
,
onMessage
:
suspend
(
T
)
->
Unit
)
val
isInitialized
:
Boolean
fun
offer
(
msg
:
T
)
:
Boolean
suspend
fun
send
(
msg
:
T
)
:
Unit
fun
startWorkers
(
)
:
Unit
fun
stopWorkers
(
)
:
Unit
class
RetriesExceededException
:
Exception
Module Contents
RetriesExceededException
(
msg
:
String
)
object
RNGUtils
Module Contents
fun
randomString
(
numChars
:
Int
=
16
,
random
:
Random
=
Random.Default
)
:
String
class
ShutdownLatch
Module Contents
ShutdownLatch
(
)
fun
acquire
(
)
:
Unit
fun
release
(
)
:
Unit
class
Stopwatch
Module Contents
val
elapsed
:
TimeMs
@JvmStatic
fun
start
(
clock
:
Clock
)
:
Stopwatch
class
SupervisorScope
:
CoroutineScope
Module Contents
SupervisorScope
(
pool
:
CoroutineDispatcher
,
exceptionHandler
:
(
CoroutineContext
,
Throwable
)
->
Unit
)
val
coroutineContext
:
CoroutineContext
typealias
TimeMs
=
Long
data
class
Timestamp
Module Contents
Timestamp
(
seconds
:
Long
,
nanos
:
Int
)
operator
fun
compareTo
(
timestamp
:
Timestamp
)
:
Int
fun
isAfter
(
time
:
Instant
)
:
Boolean
fun
isExactly
(
time
:
Instant
)
:
Boolean
val
nanos
:
Int
fun
now
(
)
:
Timestamp
val
seconds
:
Long
package
orbit.util.concurrent
Module Contents
interface
AsyncMap
<
K
,
V
>
Module Contents
abstract
suspend
fun
compareAndSet
(
key
:
K
,
initialValue
:
V
?
,
newValue
:
V
?
)
:
Boolean
open
suspend
fun
count
(
)
:
Int
abstract
suspend
fun
entries
(
)
:
Iterable
<
Pair
<
K
,
V
>
>
abstract
suspend
fun
get
(
key
:
K
)
:
V
?
open
suspend
fun
getOrPut
(
key
:
K
,
block
:
suspend
(
)
->
V
)
:
V
open
suspend
fun
getValue
(
key
:
K
)
:
V
open
suspend
fun
manipulate
(
key
:
K
,
block
:
(
V
?
)
->
V
?
)
:
V
?
abstract
suspend
fun
remove
(
key
:
K
)
:
Boolean
abstract
suspend
fun
set
(
key
:
K
,
value
:
V
)
:
Unit
open
suspend
fun
values
(
)
:
List
<
V
>
abstract
class
HashMapBackedAsyncMap
<
K
,
V
>
:
AsyncMap
<
K
,
V
>
Module Contents
HashMapBackedAsyncMap
(
)
open
suspend
fun
compareAndSet
(
key
:
K
,
initialValue
:
V
?
,
newValue
:
V
?
)
:
Boolean
open
suspend
fun
entries
(
)
:
Iterable
<
Pair
<
K
,
V
>
>
open
suspend
fun
get
(
key
:
K
)
:
V
?
abstract
val
map
:
ConcurrentHashMap
<
K
,
V
>
open
suspend
fun
remove
(
key
:
K
)
:
Boolean
open
suspend
fun
set
(
key
:
K
,
value
:
V
)
:
Unit
java.util.concurrent.atomic.AtomicReference
Module Contents
inline
fun
<
T
>
AtomicReference
<
T
>
.
atomicSet
(
crossinline
block
:
(
T
)
->
T
)
:
T
object
Pools
Module Contents
@JvmStatic
fun
createCachedPool
(
threadPrefix
:
String
)
:
CoroutineDispatcher
@JvmStatic
@JvmOverloads
fun
createFixedPool
(
threadPrefix
:
String
,
maxThreads
:
Int
=
defaultParallelism
)
:
CoroutineDispatcher
@JvmStatic
val
defaultParallelism
:
Int
class
RailWorker
<
T
>
Module Contents
RailWorker
(
scope
:
CoroutineScope
,
buffer
:
Int
=
10_000
,
railCount
:
Int
=
128
,
logger
:
KLogger
?
=
null
,
autoStart
:
Boolean
=
false
,
onMessage
:
suspend
(
T
)
->
Unit
)
val
isInitialized
:
Boolean
fun
offer
(
msg
:
T
)
:
Boolean
suspend
fun
send
(
msg
:
T
)
:
Unit
fun
startWorkers
(
)
:
Unit
fun
stopWorkers
(
)
:
Unit
class
ShutdownLatch
Module Contents
ShutdownLatch
(
)
fun
acquire
(
)
:
Unit
fun
release
(
)
:
Unit
class
SupervisorScope
:
CoroutineScope
Module Contents
SupervisorScope
(
pool
:
CoroutineDispatcher
,
exceptionHandler
:
(
CoroutineContext
,
Throwable
)
->
Unit
)
val
coroutineContext
:
CoroutineContext
package
orbit.util.di
Module Contents
class
ComponentContainer
Module Contents
ComponentContainer
(
)
inline
fun
configure
(
config
:
ComponentContainerRoot
.
(
)
->
Unit
)
:
Unit
fun
<
T
>
construct
(
concreteClass
:
Class
<
out
T
>
)
:
T
fun
<
reified
T
>
construct
(
)
:
T
fun
<
reified
R
:
Any
>
inject
(
)
:
Lazy
<
R
>
fun
<
T
:
Any
>
register
(
type
:
Class
<
T
>
,
factory
:
(
ComponentContainer
)
->
T
)
:
Unit
data
class
Registration
<
T
>
Module Contents
Registration
(
type
:
Class
<
T
>
,
factory
:
(
ComponentContainer
)
->
T
)
val
factory
:
(
ComponentContainer
)
->
T
val
type
:
Class
<
T
>
fun
<
T
>
resolve
(
type
:
Class
<
T
>
)
:
T
fun
<
reified
R
:
Any
>
resolve
(
)
:
R
class
ComponentContainerRoot
Module Contents
ComponentContainerRoot
(
container
:
ComponentContainer
)
val
container
:
ComponentContainer
fun
<
reified
T
:
Any
>
externallyConfigured
(
config
:
ExternallyConfigured
<
T
>
)
:
Unit
fun
<
reified
T
:
Any
>
instance
(
instance
:
T
)
:
Unit
inline
fun
<
reified
T
:
Any
>
register
(
crossinline
body
:
(
ComponentContainer
)
->
T
)
:
Unit
inline
fun
<
reified
T
:
Any
>
register
(
crossinline
body
:
(
)
->
T
)
:
Unit
fun
<
reified
T
:
Any
>
resolve
(
)
:
T
fun
<
reified
T
:
Any
>
singleton
(
clazz
:
Class
<
out
T
>
)
:
Unit
fun
<
reified
T
:
Any
>
singleton
(
)
:
Unit
interface
ExternallyConfigured
<
T
>
Module Contents
abstract
val
instanceType
:
Class
<
out
T
>
package
orbit.util.instrumentation
Module Contents
io.micrometer.core.instrument.Timer
Module Contents
suspend
fun
<
R
>
Timer
.
recordSuspended
(
f
:
suspend
(
)
->
R
)
:
R
package
orbit.util.misc
Module Contents
suspend
inline
fun
<
T
>
attempt
(
maxAttempts
:
Int
=
5
,
initialDelay
:
Long
=
1000
,
maxDelay
:
Long
=
Long.MAX_VALUE
,
factor
:
Double
=
1.0
,
logger
:
KLogger
?
=
null
,
body
:
(
)
->
T
)
:
T
kotlin.collections.Collection
Module Contents
fun
<
E
>
Collection
<
E
>
.
randomOrNull
(
)
:
E
?
class
RetriesExceededException
:
Exception
Module Contents
RetriesExceededException
(
msg
:
String
)
suspend
fun
<
T
>
retry
(
retryDelay
:
Duration
=
Duration.ZERO
,
attempts
:
Int
=
Int.MAX_VALUE
,
action
:
suspend
(
)
->
T
)
:
T
?
object
RNGUtils
Module Contents
fun
randomString
(
numChars
:
Int
=
16
,
random
:
Random
=
Random.Default
)
:
String
package
orbit.util.reflect
Module Contents
object
AnnotationUtils
Module Contents
fun
<
A
:
Annotation
>
findAnnotationInTree
(
clazz
:
Class
<
*
>
,
annotation
:
Class
<
A
>
)
:
A
?
fun
<
A
:
Annotation
>
isAnnotationInTree
(
clazz
:
Class
<
*
>
,
annotation
:
Class
<
A
>
)
:
Boolean
package
orbit.util.time
Module Contents
class
Clock
Module Contents
Clock
(
)
fun
advanceTime
(
offset
:
TimeMs
)
:
Unit
val
currentTime
:
TimeMs
fun
inFuture
(
time
:
Timestamp
)
:
Boolean
fun
inPast
(
time
:
Timestamp
)
:
Boolean
fun
now
(
)
:
Instant
!
fun
nowOrPast
(
time
:
Timestamp
)
:
Boolean
fun
resetToNow
(
)
:
Unit
object
ClockUtils
Module Contents
fun
currentTimeMillis
(
)
:
Long
class
ConstantTicker
Module Contents
ConstantTicker
(
scope
:
CoroutineScope
,
targetTickRate
:
Long
,
clock
:
Clock
,
logger
:
KLogger
?
=
null
,
exceptionHandler
:
(
(
Throwable
)
->
Unit
)
?
=
null
,
autoStart
:
Boolean
=
false
,
onTick
:
suspend
(
)
->
Unit
,
onSlowTick
:
suspend
(
)
->
Unit
=
{}
)
fun
start
(
)
:
Unit
fun
stop
(
)
:
Unit
data
class
ElapsedAndResult
<
T
>
Module Contents
ElapsedAndResult
(
elapsed
:
TimeMs
,
result
:
T
)
val
elapsed
:
TimeMs
val
result
:
T
@ExperimentalCoroutinesApi
fun
highResolutionTicker
(
ticksPerSecond
:
Double
,
scope
:
CoroutineScope
=
GlobalScope
)
:
ReceiveChannel
<
Unit
>
java.time.Instant
Module Contents
fun
Instant
.
toTimestamp
(
)
:
Timestamp
class
Stopwatch
Module Contents
val
elapsed
:
TimeMs
@JvmStatic
fun
start
(
clock
:
Clock
)
:
Stopwatch
inline
fun
<
T
>
stopwatch
(
clock
:
Clock
,
body
:
(
(
)
->
TimeMs
)
->
T
)
:
ElapsedAndResult
<
T
>
typealias
TimeMs
=
Long
data
class
Timestamp
Module Contents
Timestamp
(
seconds
:
Long
,
nanos
:
Int
)
operator
fun
compareTo
(
timestamp
:
Timestamp
)
:
Int
fun
isAfter
(
time
:
Instant
)
:
Boolean
fun
isExactly
(
time
:
Instant
)
:
Boolean
val
nanos
:
Int
fun
now
(
)
:
Timestamp
val
seconds
:
Long
fun
Timestamp
.
toInstant
(
)
:
Instant
!