|
1 |
{-| Ganeti lock-related types and type classes
|
|
2 |
|
|
3 |
-}
|
|
4 |
|
|
5 |
{-
|
|
6 |
|
|
7 |
Copyright (C) 2014 Google Inc.
|
|
8 |
|
|
9 |
This program is free software; you can redistribute it and/or modify
|
|
10 |
it under the terms of the GNU General Public License as published by
|
|
11 |
the Free Software Foundation; either version 2 of the License, or
|
|
12 |
(at your option) any later version.
|
|
13 |
|
|
14 |
This program is distributed in the hope that it will be useful, but
|
|
15 |
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17 |
General Public License for more details.
|
|
18 |
|
|
19 |
You should have received a copy of the GNU General Public License
|
|
20 |
along with this program; if not, write to the Free Software
|
|
21 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
22 |
02110-1301, USA.
|
|
23 |
|
|
24 |
-}
|
|
25 |
|
|
26 |
module Ganeti.Locking.Types
|
|
27 |
( Lock
|
|
28 |
, lockImplications
|
|
29 |
) where
|
|
30 |
|
|
31 |
{-| The type class of being a lock
|
|
32 |
|
|
33 |
As usual, locks need to come with an order, the lock order, and
|
|
34 |
be an instance of Show, so that malformed requests can meaningfully
|
|
35 |
be reported.
|
|
36 |
|
|
37 |
Additionally, in Ganeti we also have group locks, like a lock for all
|
|
38 |
nodes. While those group locks contain infinitely many locks, the set
|
|
39 |
of locks a single lock is included in is always finite, and usually
|
|
40 |
very small. So we take this association from a lock to the locks it
|
|
41 |
is (strictly) included in as additional data of the type class.
|
|
42 |
|
|
43 |
It is a prerequisite that whenever 'a' is implied in 'b', then all locks
|
|
44 |
that are in the lock order between 'a' and 'b' are also implied in 'b'.
|
|
45 |
|
|
46 |
-}
|
|
47 |
|
|
48 |
class (Ord a, Show a) => Lock a where
|
|
49 |
lockImplications :: a -> [a]
|