patch applied (hackage-server): "Step towards greater encapsulation and modularity of the feature modules" and 4 others

devnull at community.haskell.org devnull at community.haskell.org
Fri Sep 28 11:18:50 CEST 2012


Thu Sep 27 22:38:03 BST 2012  Duncan Coutts <duncan at well-typed.com>
  * Step towards greater encapsulation and modularity of the feature modules
  Ignore-this: 2a79f6a60fdf42be6166a261d3a54de4
  The Distribution.Server.Feature.* modules are the way we add
  functionality to the hackage server in a nice modular way.
  
  For this to be robust, these features need to properly encapsulate
  the state they manage, and provide APIs for other features to use
  that state in disciplined ways. Currently the AcidState stuff is
  global, rather than partitioned between features. This is primarily
  for historical reasons (the original happstack-state forced the state
  to be application global), and for ease of porting to the new
  acid-state package, we kept the same pattern of global shared state
  (in the Distribution.Server.Acid module).
  
  Obviously we want to split this up so that each feature encapsulates
  its own state. The first step to doing this more easily is to change
  the features to use a "first class module" style, where all the
  exported functions are part of a feature record. This will make things
  much easier since as we will not need to pass state tokens around to
  every query or update. e.g instead of:
  
  foo :: UsersFeature -> ...
  foo usersF ... =
    ...
    users <- queryGetUsersDb usersF
  
  it'll be simply
  
  foo :: UsersFeature ->
  foo UsersFeature{..} ... =
  
    users <- queryGetUsersDb
  
  And indeed, most functions don't need to take the feature arguments
  explicitly, just the top level initBlahFeature functions, with all
  other functions in the module defined in the where clause.
  
  This may seem a little odd, but in my experiments in trying to
  encapsulate the state properly, this seems like the best approach.

    M ./Distribution/Server/Features.hs -10 +14
    M ./Distribution/Server/Features/BuildReports.hs -91 +91
    M ./Distribution/Server/Features/Check.hs -174 +185
    M ./Distribution/Server/Features/Core.hs -209 +227
    M ./Distribution/Server/Features/Distro.hs -53 +55
    M ./Distribution/Server/Features/Documentation.hs -55 +56
    M ./Distribution/Server/Features/DownloadCount.hs -31 +35
    M ./Distribution/Server/Features/HaskellPlatform.hs -12 +22
    M ./Distribution/Server/Features/Html.hs -762 +763
    M ./Distribution/Server/Features/Mirror.hs -49 +72
    M ./Distribution/Server/Features/NameSearch.hs -38 +42
    M ./Distribution/Server/Features/PackageContents.hs -33 +34
    M ./Distribution/Server/Features/PackageList.hs -51 +58
    M ./Distribution/Server/Features/Packages.hs -5 +6
    M ./Distribution/Server/Features/PreferredVersions.hs -131 +139
    M ./Distribution/Server/Features/ReverseDependencies.hs +1
    M ./Distribution/Server/Features/ServerApiDoc.hs -4 +4
    M ./Distribution/Server/Features/Tags.hs -72 +89
    M ./Distribution/Server/Features/Upload.hs -203 +241
    M ./Distribution/Server/Features/Users.hs -316 +370
    M ./Distribution/Server/Users/State.hs -11 +1

Thu Sep 27 23:17:08 BST 2012  Duncan Coutts <duncan at well-typed.com>
  * Add checkpoint and shutdown to feature interface
  Ignore-this: 85c45148ef67dc5bff42b65c389ac1e1
  and start to use it in the server checkpoint and shutdown.
  Eventually the global startAcid/stopAcid will go away.

    M ./Distribution/Server.hs -2 +7
    M ./Distribution/Server/Features.hs +6
    M ./Distribution/Server/Framework/Feature.hs +4

Thu Sep 27 23:24:00 BST 2012  Duncan Coutts <duncan at well-typed.com>
  * Convert UserFeature to encapsulating its state
  Ignore-this: e95e7ec792edc773acb235b6f4e38146
  It manages the set of users and the admin user group

    M ./Distribution/Server.hs -13 +17
    M ./Distribution/Server/Acid.hs -25 +9
    M ./Distribution/Server/Features.hs -2 +2
    M ./Distribution/Server/Features/BuildReports.hs -5 +4
    M ./Distribution/Server/Features/Check.hs -2 +1
    M ./Distribution/Server/Features/Core.hs -10 +5
    M ./Distribution/Server/Features/Html.hs -5 +4
    M ./Distribution/Server/Features/Mirror.hs -4 +4
    M ./Distribution/Server/Features/Packages.hs -3 +2
    M ./Distribution/Server/Features/Upload.hs -7 +6
    M ./Distribution/Server/Features/Users.hs -31 +67
    M ./Distribution/Server/Users/Backup.hs -16 +14

Fri Sep 28 03:30:08 BST 2012  Duncan Coutts <duncan at well-typed.com>
  * Massage the feature modules to follow a common pattern
  Ignore-this: ca490df4714b9c892e14232f0d6d1d04
  This is partly intended to clarify what mutable state each module owns.
  We separate the initBlahFeature which creates the state, from a pure
  blahFeature function which is the module functor, that is it defines
  the behaviour for the new BlahFeature record in terms of the records
  of the imported modules, and the local private state. Sometimes these
  two parts are mutually dependent, in which case we use recursive do.

    M ./Distribution/Server/Features/BuildReports.hs -33 +47
    M ./Distribution/Server/Features/Check.hs -6 +8
    M ./Distribution/Server/Features/Core.hs -3 +3
    M ./Distribution/Server/Features/Distro.hs -11 +23
    M ./Distribution/Server/Features/Documentation.hs -40 +49
    M ./Distribution/Server/Features/DownloadCount.hs -39 +52
    M ./Distribution/Server/Features/HaskellPlatform.hs -18 +20
    M ./Distribution/Server/Features/Html.hs -42 +75
    M ./Distribution/Server/Features/Mirror.hs -2 +4
    M ./Distribution/Server/Features/NameSearch.hs -37 +51
    M ./Distribution/Server/Features/PackageContents.hs -27 +38
    M ./Distribution/Server/Features/PackageList.hs -57 +78
    M ./Distribution/Server/Features/Packages.hs -21 +42
    M ./Distribution/Server/Features/PreferredVersions.hs -33 +43
    M ./Distribution/Server/Features/ReverseDependencies.hs -30 +46
    M ./Distribution/Server/Features/Tags.hs -3 +3
    M ./Distribution/Server/Features/Upload.hs -3 +3
    M ./Distribution/Server/Features/Users.hs -3 +3

Fri Sep 28 10:16:26 BST 2012  Duncan Coutts <duncan at well-typed.com>
  * Make the TagsFeature encapsulate its state
  Ignore-this: 8e92f0f5d962aa2580a274a93b416d4c

    M ./Distribution/Server/Acid.hs -12 +1
    M ./Distribution/Server/Features/Html.hs -3 +3
    M ./Distribution/Server/Features/PackageList.hs -2 +2
    M ./Distribution/Server/Features/Tags.hs -16 +45
    M ./Distribution/Server/Packages/Backup/Tags.hs -7 +7




More information about the cabal-devel mailing list