Skip to content

Commit

Permalink
Fix warnings about deprecation in streaming-bytestring
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Jun 17, 2024
1 parent 24f1dd7 commit daf54bf
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions kubernetes-client/src/Kubernetes/Client/Watch.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}

module Kubernetes.Client.Watch
( WatchEvent
, eventType
Expand All @@ -11,14 +13,22 @@ import Control.Monad
import Control.Monad.Trans (lift)
import Data.Aeson
import qualified Data.ByteString as B
import qualified Data.ByteString.Streaming.Char8 as Q
import qualified Data.Text as T
import Kubernetes.OpenAPI.Core
import Kubernetes.OpenAPI.Client
import Kubernetes.OpenAPI.Core
import Kubernetes.OpenAPI.MimeTypes
import Kubernetes.OpenAPI.Model (Watch(..))
import Network.HTTP.Client

#if MIN_VERSION_streaming_bytestring(0,1,7)
import qualified Streaming.ByteString.Char8 as Q
type ByteStream = Q.ByteStream
#else
import qualified Data.ByteString.Streaming.Char8 as Q
type ByteStream = Q.ByteString
#endif


data WatchEvent a = WatchEvent
{ _eventType :: T.Text
, _eventObject :: a
Expand Down Expand Up @@ -68,7 +78,7 @@ dispatchWatch ::
Manager
-> KubernetesClientConfig
-> KubernetesRequest req contentType resp accept
-> (Q.ByteString IO () -> IO a)
-> (ByteStream IO () -> IO a)
-> IO a
dispatchWatch manager config request apply = do
let watchRequest = applyOptionalParam request (Watch True)
Expand All @@ -78,14 +88,14 @@ dispatchWatch manager config request apply = do
withHTTP ::
Request
-> Manager
-> (Response (Q.ByteString IO ()) -> IO a)
-> (Response (ByteStream IO ()) -> IO a)
-> IO a
withHTTP request manager f = withResponse request manager f'
where
f' resp = do
let p = (from . brRead . responseBody) resp
f (resp {responseBody = p})
from :: IO B.ByteString -> Q.ByteString IO ()
from :: IO B.ByteString -> ByteStream IO ()
from io = go
where
go = do
Expand Down

0 comments on commit daf54bf

Please sign in to comment.