systemd-socket-activation 1.0.0.2 → 1.1.0.0
raw patch · 4 files changed
+72/−12 lines, 4 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- SocketActivation: NoSuchName :: Name -> Error
+ SocketActivation: NoSuchName :: Name -> [Name] -> Error
Files
- changelog.md +8/−0
- src/SocketActivation/Concepts.hs +57/−6
- src/SocketActivation/GetByName.hs +1/−1
- systemd-socket-activation.cabal +6/−5
changelog.md view
@@ -1,3 +1,11 @@+# 1.1.0.0 (2023-02-25)++The `NoSuchName` constructor of `Error` now has an additional field that+indicates which sockets are available.++The `displayException` method of `Error` has been changed from the default+implementation; it now constructs sentences.+ # 1.0.0.2 (2023-01-08) Support GHC 9.4
src/SocketActivation/Concepts.hs view
@@ -12,15 +12,20 @@ ) where -import Control.Exception (Exception)+import Control.Exception (Exception (..), SomeException (..))+import Data.Functor ((<$>))+import Data.Function ((.))+import Data.Semigroup ((<>)) import Data.String (IsString) import Data.Text (Text)-import Numeric.Natural (Natural)-import Prelude (Bounded, Enum, Eq, Ord, Show)-+import Data.Typeable (cast) import Network.Socket (Socket)+import Numeric.Natural (Natural)+import Prelude (Bounded, Enum, Eq, Ord, Show, String, show) import System.Posix.Types (Fd (..), ProcessID) +import qualified Data.Text as Text+ {-| The ID of the process to whom systemd has given the sockets A process should not use sockets that are intended for someone else, so we@@ -47,6 +52,52 @@ data VarName = LISTEN_PID | LISTEN_FDS | LISTEN_FDNAMES deriving stock (Eq, Show, Enum, Bounded) -data Error = Missing VarName | Invalid VarName | WrongProcess | NoSuchName Name+data Error =+ Missing VarName+ | Invalid VarName+ | WrongProcess+ | NoSuchName Name [Name] deriving stock Show- deriving anyclass Exception++instance Exception Error where+ fromException (SomeException e) = cast e+ toException = SomeException+ displayException = \case+ Missing v -> unwords+ [ "The environment variable"+ , tshow @VarName v+ , "is required but not present."+ ]+ Invalid v -> unwords+ [ "The environment variable"+ , tshow @VarName v+ , "has a malformed value that could not be parsed."+ ]+ WrongProcess -> unwords+ [ "A socket is present, but it was rejected because"+ , tshow @VarName LISTEN_PID+ , "differs from the current process ID."+ ]+ NoSuchName wanted found -> unwords+ [ "Cannot find a socket named"+ , quote (nameText wanted) <> "."+ , case found of+ [] -> "There are no available sockets."+ [x] -> Text.unwords+ [ "This is one available socket and its name is"+ , quote (nameText x) <> "."+ ]+ xs -> Text.unwords+ [ "The available sockets are:"+ , Text.intercalate ", " (nameText <$> xs) <> "."+ ]+ ]++quote :: Text -> Text+quote x = "‘" <> x <> "’"++tshow :: forall a. Show a => a -> Text+tshow = Text.pack . show++unwords :: [Text] -> String+unwords = Text.unpack . Text.unwords
src/SocketActivation/GetByName.hs view
@@ -45,5 +45,5 @@ getSocketByName name = run (getMap >>= findFd >>= convertToSocket) where getMap = IO' getFileDescriptorMap- findFd = maybe (throwError (NoSuchName name)) return . Map.lookup name+ findFd m = maybe (throwError (NoSuchName name (Map.keys m))) return (Map.lookup name m) convertToSocket = liftIO . fdSocket
systemd-socket-activation.cabal view
@@ -1,7 +1,7 @@ cabal-version: 3.0 name: systemd-socket-activation-version: 1.0.0.2+version: 1.1.0.0 category: System, Network synopsis: Let systemd bind the server's socket for you @@ -24,8 +24,8 @@ extra-source-files: *.md source-repository head- type: git- location: https://github.com/typeclasses/systemd-socket-activation+ type: git+ location: https://github.com/typeclasses/systemd-socket-activation library default-language: Haskell2010@@ -33,8 +33,9 @@ hs-source-dirs: src default-extensions: DeriveAnyClass DerivingStrategies- DerivingVia GeneralizedNewtypeDeriving- NoImplicitPrelude OverloadedStrings TypeApplications+ DerivingVia LambdaCase GeneralizedNewtypeDeriving+ NoImplicitPrelude OverloadedStrings+ ScopedTypeVariables TypeApplications exposed-modules: SocketActivation