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