diff options
author | Joe Crayne <joe@jerkface.net> | 2020-01-24 20:06:26 -0500 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2020-01-25 19:18:12 -0500 |
commit | 512c97888c09cdf00837f7c5cabd3655c286458d (patch) | |
tree | 867132d3daf24831e7f4b259ff3b68391928c3f7 | |
parent | 4881188039568837d0a12ef8c73450718957f58b (diff) |
QueryResponse: non-error ignored case Discarded.
-rw-r--r-- | server/src/Network/QueryResponse.hs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/server/src/Network/QueryResponse.hs b/server/src/Network/QueryResponse.hs index 470b7ce7..6af1f355 100644 --- a/server/src/Network/QueryResponse.hs +++ b/server/src/Network/QueryResponse.hs | |||
@@ -65,13 +65,14 @@ resultToMaybe _ = Nothing | |||
65 | -- | An inbound packet or condition raised while monitoring a connection. | 65 | -- | An inbound packet or condition raised while monitoring a connection. |
66 | data Arrival err addr x | 66 | data Arrival err addr x |
67 | = Terminated -- ^ Virtual message that signals EOF. | 67 | = Terminated -- ^ Virtual message that signals EOF. |
68 | | Discarded -- ^ Message dropped or passed to another thread. | ||
68 | | ParseError !err -- ^ A badly-formed message was received. | 69 | | ParseError !err -- ^ A badly-formed message was received. |
69 | | Arrival { arrivedFrom :: !addr , arrivedMsg :: !x } -- ^ Inbound message. | 70 | | Arrival { arrivedFrom :: !addr , arrivedMsg :: !x } -- ^ Inbound message. |
70 | 71 | ||
71 | -- | Three methods are required to implement a datagram based query\/response protocol. | 72 | -- | Three methods are required to implement a datagram based query\/response protocol. |
72 | data TransportA err addr x y = Transport | 73 | data TransportA err addr x y = Transport |
73 | { -- | Blocks until an inbound packet is available. Then calls the provided | 74 | { -- | Blocks until an inbound packet is available. Then calls the provided |
74 | -- continuation with the packet and origin addres or an error condition. | 75 | -- continuation with the packet and origin address or an error condition. |
75 | awaitMessage :: forall a. (Arrival err addr x -> IO a) -> STM (IO a) | 76 | awaitMessage :: forall a. (Arrival err addr x -> IO a) -> STM (IO a) |
76 | -- | Send an /y/ packet to the given destination /addr/. | 77 | -- | Send an /y/ packet to the given destination /addr/. |
77 | , sendMessage :: addr -> y -> IO () | 78 | , sendMessage :: addr -> y -> IO () |
@@ -109,6 +110,7 @@ layerTransportM parse encode tr = | |||
109 | tr { awaitMessage = \kont -> | 110 | tr { awaitMessage = \kont -> |
110 | awaitMessage tr $ \case | 111 | awaitMessage tr $ \case |
111 | Terminated -> kont $ Terminated | 112 | Terminated -> kont $ Terminated |
113 | Discarded -> kont $ Discarded | ||
112 | ParseError e -> kont $ ParseError e | 114 | ParseError e -> kont $ ParseError e |
113 | Arrival addr x -> parse x addr >>= \case | 115 | Arrival addr x -> parse x addr >>= \case |
114 | Left e -> kont $ ParseError e | 116 | Left e -> kont $ ParseError e |
@@ -153,6 +155,7 @@ partitionTransportM parse encodex tr = do | |||
153 | Left x -> atomically (writeTChan tchan (Just x)) >> join (atomically again) | 155 | Left x -> atomically (writeTChan tchan (Just x)) >> join (atomically again) |
154 | Right (y,yaddr) -> kont $ Arrival yaddr y | 156 | Right (y,yaddr) -> kont $ Arrival yaddr y |
155 | ParseError e -> kont $ ParseError e | 157 | ParseError e -> kont $ ParseError e |
158 | Discarded -> kont $ Discarded | ||
156 | Terminated -> atomically (writeTChan tchan Nothing) >> kont Terminated | 159 | Terminated -> atomically (writeTChan tchan Nothing) >> kont Terminated |
157 | , sendMessage = sendMessage tr | 160 | , sendMessage = sendMessage tr |
158 | } | 161 | } |
@@ -708,6 +711,7 @@ newtype Tagged x addr = Tagged x | |||
708 | 711 | ||
709 | decorateAddr :: tag addr -> Arrival e addr x -> Arrival e (DSum tag Identity) x | 712 | decorateAddr :: tag addr -> Arrival e addr x -> Arrival e (DSum tag Identity) x |
710 | decorateAddr tag Terminated = Terminated | 713 | decorateAddr tag Terminated = Terminated |
714 | decorateAddr tag Discarded = Discarded | ||
711 | decorateAddr tag (ParseError e) = ParseError e | 715 | decorateAddr tag (ParseError e) = ParseError e |
712 | decorateAddr tag (Arrival addr x) = Arrival (tag ==> addr) x | 716 | decorateAddr tag (Arrival addr x) = Arrival (tag ==> addr) x |
713 | 717 | ||