ganeti

Safe HaskellSafe-Infered

Ganeti.ConfigReader

Contents

Description

Implementation of configuration reader with watching support.

Synopsis

Documentation

type ConfigReader = IO (Result ConfigData)Source

A type for functions that can return the configuration when executed.

data ReloadModel Source

Constructors

ReloadNotify 
ReloadPoll Int 

Instances

data ServerState Source

Constructors

ServerState 

Configuration handling

Helper functions

moveToPolling :: String -> INotify -> FilePath -> (Result ConfigData -> IO ()) -> MVar ServerState -> IO ReloadModelSource

Configuration loading

updateConfig :: FilePath -> (Result ConfigData -> IO ()) -> IO ()Source

safeUpdateConfig :: FilePath -> FStat -> (Result ConfigData -> IO ()) -> IO (FStat, ConfigReload)Source

Watcher threads

We have three threads/functions that can mutate the server state:

  1. the long-interval watcher (onWatcherTimer)
  2. the polling watcher (onPollTimer)
  3. the inotify event handler (onInotify)

All of these will mutate the server state under modifyMVar or modifyMVar_, so that server transitions are more or less atomic. The inotify handler remains active during polling mode, but checks for polling mode and doesn't do anything in this case (this check is needed even if we would unregister the event handler due to how events are serialised).

onWatcherTimer :: IO Bool -> FilePath -> (Result ConfigData -> IO ()) -> MVar ServerState -> IO ()Source

onWatcherInner :: FilePath -> (Result ConfigData -> IO ()) -> ServerState -> IO ServerStateSource

onPollTimer :: IO Bool -> FilePath -> (Result ConfigData -> IO ()) -> MVar ServerState -> IO ()Source

onPollInner :: IO Bool -> FilePath -> (Result ConfigData -> IO ()) -> ServerState -> IO (ServerState, Bool)Source

addNotifier :: INotify -> FilePath -> (Result ConfigData -> IO ()) -> MVar ServerState -> IO BoolSource

onInotify :: INotify -> String -> (Result ConfigData -> IO ()) -> MVar ServerState -> Event -> IO ()Source

initConfigReader :: (Result ConfigData -> a) -> IORef a -> IO ()Source