I'd suggest to call it something like 'updateLocksNonBlocking' or 'tryUpdateLocks', because we'll also have a blocking variant, for which the plain name 'updateLocks' seems more appropriate. Also I'd suggest to document what the result means in the Haddock comment, so that it's not necessary to go into the internals to understand what the function does ([] = locks acquired, non-empty = lock-blocking jobs, no locks acquired).
Otherwise LGTM, no need to resend. On Mon, Mar 3, 2014 at 2:48 PM, Klaus Aehlig <[email protected]> wrote: > Export the functionality to update the locks of a given > owner through WConfD. > > Signed-off-by: Klaus Aehlig <[email protected]> > --- > src/Ganeti/WConfd/Core.hs | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/src/Ganeti/WConfd/Core.hs b/src/Ganeti/WConfd/Core.hs > index c67a4a2..c5caf62 100644 > --- a/src/Ganeti/WConfd/Core.hs > +++ b/src/Ganeti/WConfd/Core.hs > @@ -31,12 +31,16 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, > Boston, MA > > module Ganeti.WConfd.Core where > > +import Control.Monad (liftM) > import qualified Data.Map as M > +import qualified Data.Set as S > import Language.Haskell.TH (Name) > > +import Ganeti.BasicTypes (toErrorStr) > import qualified Ganeti.Locking.Allocation as L > import Ganeti.Locking.Locks (GanetiLocks) > import Ganeti.Types (JobId) > +import Ganeti.WConfd.Language > import Ganeti.WConfd.Monad > import Ganeti.WConfd.ConfigWriter > > @@ -55,7 +59,20 @@ listLocks :: JobId -> FilePath -> WConfdMonad > [(GanetiLocks, L.OwnerState)] > listLocks jid fpath = > liftM (M.toList . L.listLocks (jid, fpath)) readLockAllocation > > +-- | Update the locks of a given owner (i.e., a job-id lockfile pair). > +updateLocks :: JobId -> FilePath -> GanetiLockRequest -> WConfdMonad > [JobId] > +updateLocks jid fpath req = > + liftM (S.toList . S.map fst) > + . (>>= toErrorStr) > + $ modifyLockAllocation (L.updateLocks (jid, fpath) > + (fromGanetiLockRequest req)) > + > -- * The list of all functions exported to RPC. > > exportedFunctions :: [Name] > -exportedFunctions = [ 'echo, 'readConfig, 'writeConfig, 'listLocks] > +exportedFunctions = [ 'echo > + , 'readConfig > + , 'writeConfig > + , 'listLocks > + , 'updateLocks > + ] > -- > 1.9.0.279.gdc9e3eb > >
