Safe Haskell | None |
---|
All RPC calls are run within this monad.
It encapsulates:
- IO operations,
- failures,
- working with the daemon state.
Code that is specific either to the configuration or the lock management, should go into their corresponding dedicated modules.
Synopsis
- data DistributionTarget
- = Everywhere
- | ToGroups (Set String)
- data DaemonState = DaemonState {}
- dsTempResL :: Lens' DaemonState TempResState
- dsLockWaitingL :: Lens' DaemonState GanetiLockWaiting
- dsConfigStateL :: Lens' DaemonState ConfigState
- data DaemonHandle = DaemonHandle {
- dhDaemonState :: IORef DaemonState
- dhConfigPath :: FilePath
- dhSaveConfigWorker :: AsyncWorker (Any, DistributionTarget) ()
- dhSaveLocksWorker :: AsyncWorker () ()
- dhSaveTempResWorker :: AsyncWorker () ()
- dhLivelock :: Livelock
- mkDaemonHandle :: FilePath -> ConfigState -> GanetiLockWaiting -> TempResState -> (IO ConfigState -> [AsyncWorker DistributionTarget ()] -> ResultG (AsyncWorker (Any, DistributionTarget) ())) -> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) -> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) -> (IO GanetiLockWaiting -> ResultG (AsyncWorker () ())) -> (IO TempResState -> ResultG (AsyncWorker () ())) -> Livelock -> ResultG DaemonHandle
- type WConfdMonadIntType = ReaderT DaemonHandle IO
- newtype WConfdMonadInt a = WConfdMonadInt {}
- runWConfdMonadInt :: WConfdMonadInt a -> DaemonHandle -> IO a
- type WConfdMonad = ResultT GanetiException WConfdMonadInt
- type AtomicModifyMonad a = ResultT GanetiException WriterLog a
- daemonHandle :: WConfdMonad DaemonHandle
- readConfigState :: WConfdMonad ConfigState
- unpackConfigResult :: ClockTime -> ConfigState -> (a, ConfigState) -> ((a, Bool, Bool), ConfigState)
- modifyConfigStateErrWithImmediate :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad () -> WConfdMonad a
- modifyConfigStateErr :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad a
- modifyConfigStateErr_ :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> WConfdMonad ()
- modifyConfigState :: (ConfigState -> (a, ConfigState)) -> WConfdMonad a
- modifyConfigStateWithImmediate :: (ConfigState -> (a, ConfigState)) -> WConfdMonad () -> WConfdMonad a
- forceConfigStateDistribution :: DistributionTarget -> WConfdMonad ()
- modifyConfigDataErr_ :: (TempResState -> ConfigData -> AtomicModifyMonad ConfigData) -> WConfdMonad ()
- modifyTempResStateErr :: (ConfigData -> StateT TempResState ErrorResult a) -> WConfdMonad a
- modifyTempResState :: (ConfigData -> State TempResState a) -> WConfdMonad a
- readTempResState :: WConfdMonad (ConfigData, TempResState)
- modifyLockWaiting :: (GanetiLockWaiting -> (GanetiLockWaiting, (a, Set ClientId))) -> WConfdMonad a
- modifyLockWaiting_ :: (GanetiLockWaiting -> (GanetiLockWaiting, Set ClientId)) -> WConfdMonad ()
- readLockWaiting :: WConfdMonad GanetiLockWaiting
- readLockAllocation :: WConfdMonad (LockAllocation GanetiLocks ClientId)
- modifyConfigAndReturnWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> State TempResState () -> WConfdMonad (Maybe a)
- modifyConfigWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> State TempResState () -> WConfdMonad (Maybe ())
Monoid of the locations to flush the configuration to
data DistributionTarget Source #
Data type describing where the configuration has to be distributed to.
Everywhere | |
ToGroups (Set String) |
Instances
Show DistributionTarget # | |
Defined in Ganeti.WConfd.Monad showsPrec :: Int -> DistributionTarget -> ShowS show :: DistributionTarget -> String showList :: [DistributionTarget] -> ShowS | |
Semigroup DistributionTarget # | |
Defined in Ganeti.WConfd.Monad (<>) :: DistributionTarget -> DistributionTarget -> DistributionTarget sconcat :: NonEmpty DistributionTarget -> DistributionTarget stimes :: Integral b => b -> DistributionTarget -> DistributionTarget | |
Monoid DistributionTarget # | |
Defined in Ganeti.WConfd.Monad |
Pure data types used in the monad
data DaemonState Source #
The state of the daemon, capturing both the configuration state and the locking state.
dsTempResL :: Lens' DaemonState TempResState Source #
dsLockWaitingL :: Lens' DaemonState GanetiLockWaiting Source #
dsConfigStateL :: Lens' DaemonState ConfigState Source #
data DaemonHandle Source #
DaemonHandle | |
|
:: FilePath | |
-> ConfigState | |
-> GanetiLockWaiting | |
-> TempResState | |
-> (IO ConfigState -> [AsyncWorker DistributionTarget ()] -> ResultG (AsyncWorker (Any, DistributionTarget) ())) | A function that creates a worker that asynchronously saves the configuration to the master file. |
-> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) | A function that creates a worker that asynchronously distributes the configuration to master candidates |
-> (IO ConfigState -> ResultG (AsyncWorker DistributionTarget ())) | A function that creates a worker that asynchronously distributes SSConf to nodes |
-> (IO GanetiLockWaiting -> ResultG (AsyncWorker () ())) | A function that creates a worker that asynchronously saves the lock allocation state. |
-> (IO TempResState -> ResultG (AsyncWorker () ())) | A function that creates a worker that asynchronously saves the temporary reservations state. |
-> Livelock | |
-> ResultG DaemonHandle |
The monad and its instances
type WConfdMonadIntType = ReaderT DaemonHandle IO Source #
A type alias for easier referring to the actual content of the monad when implementing its instances.
newtype WConfdMonadInt a Source #
The internal part of the monad without error handling.
Instances
runWConfdMonadInt :: WConfdMonadInt a -> DaemonHandle -> IO a Source #
Runs the internal part of the WConfdMonad monad on a given daemon handle.
type WConfdMonad = ResultT GanetiException WConfdMonadInt Source #
The complete monad with error handling.
type AtomicModifyMonad a = ResultT GanetiException WriterLog a Source #
A pure monad that logs and reports errors used for atomic modifications.
Basic functions in the monad
daemonHandle :: WConfdMonad DaemonHandle Source #
Returns the daemon handle.
readConfigState :: WConfdMonad ConfigState Source #
Returns the current configuration, given a handle
unpackConfigResult :: ClockTime -> ConfigState -> (a, ConfigState) -> ((a, Bool, Bool), ConfigState) Source #
From a result of a configuration change, determine if the configuration was changed and if full distribution is needed. If so, also bump the serial number.
modifyConfigStateErrWithImmediate :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad () -> WConfdMonad a Source #
Atomically modifies the configuration state in the WConfdMonad with a computation that can possibly fail; immediately afterwards, while config write is still going on, do the followup action. Return only after replication is finished.
modifyConfigStateErr :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> WConfdMonad a Source #
Atomically modifies the configuration state in the WConfdMonad with a computation that can possibly fail.
modifyConfigStateErr_ :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> WConfdMonad () Source #
Atomically modifies the configuration state in the WConfdMonad with a computation that can possibly fail.
modifyConfigState :: (ConfigState -> (a, ConfigState)) -> WConfdMonad a Source #
Atomically modifies the configuration state in the WConfdMonad.
modifyConfigStateWithImmediate :: (ConfigState -> (a, ConfigState)) -> WConfdMonad () -> WConfdMonad a Source #
Atomically modifies the configuration state in WConfdMonad; immediately afterwards (while the config write-out is not necessarily finished) do another acation.
forceConfigStateDistribution :: DistributionTarget -> WConfdMonad () Source #
Force the distribution of configuration without actually modifying it.
We need a separate call for this operation, because modifyConfigState
only
triggers the distribution when the configuration changes.
modifyConfigDataErr_ :: (TempResState -> ConfigData -> AtomicModifyMonad ConfigData) -> WConfdMonad () Source #
Atomically modifies the configuration data in the WConfdMonad with a computation that can possibly fail.
modifyTempResStateErr :: (ConfigData -> StateT TempResState ErrorResult a) -> WConfdMonad a Source #
Atomically modifies the state of temporary reservations in WConfdMonad in the presence of possible errors.
modifyTempResState :: (ConfigData -> State TempResState a) -> WConfdMonad a Source #
Atomically modifies the state of temporary reservations in WConfdMonad.
readTempResState :: WConfdMonad (ConfigData, TempResState) Source #
Reads the state of of the configuration and temporary reservations in WConfdMonad.
modifyLockWaiting :: (GanetiLockWaiting -> (GanetiLockWaiting, (a, Set ClientId))) -> WConfdMonad a Source #
Atomically modifies the lock waiting state in WConfdMonad.
modifyLockWaiting_ :: (GanetiLockWaiting -> (GanetiLockWaiting, Set ClientId)) -> WConfdMonad () Source #
Atomically modifies the lock allocation state in WConfdMonad, not producing any result
readLockWaiting :: WConfdMonad GanetiLockWaiting Source #
Read the lock waiting state in WConfdMonad.
readLockAllocation :: WConfdMonad (LockAllocation GanetiLocks ClientId) Source #
Read the underlying lock allocation.
modifyConfigAndReturnWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad (a, ConfigState)) -> State TempResState () -> WConfdMonad (Maybe a) Source #
Modify the configuration while temporarily acquiring the configuration lock. If the configuration lock is held by someone else, nothing is changed and Nothing is returned.
modifyConfigWithLock :: (TempResState -> ConfigState -> AtomicModifyMonad ConfigState) -> State TempResState () -> WConfdMonad (Maybe ()) Source #