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

Check if connection is open in withConnection #18

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

matthewbauer
Copy link

No description provided.

Comment on lines -607 to -609
ensureOpen :: ApnSession -> IO ()
ensureOpen s = do
open <- isOpen s

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For backwards compat, it's nicer if we leave the existing function as an alias. The types indicate what sort of thing it is. Then we're in minor bump land. A DEPRECATED pragma could also point users to the ensureSessionOpen so that ensureOpen can be deleted in the next major version.

@@ -639,7 +650,7 @@ sendApnRaw connection deviceToken mJwtBearerToken message = bracket_
upload message (HTTP2.setEndHeader . HTTP2.setEndStream) client (_outgoingFlowControl client) stream osfc
let pph _hStreamId _hStream hHeaders _hIfc _hOfc =
lift $ print hHeaders
response <- waitStream stream isfc pph
response <- waitStream client stream isfc pph

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR can have permissive bounds on http2-client if this is guarded with CPP

Suggested change
response <- waitStream client stream isfc pph
#if MIN_VERSION_http2_client(?major, ?major, ?minor)
response <- waitStream client stream isfc pph
#else
response <- waitStream stream isfc pph
#endif

ensureConnectionOpen :: ApnConnection -> IO ()
ensureConnectionOpen c = do
open <- isConnectionOpen c
unless open $ error "Connection is closed"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this error right here. The context is that we're calling this in an ExceptT . (try :: IO a -> IO (Either ClientError a)). Which means that it seems like we're intending to have a ClientError as the "known" error path.

I know the other ensureSessionIsOpen also uses error - may be worthwhile to change that too? Would be a major break to change exception types IMO.

@hce
Copy link
Member

hce commented Nov 8, 2022

Thanks for the PR. I see there are some merge conflicts, though?

@mpscholten
Copy link

@matthewbauer @parsonsmatt this PR is included in v0.4.0.0 of push-notify-apn that I just published to hackage https://hackage.haskell.org/package/push-notify-apn-0.4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants