From 430765937d5abf473a799b214d7a138c7a1be909 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Mon, 17 Jan 2022 16:08:07 +0100 Subject: [PATCH] Rename --cache-listpools-ttl to --cache-listpools-refresh and clarify its function --- docs/contributing/Testing.md | 2 +- docs/user-guide/cli.md | 5 +++-- lib/cli/src/Cardano/CLI.hs | 15 ++++++++------- lib/cli/test/unit/Cardano/CLISpec.hs | 4 ++-- .../src/Cardano/Wallet/Shelley/Launch/Cluster.hs | 4 ++-- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/contributing/Testing.md b/docs/contributing/Testing.md index bfcb9341440..405be35ed94 100644 --- a/docs/contributing/Testing.md +++ b/docs/contributing/Testing.md @@ -51,7 +51,7 @@ integration tests and test cluster. | `NO_POOLS` | bool | Don't start any stake pool nodes in the local test cluster. | Pool nodes are started | | `TOKEN_METADATA_SERVER` | URL | Use this URL for querying asset metadata | Asset metadata fetching disabled | | `NO_CACHE_LISTPOOLS` | bool | Do not cache pool listing retrieved from cardano-node. *Testing only. Use `--no-cache-listpools` command line for executable*. | Stake distribution is cached to improve responsiveness | -| `CACHE_LISTPOOLS_TTL` | number | Cache time to live (TTL) for pool listing. *Testing only. Use `--no-cache-listpools` command line for executable*. | 6 seconds for test builds | +| `CACHE_LISTPOOLS_REFRESH` | number | Time interval that indicates how often the cache for the stake-pools listing will be refreshed. *Testing only. Use `--cache-listpools-refresh` command line for executable*. | 6 seconds for test builds | Here are the possible values of different types of environment variables: diff --git a/docs/user-guide/cli.md b/docs/user-guide/cli.md index d166161426b..eb59a37d076 100644 --- a/docs/user-guide/cli.md +++ b/docs/user-guide/cli.md @@ -168,8 +168,9 @@ Serve API that listens for commands/actions. Before launching user should start > you are fully trusting the operator of the metadata > server to provide authentic token metadata. > --no-cache-listpools Do not cache the stake-pools listing. -> --cache-listpools-ttl TTL -> Cache time to live (TTL) for stake-pools listing. +> --cache-listpools-refresh DURATION +> Time interval that indicates how often +> the cache for the stake-pools listing will be refreshed. > Expressed in seconds with a trailing 's'. > (default: 3600s) > --log-level SEVERITY Global minimum severity for a message to be logged. diff --git a/lib/cli/src/Cardano/CLI.hs b/lib/cli/src/Cardano/CLI.hs index 37fdd87d495..7e0a4014269 100644 --- a/lib/cli/src/Cardano/CLI.hs +++ b/lib/cli/src/Cardano/CLI.hs @@ -1408,15 +1408,16 @@ walletIdArgument :: Parser WalletId walletIdArgument = argumentT $ mempty <> metavar "WALLET_ID" --- | [--no-cache-listpools|--cache-listpools-ttl DURATION] +-- | [--no-cache-listpools|--cache-listpools-refresh DURATION] cacheListPoolsOption :: Parser CacheConfig -cacheListPoolsOption = no <|> fmap (CacheTTL . getQuantity) ttl +cacheListPoolsOption = no <|> fmap (CacheTTL . getQuantity) refresh where - ttl :: Parser (Quantity "second" NominalDiffTime) - ttl = fmap Quantity $ optionT $ mempty - <> long "cache-listpools-ttl" - <> metavar "TTL" - <> help ( "Cache time to live (TTL) for stake-pools listing. " + refresh :: Parser (Quantity "second" NominalDiffTime) + refresh = fmap Quantity $ optionT $ mempty + <> long "cache-listpool-refresh" + <> metavar "DURATION" + <> help ( "Time interval that indicates how often " + <> "the cache for the stake-pools listing will be refreshed." <> "Expressed in seconds with a trailing 's'. " ) <> value 3600 diff --git a/lib/cli/test/unit/Cardano/CLISpec.hs b/lib/cli/test/unit/Cardano/CLISpec.hs index e4e4b7ac3ad..1de1638756c 100644 --- a/lib/cli/test/unit/Cardano/CLISpec.hs +++ b/lib/cli/test/unit/Cardano/CLISpec.hs @@ -299,9 +299,9 @@ spec = do forM_ parseTimeTests $ \(desc, arg, tst) -> it desc $ parse arg `shouldSatisfy` tst - describe "Cache listpools TTL option" $ do + describe "Cache listpools refresh option" $ do let parse arg = execParserPure defaultPrefs - (info cacheListPoolsOption mempty) ["--cache-listpools-ttl", arg] + (info cacheListPoolsOption mempty) ["--cache-listpools-refresh", arg] let toMaybe (CacheTTL x) = Just (Quantity x) toMaybe (NoCache) = Nothing forM_ parseTimeTests $ \(desc, arg, tst) -> diff --git a/lib/shelley/src/Cardano/Wallet/Shelley/Launch/Cluster.hs b/lib/shelley/src/Cardano/Wallet/Shelley/Launch/Cluster.hs index c4e9e526dd2..b3491a86026 100644 --- a/lib/shelley/src/Cardano/Wallet/Shelley/Launch/Cluster.hs +++ b/lib/shelley/src/Cardano/Wallet/Shelley/Launch/Cluster.hs @@ -300,11 +300,11 @@ tokenMetadataServerFromEnv = envFromText "TOKEN_METADATA_SERVER" >>= \case Just (Right s) -> pure (Just s) Just (Left e) -> die $ show e --- | Collect @--cache-listpools-ttl@ and @--no-cache-listpools@ options +-- | Collect @--cache-listpools-refresh@ and @--no-cache-listpools@ options -- from environment variables. listPoolsConfigFromEnv :: IO CacheConfig listPoolsConfigFromEnv = do - ttl <- envFromText "CACHE_LISTPOOLS_TTL" >>= \case + ttl <- envFromText "CACHE_LISTPOOLS_REFRESH" >>= \case Nothing -> pure $ CacheTTL 6 -- default value for testing Just (Right s) -> pure $ CacheTTL s Just (Left e) -> die $ show e