Skip to content

Commit

Permalink
Use hackage resource-registry
Browse files Browse the repository at this point in the history
  • Loading branch information
jasagredo committed Oct 23, 2024
1 parent d79a61a commit faccfff
Show file tree
Hide file tree
Showing 68 changed files with 161 additions and 2,078 deletions.
3 changes: 3 additions & 0 deletions ouroboros-consensus-cardano/changelog.d/js-resourcereg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Patch

* Use [`resource-registry`](https://hackage.haskell.org/package/resource-registry).
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ library unstable-cardano-tools
ouroboros-network-api,
ouroboros-network-framework ^>=0.14,
ouroboros-network-protocols,
resource-registry,
serialise ^>=0.2,
singletons,
sop-core,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import Cardano.Tools.DBAnalyser.Types
import Codec.CBOR.Encoding (Encoding)
import Control.Monad (unless, void, when)
import Control.Monad.Except (runExcept)
import Control.ResourceRegistry
import Control.Tracer (Tracer (..), nullTracer, traceWith)
import Data.Int (Int64)
import Data.List (intercalate)
Expand Down Expand Up @@ -75,7 +76,6 @@ import Ouroboros.Consensus.Storage.LedgerDB (DiskSnapshot (..),
import Ouroboros.Consensus.Storage.Serialisation (encodeDisk)
import Ouroboros.Consensus.Util ((..:))
import qualified Ouroboros.Consensus.Util.IOLike as IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.SizeInBytes
import System.FS.API (SomeHasFS (..))
import qualified System.IO as IO
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Cardano.Tools.DBAnalyser.HasAnalysis
import Cardano.Tools.DBAnalyser.Types
import Codec.Serialise (Serialise (decode))
import Control.Monad.Except (runExceptT)
import Control.ResourceRegistry
import Control.Tracer (Tracer (..), nullTracer)
import Data.Singletons (Sing, SingI (..))
import qualified Debug.Trace as Debug
Expand All @@ -32,7 +33,6 @@ import Ouroboros.Consensus.Storage.LedgerDB (DiskSnapshot (..),
readSnapshot)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import System.IO
import Text.Printf (printf)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ module Cardano.Tools.DBImmutaliser.Run (

import qualified Cardano.Tools.DBAnalyser.Block.Cardano as Cardano
import Cardano.Tools.DBAnalyser.HasAnalysis (mkProtocolInfo)
import Control.ResourceRegistry
import Control.Tracer (Tracer, stdoutTracer, traceWith)
import Data.Foldable (for_)
import Data.Functor.Contravariant ((>$<))
Expand All @@ -43,7 +44,6 @@ import qualified Ouroboros.Consensus.Storage.VolatileDB.API as VolatileDB
import qualified Ouroboros.Consensus.Storage.VolatileDB.Impl as VolatileDB
import Ouroboros.Consensus.Util.Args
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (MaxSlotNo)
import System.FS.API (SomeHasFS (..))
import System.FS.API.Types (MountPoint (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Control.Monad (filterM)
import Control.Monad.Trans.Except (ExceptT)
import Control.Monad.Trans.Except.Extra (firstExceptT,
handleIOExceptT, hoistEither, runExceptT)
import Control.ResourceRegistry
import Control.Tracer (nullTracer)
import Data.Aeson as Aeson (FromJSON, Result (..), Value,
eitherDecodeFileStrict', eitherDecodeStrict', fromJSON)
Expand All @@ -36,7 +37,6 @@ import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB (getTipPoint)
import qualified Ouroboros.Consensus.Storage.ChainDB.Impl as ChainDB (withDB)
import qualified Ouroboros.Consensus.Storage.ChainDB.Impl.Args as ChainDB
import Ouroboros.Consensus.Util.IOLike (atomically)
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block
import Ouroboros.Network.Point (WithOrigin (..))
import System.Directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import Cardano.Tools.DBTruncater.Types
import Control.Monad
import Control.Monad.Trans.Class (lift)
import Control.Monad.Trans.Maybe (MaybeT (..))
import Control.ResourceRegistry (runWithTempRegistry, withRegistry)
import Control.Tracer
import Data.Foldable (asum)
import Data.Functor ((<&>))
Expand All @@ -27,8 +28,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB (ImmutableDB, Iterator,
import qualified Ouroboros.Consensus.Storage.ImmutableDB as ImmutableDB
import Ouroboros.Consensus.Storage.ImmutableDB.Impl
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry (runWithTempRegistry,
withRegistry)
import Prelude hiding (truncate)
import System.IO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
module Cardano.Tools.ImmDBServer.Diffusion (run) where

import Cardano.Tools.ImmDBServer.MiniProtocols (immDBServer)
import Control.ResourceRegistry
import Control.Tracer
import qualified Data.ByteString.Lazy as BL
import Data.Functor.Contravariant ((>$<))
Expand All @@ -22,7 +23,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB (ImmutableDbArgs (..))
import qualified Ouroboros.Consensus.Storage.ImmutableDB as ImmutableDB
import Ouroboros.Consensus.Util
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.ErrorPolicy (nullErrorPolicies)
import Ouroboros.Network.IOManager (withIOManager)
import Ouroboros.Network.Mux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module Cardano.Tools.ImmDBServer.MiniProtocols (immDBServer) where
import qualified Codec.CBOR.Decoding as CBOR
import qualified Codec.CBOR.Encoding as CBOR
import Control.Monad (forever)
import Control.ResourceRegistry
import Control.Tracer
import Data.Bifunctor (bimap)
import qualified Data.ByteString.Lazy as BL
Expand All @@ -42,7 +43,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB.API (ImmutableDB)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmutableDB
import Ouroboros.Consensus.Util
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (ChainUpdate (..), Tip (..))
import Ouroboros.Network.Driver (runPeer)
import Ouroboros.Network.KeepAlive (keepAliveServer)
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-consensus-diffusion/changelog.d/js-resourcereg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Patch

* Use [`resource-registry`](https://hackage.haskell.org/package/resource-registry).
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ library
ouroboros-network-framework ^>=0.14,
ouroboros-network-protocols ^>=0.12,
random,
resource-registry ^>=0.1,
safe-wild-cards ^>=1.0,
serialise ^>=0.2,
si-timers ^>=1.5,
Expand Down Expand Up @@ -149,6 +150,7 @@ library unstable-diffusion-testlib
ouroboros-network-protocols,
quiet ^>=0.2,
random,
resource-registry,
si-timers,
sop-core ^>=0.5,
sop-extras ^>=0.2,
Expand Down Expand Up @@ -302,6 +304,7 @@ test-suite consensus-test
quickcheck-state-machine:no-vendored-treediff,
quiet,
random,
resource-registry,
serialise,
si-timers,
sop-extras,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import Codec.CBOR.Decoding (Decoder)
import Codec.CBOR.Encoding (Encoding)
import Codec.CBOR.Read (DeserialiseFailure)
import Codec.Serialise (Serialise)
import Control.ResourceRegistry
import Control.Tracer
import Data.ByteString.Lazy (ByteString)
import Data.Void (Void)
Expand All @@ -61,7 +62,6 @@ import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB
import Ouroboros.Consensus.Util (ShowProxy)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import qualified Ouroboros.Network.AnchoredFragment as AF
import Ouroboros.Network.Block (Serialised, decodePoint, decodeTip,
encodePoint, encodeTip)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Codec.CBOR.Read (DeserialiseFailure)
import qualified Control.Concurrent.Class.MonadSTM.Strict.TVar as TVar.Unchecked
import Control.Monad.Class.MonadTime.SI (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import Control.ResourceRegistry
import Control.Tracer
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BSL
Expand Down Expand Up @@ -72,7 +73,6 @@ import Ouroboros.Consensus.Storage.Serialisation (SerialisedHeader)
import Ouroboros.Consensus.Util (ShowProxy)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.Block (Serialised (..), decodePoint,
decodeTip, encodePoint, encodeTip)
import Ouroboros.Network.BlockFetch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ import Control.DeepSeq (NFData)
import Control.Monad (forM_, when)
import Control.Monad.Class.MonadTime.SI (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import Control.ResourceRegistry
import Control.Tracer (Tracer, contramap, traceWith)
import Data.ByteString.Lazy (ByteString)
import Data.Functor.Contravariant (Predicate (..))
Expand Down Expand Up @@ -113,7 +114,6 @@ import Ouroboros.Consensus.Storage.LedgerDB.DiskPolicy
import Ouroboros.Consensus.Util.Args
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.Time (secondsToNominalDiffTime)
import Ouroboros.Network.BlockFetch (BlockFetchConfiguration (..))
import qualified Ouroboros.Network.Diffusion as Diffusion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Ouroboros.Consensus.Node.ErrorPolicy (consensusErrorPolicy) where

import Control.Monad.Class.MonadAsync (ExceptionInLinkedThread (..))
import Control.ResourceRegistry (RegistryClosedException,
ResourceRegistryThreadException, TempRegistryException)
import Data.Proxy (Proxy)
import Data.Time.Clock (DiffTime)
import Data.Typeable (Typeable)
Expand All @@ -20,9 +22,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB.API (ImmutableDBError)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmutableDB
import Ouroboros.Consensus.Storage.VolatileDB.API (VolatileDBError)
import qualified Ouroboros.Consensus.Storage.VolatileDB.API as VolatileDB
import Ouroboros.Consensus.Util.ResourceRegistry
(RegistryClosedException, ResourceRegistryThreadException,
TempRegistryException)
import Ouroboros.Network.ErrorPolicy
import System.FS.API.Types (FsError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
module Ouroboros.Consensus.Node.RethrowPolicy (consensusRethrowPolicy) where

import Control.Monad.Class.MonadAsync (ExceptionInLinkedThread (..))
import Control.ResourceRegistry (RegistryClosedException,
ResourceRegistryThreadException, TempRegistryException)
import Data.Proxy (Proxy)
import Data.Typeable (Typeable)
import Ouroboros.Consensus.Block (StandardHash)
Expand All @@ -19,9 +21,6 @@ import Ouroboros.Consensus.Storage.ImmutableDB.API (ImmutableDBError)
import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmutableDB
import Ouroboros.Consensus.Storage.VolatileDB.API (VolatileDBError)
import qualified Ouroboros.Consensus.Storage.VolatileDB.API as VolatileDB
import Ouroboros.Consensus.Util.ResourceRegistry
(RegistryClosedException, ResourceRegistryThreadException,
TempRegistryException)
import Ouroboros.Network.RethrowPolicy
import System.FS.API.Types (FsError)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import Control.DeepSeq (force)
import Control.Monad
import qualified Control.Monad.Class.MonadTimer.SI as SI
import Control.Monad.Except
import Control.ResourceRegistry
import Control.Tracer
import Data.Bifunctor (second)
import Data.Data (Typeable)
Expand Down Expand Up @@ -87,7 +88,6 @@ import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.LeakyBucket
(atomicallyWithMonotonicTime)
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.STM
import Ouroboros.Network.AnchoredFragment (AnchoredFragment,
AnchoredSeq (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import Control.Monad
import Control.Monad.Class.MonadTime.SI (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import qualified Control.Monad.Except as Exc
import Control.ResourceRegistry
import Control.Tracer
import qualified Data.ByteString.Lazy as Lazy
import Data.Either (isRight)
Expand Down Expand Up @@ -99,7 +100,6 @@ import Ouroboros.Consensus.Util.Enclose (pattern FallingEdge)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.Orphans ()
import Ouroboros.Consensus.Util.RedundantConstraints
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.STM
import Ouroboros.Consensus.Util.Time
import qualified Ouroboros.Network.AnchoredFragment as AF
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Control.Exception (SomeException)
import Control.Monad (void)
import Control.Monad.Class.MonadTime
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import Control.ResourceRegistry
import Control.Tracer (Tracer, nullTracer, traceWith)
import Data.Functor.Contravariant ((>$<))
import Data.Map.Strict (Map)
Expand All @@ -37,7 +38,6 @@ import Ouroboros.Consensus.Util (ShowProxy)
import Ouroboros.Consensus.Util.IOLike (DiffTime,
Exception (fromException), IOLike, STM, atomically, retry,
try)
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.AnchoredFragment (AnchoredFragment)
import Ouroboros.Network.BlockFetch (BlockFetchConfiguration (..),
FetchClientRegistry, FetchMode (..), blockFetchLogic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Test.Consensus.PeerSimulator.NodeLifecycle (
, restoreNode
) where

import Control.ResourceRegistry
import Control.Tracer (Tracer (..), traceWith)
import Data.Functor (void)
import Data.Set (Set)
Expand All @@ -25,7 +26,6 @@ import qualified Ouroboros.Consensus.Storage.ChainDB.Impl as ChainDB
import Ouroboros.Consensus.Storage.ChainDB.Impl.Args (cdbsLoE,
updateTracer)
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Network.AnchoredFragment (AnchoredFragment)
import qualified Ouroboros.Network.AnchoredFragment as AF
import qualified System.FS.Sim.MockFS as MockFS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module Test.Consensus.PeerSimulator.Run (
import Control.Monad (foldM, forM, void)
import Control.Monad.Class.MonadTime (MonadTime)
import Control.Monad.Class.MonadTimer.SI (MonadTimer)
import Control.ResourceRegistry
import Control.Tracer (Tracer (..), nullTracer, traceWith)
import Data.Coerce (coerce)
import Data.Foldable (for_)
Expand All @@ -34,7 +35,6 @@ import Ouroboros.Consensus.Storage.ChainDB.API
import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB
import Ouroboros.Consensus.Util.Condense (Condense (..))
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.STM (forkLinkedWatcher)
import Ouroboros.Network.AnchoredFragment (AnchoredFragment)
import qualified Ouroboros.Network.AnchoredFragment as AF
Expand Down
2 changes: 1 addition & 1 deletion ouroboros-consensus/bench/ChainSync-client-bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Main (main) where
import Bench.Consensus.ChainSyncClient.Driver (mainWith)
import Cardano.Crypto.DSIGN.Mock
import Control.Monad (void)
import Control.ResourceRegistry
import Control.Tracer (contramap, debugTracer, nullTracer)
import Data.IORef (newIORef, readIORef, writeIORef)
import qualified Data.List.NonEmpty as NE
Expand Down Expand Up @@ -33,7 +34,6 @@ import Ouroboros.Consensus.NodeId
import Ouroboros.Consensus.Protocol.BFT
import qualified Ouroboros.Consensus.Storage.ChainDB.API as ChainDB
import Ouroboros.Consensus.Util.IOLike
import Ouroboros.Consensus.Util.ResourceRegistry
import Ouroboros.Consensus.Util.STM (Fingerprint (..),
WithFingerprint (..))
import Ouroboros.Consensus.Util.Time (secondsToNominalDiffTime)
Expand Down
3 changes: 3 additions & 0 deletions ouroboros-consensus/changelog.d/js-resourcereg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Patch

* Use [`resource-registry`](https://hackage.haskell.org/package/resource-registry).
Loading

0 comments on commit faccfff

Please sign in to comment.