Skip to content

Commit

Permalink
remote: less chatty server
Browse files Browse the repository at this point in the history
  • Loading branch information
sorki committed Dec 10, 2023
1 parent 3dc7ab6 commit e2381c8
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions hnix-store-remote/src/System/Nix/Store/Remote/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ type WorkerHelper m
)
=> StoreRequest a -> m a

chatty :: Bool
chatty = False

dbg :: MonadIO m => Text -> m ()
dbg = when chatty . liftIO . Data.Text.IO.putStrLn

-- | Run an emulated nix daemon on given socket address.
-- The deamon will close when the continuation returns.
runProxyDaemon
Expand All @@ -57,12 +63,12 @@ runProxyDaemon
runProxyDaemon workerHelper postGreet lsock k = do
liftIO $ listen lsock maxListenQueue

liftIO $ Data.Text.IO.putStrLn "listening"
dbg "listening"

let listener :: m Void
listener = do
(sock, _) <- liftIO $ accept lsock
liftIO $ Data.Text.IO.putStrLn "accepting"
dbg "accepting"

-- TODO: this, but without the space leak
fmap fst
Expand Down Expand Up @@ -160,7 +166,7 @@ processConnection workerHelper postGreet sock = do
loop
loop

liftIO $ Data.Text.IO.putStrLn "daemon connection done"
dbg "daemon connection done"
liftIO $ close sock

where
Expand All @@ -176,7 +182,6 @@ processConnection workerHelper postGreet sock = do
RemoteStoreError_SerializerHandshake
workerMagic

liftIO $ print ("magic" :: Text, magic)
when (magic /= WorkerMagic_One)
$ throwError
$ RemoteStoreError_WorkerException
Expand All @@ -195,8 +200,6 @@ processConnection workerHelper postGreet sock = do

let leastCommonVersion = min clientVersion serverHandshakeInputOurVersion

liftIO $ print ("Versions client, min" :: Text, clientVersion, leastCommonVersion)

when (clientVersion < ProtoVersion 1 10)
$ throwError
$ RemoteStoreError_WorkerException
Expand Down

0 comments on commit e2381c8

Please sign in to comment.