-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Here I'm making a short list of key things to improve in consul-haskell.
- Document all functions.
- Provide some examples for common distributed-systems tasks, such as running a service with a health check from Haskell, or running a master-elected task across multiple Haskell servers.
- Sensibly group funciton docs into sections of tasks that you usually want to accomplish with consul.
- Use of
Boolon errors.
For exampleregisterService :: ... -> m BoolreturnsFalseon any non-HTTP-200 response, discarding any useful error message, thus making it unclear how the caller should handle that case. Invalid request, or temporary loss of cluster leadership? The caller cannot tell.
Some functions don't seem to check the status code at all; we need to fix that. - Clean up comment
this is here instead of the where to prevent typechecking nastiness - Move the datacenter into
ConsulClient(like the Python bindings do).
Currently most functions takeMaybe Datacenteras an argument, but it is usually not used, and if used, usually the same. - Fix usage of plain
async.
That function isn't exception-safe (see first section of the main docs of theasyncpackage); usewithAsyncor other safe helper utilities that the docs instruct to use instead. - Extract common code for functions that make requests.
Most functions have very similar implementation:We should extract this common pattern into a helper function to make them easier to read.someFunctionality :: MonadIO m => ConsulClient -> FunctionalitySpecificRequestType -> m (Maybe FunctionalitySpecificResponseType) someFunctionality client@ConsulClient{..} request dc = do let hostnameWithScheme = hostWithScheme client initReq <- createRequest hostnameWithScheme ccPort "/v1/functionalitySpecificPath" Nothing (Just $ BL.toStrict $ encode request) False dc liftIO $ withResponse initReq ccManager $ \ response -> do case responseStatus response of x | x == status200 -> do bodyParts <- brConsume $ responseBody response return $ decode $ BL.fromStrict $ B.concat bodyParts _ -> return Nothing
- Implement ACL support.
- Add Github Actions based CI (Travis will discontinue OSS CI)
- Add tests for all functions, ideally also including coverage reports.
Metadata
Metadata
Assignees
Labels
No labels