1
+ {-# LANGUAGE CPP #-}
1
2
{-# LANGUAGE FlexibleContexts #-}
2
3
{-# LANGUAGE OverloadedStrings #-}
4
+
3
5
module Kubernetes.Client.Watch
4
6
( WatchEvent
5
7
, eventType
@@ -11,14 +13,22 @@ import Control.Monad
11
13
import Control.Monad.Trans (lift )
12
14
import Data.Aeson
13
15
import qualified Data.ByteString as B
14
- import qualified Data.ByteString.Streaming.Char8 as Q
15
16
import qualified Data.Text as T
16
- import Kubernetes.OpenAPI.Core
17
17
import Kubernetes.OpenAPI.Client
18
+ import Kubernetes.OpenAPI.Core
18
19
import Kubernetes.OpenAPI.MimeTypes
19
20
import Kubernetes.OpenAPI.Model (Watch (.. ))
20
21
import Network.HTTP.Client
21
22
23
+ #if MIN_VERSION_streaming_bytestring(0,1,7)
24
+ import qualified Streaming.ByteString.Char8 as Q
25
+ type ByteStream = Q. ByteStream
26
+ #else
27
+ import qualified Data.ByteString.Streaming.Char8 as Q
28
+ type ByteStream = Q. ByteString
29
+ #endif
30
+
31
+
22
32
data WatchEvent a = WatchEvent
23
33
{ _eventType :: T. Text
24
34
, _eventObject :: a
@@ -68,7 +78,7 @@ dispatchWatch ::
68
78
Manager
69
79
-> KubernetesClientConfig
70
80
-> KubernetesRequest req contentType resp accept
71
- -> (Q. ByteString IO () -> IO a )
81
+ -> (ByteStream IO () -> IO a )
72
82
-> IO a
73
83
dispatchWatch manager config request apply = do
74
84
let watchRequest = applyOptionalParam request (Watch True )
@@ -78,14 +88,14 @@ dispatchWatch manager config request apply = do
78
88
withHTTP ::
79
89
Request
80
90
-> Manager
81
- -> (Response (Q. ByteString IO () ) -> IO a )
91
+ -> (Response (ByteStream IO () ) -> IO a )
82
92
-> IO a
83
93
withHTTP request manager f = withResponse request manager f'
84
94
where
85
95
f' resp = do
86
96
let p = (from . brRead . responseBody) resp
87
97
f (resp {responseBody = p})
88
- from :: IO B. ByteString -> Q. ByteString IO ()
98
+ from :: IO B. ByteString -> ByteStream IO ()
89
99
from io = go
90
100
where
91
101
go = do
0 commit comments