mirror of
https://github.com/simplex-chat/simplexmq.git
synced 2026-04-25 09:52:18 +00:00
* disconnect inactive clients * update test description * use one thread per client to disconnect inactive clients * remove comments * more comments
18 lines
541 B
Haskell
18 lines
541 B
Haskell
{-# LANGUAGE NamedFieldPuns #-}
|
|
|
|
module Simplex.Messaging.Server.Expiration where
|
|
|
|
import Control.Monad.IO.Class
|
|
import Data.Int (Int64)
|
|
import Data.Time.Clock.System (SystemTime (..), getSystemTime)
|
|
|
|
data ExpirationConfig = ExpirationConfig
|
|
{ -- time after which the entity can be expired, seconds
|
|
ttl :: Int64,
|
|
-- interval to check expiration, seconds
|
|
checkInterval :: Int
|
|
}
|
|
|
|
expireBeforeEpoch :: ExpirationConfig -> IO Int64
|
|
expireBeforeEpoch ExpirationConfig {ttl} = subtract ttl . systemSeconds <$> liftIO getSystemTime
|