Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hadmin-store: fix formatting and handling of logReplicateAcross attribute display #1622

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ jobs:
${{ env.CABAL }} install hadmin-store

- name: run hadmin-store
run: ${{ env.CABAL }} exec hadmin-store --help
run: ${{ env.CABAL }} exec -- hadmin-store --help

build-and-test:
needs: pre-build
Expand Down
22 changes: 13 additions & 9 deletions hstream-admin/store/HStream/Admin/Store/Command/Logs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -247,22 +247,26 @@ printLogDirectory' client level maxDepth verbose logDirectory = do

printLogAttributes :: Int -> LogAttributes -> IO ()
printLogAttributes level LogAttributes{..} = do
let cast = Casting.toKebab . Casting.dropPrefix . Casting.fromAny
emit s = putStrLn $ replicate ((level + 1) * shift) ' ' <> "- " <> s
#define _SHOW_ATTR(x) cast #x <> ": " <> showAttributeVal x
let formatAttrKey = Casting.toKebab . Casting.dropPrefix . Casting.fromAny
emit (Just s) = putStrLn $ replicate ((level + 1) * shift) ' ' <> "- " <> s
emit Nothing = pure ()
#define _SHOW_ATTR(x) showAttributeVal x (formatAttrKey #x <> ": ")
emit $ _SHOW_ATTR(logReplicationFactor)
emit $ _SHOW_ATTR(logSyncedCopies)
emit $ _SHOW_ATTR(logBacklogDuration)
emit $ _SHOW_ATTR(logReplicateAcross)
forM_ (Map.toList logAttrsExtras) $ \(k, v) ->
emit $ unpack k <> ": " <> unpack v
emit $ Just $ unpack k <> ": " <> unpack v
#undef _SHOW_ATTR

showAttributeVal :: Show a => S.Attribute a -> String
showAttributeVal S.Attribute{..} =
-- TODO
let overridden = if not attrInherited then " (Overridden)" else ""
in (show . fromJust $ attrValue) <> overridden
showAttributeVal :: Show a => S.Attribute a -> String -> Maybe String
showAttributeVal S.Attribute{..} label =
case attrValue of
Nothing -> Nothing
Just vl ->
-- TODO
let overridden = if not attrInherited then " (Overridden)" else ""
in Just $ label <> (show vl) <> overridden

runLogsSetRange :: HeaderConfig AdminAPI -> SetRangeOpts -> IO ()
runLogsSetRange conf SetRangeOpts{..} = do
Expand Down
Loading