-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add phases definition for the local-cluster
- Loading branch information
Showing
2 changed files
with
70 additions
and
0 deletions.
There are no files selected for viewing
69 changes: 69 additions & 0 deletions
69
lib/local-cluster/lib/Cardano/Wallet/Launch/Cluster/Monitoring/Phase.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
|
||
module Cardano.Wallet.Launch.Cluster.Monitoring.Phase | ||
( Phase (..) | ||
, RelayNode (..) | ||
, History (..) | ||
) | ||
where | ||
|
||
import Prelude | ||
|
||
import Cardano.Launcher.Node | ||
( CardanoNodeConn | ||
, cardanoNodeConn | ||
, nodeSocketFile | ||
) | ||
import Data.Aeson | ||
( FromJSON | ||
, ToJSON | ||
) | ||
import Data.Aeson.Types | ||
( FromJSON (..) | ||
, ToJSON (..) | ||
) | ||
import Data.Map | ||
( Map | ||
) | ||
import Data.Time | ||
( UTCTime | ||
) | ||
import GHC.Generics | ||
( Generic | ||
) | ||
|
||
-- | A relay node as a reference to it's socket file or pipe | ||
newtype RelayNode = RelayNode CardanoNodeConn | ||
deriving stock (Eq, Show, Generic) | ||
|
||
instance ToJSON RelayNode where | ||
toJSON (RelayNode f) = toJSON $ nodeSocketFile f | ||
|
||
instance FromJSON RelayNode where | ||
parseJSON x = do | ||
f <- parseJSON x | ||
case cardanoNodeConn f of | ||
Right conn -> pure $ RelayNode conn | ||
Left e -> fail e | ||
|
||
-- | The different phases the cluster can be in. We use the convention to report | ||
-- the start of a phase. | ||
data Phase | ||
= RetrievingFunds | ||
| Metadata | ||
| Genesis | ||
| Pool0 | ||
| Funding | ||
| Pools | ||
| Relay | ||
| Cluster (Maybe RelayNode) | ||
deriving stock (Eq, Show, Generic) | ||
deriving anyclass (ToJSON, FromJSON) | ||
|
||
-- | The history of the cluster phases | ||
newtype History = History | ||
{ history :: Map UTCTime Phase | ||
} | ||
deriving stock (Eq, Show) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters