Skip to content

Commit

Permalink
hadmin: add deleteConnector command
Browse files Browse the repository at this point in the history
  • Loading branch information
YangKian committed May 27, 2024
1 parent 5ad74fd commit 926318d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions hstream-admin/app/admin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ runServerCli' s (Server.ServerAdminCmd adminCmd) = do
Server.AdminSubscriptionCommand (Server.SubscriptionCmdDelete sid _) -> (True, sid)
Server.AdminSubscriptionCommand (Server.SubscriptionCmdDescribe sid) -> (True, sid)
Server.AdminConnectorCommand (Server.ConnectorCmdResume cId) -> (True, cId)
Server.AdminConnectorCommand (Server.ConnectorCmdDelete cId) -> (True, cId)
Server.AdminConnectorCommand (Server.ConnectorCmdDescribe cId) -> (True, cId)
_ -> (False, "")

Expand Down
6 changes: 6 additions & 0 deletions hstream-admin/server/HStream/Admin/Server/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ data ConnectorCommand
= ConnectorCmdList
| ConnectorCmdResume Text
| ConnectorCmdDescribe Text
| ConnectorCmdDelete Text
deriving (Show)

connectorCmdParser :: O.Parser ConnectorCommand
Expand All @@ -260,6 +261,11 @@ connectorCmdParser = O.hsubparser
<> O.metavar "CONNECTOR_ID"
<> O.help "The ID of the connector"))
(O.progDesc "Get the details of specific connector"))
<> O.command "delete" (O.info (ConnectorCmdDelete <$> O.strOption ( O.long "id"
<> O.short 'i'
<> O.metavar "CONNECTOR_ID"
<> O.help "The ID of the connector"))
(O.progDesc "Delete specific connector"))
)

-------------------------------------------------------------------------------
Expand Down
3 changes: 3 additions & 0 deletions hstream/src/HStream/Server/Handler/Admin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,9 @@ runConnector ServerContext{..} (AT.ConnectorCmdDescribe cId) = do
]]
let content = Aeson.object ["headers" .= headers, "rows" .= rows]
return $ AT.tableResponse content
runConnector ServerContext{..} (AT.ConnectorCmdDelete cId) = do
void $ HC.deleteIOTask scIOWorker cId
return $ AT.plainResponse "OK"

-------------------------------------------------------------------------------
-- Admin Status Command
Expand Down

0 comments on commit 926318d

Please sign in to comment.