Copyright | (c) Moritz Clasmeier 2017 2018 |
---|---|
License | BSD3 |
Maintainer | mtesseract@silverratio.net |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Internal module containing HTTP client relevant code.
Synopsis
- setRequestCheckStatus :: Request -> Request
- setRequestIgnoreStatus :: Request -> Request
- defaultRequest :: Request
- parseRequest_ :: String -> Request
- parseRequest :: MonadThrow m => String -> m Request
- data HttpException
- proxyHost :: Proxy -> ByteString
- proxyPort :: Proxy -> Int
- data Request
- data Response body
- getResponseBody :: Response a -> a
- getResponseHeaders :: Response a -> [(HeaderName, ByteString)]
- getResponseHeader :: HeaderName -> Response a -> [ByteString]
- getResponseStatusCode :: Response a -> Int
- getResponseStatus :: Response a -> Status
- setRequestProxy :: Maybe Proxy -> Request -> Request
- setRequestManager :: Manager -> Request -> Request
- setRequestBasicAuth :: ByteString -> ByteString -> Request -> Request
- setRequestBodyURLEncoded :: [(ByteString, ByteString)] -> Request -> Request
- setRequestBodyFile :: FilePath -> Request -> Request
- setRequestBodySource :: Int64 -> ConduitM () ByteString IO () -> Request -> Request
- setRequestBodyLBS :: ByteString -> Request -> Request
- setRequestBodyJSON :: ToJSON a => a -> Request -> Request
- setRequestBody :: RequestBody -> Request -> Request
- setRequestQueryString :: Query -> Request -> Request
- getRequestQueryString :: Request -> Query
- setRequestHeaders :: RequestHeaders -> Request -> Request
- setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request
- getRequestHeader :: HeaderName -> Request -> [ByteString]
- addRequestHeader :: HeaderName -> ByteString -> Request -> Request
- setRequestPath :: ByteString -> Request -> Request
- setRequestPort :: Int -> Request -> Request
- setRequestHost :: ByteString -> Request -> Request
- setRequestSecure :: Bool -> Request -> Request
- setRequestMethod :: ByteString -> Request -> Request
- httpLbs :: MonadIO m => Request -> m (Response ByteString)
- parseRequestThrow_ :: String -> Request
- parseRequestThrow :: MonadThrow m => String -> m Request
- withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a
- httpSource :: (MonadResource m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> ConduitM i o m r) -> ConduitM i o m r
- httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a
- httpJSONEither :: (MonadIO m, FromJSON a) => Request -> m (Response (Either JSONException a))
- httpJSON :: (MonadIO m, FromJSON a) => Request -> m (Response a)
- httpNoBody :: MonadIO m => Request -> m (Response ())
- httpLBS :: MonadIO m => Request -> m (Response ByteString)
- httpBS :: MonadIO m => Request -> m (Response ByteString)
- data JSONException
- type ResponseHeaders = [Header]
- type RequestHeaders = [Header]
- type Header = (HeaderName, ByteString)
- type Query = [QueryItem]
- type QueryItem = (ByteString, Maybe ByteString)
- module Network.HTTP.Types.Status
- type StreamConnectCallback m = Response () -> m ()
- type HttpErrorCallback m = Request -> HttpException -> RetryStatus -> Bool -> m ()
- type ConfigIO = Config IO
- data Config m = Config {
- _requestTemplate :: Request
- _requestModifier :: Request -> m Request
- _manager :: Maybe Manager
- _deserializationFailureCallback :: Maybe (ByteString -> Text -> m ())
- _streamConnectCallback :: Maybe (StreamConnectCallback m)
- _logFunc :: Maybe (LogFunc m)
- _retryPolicy :: RetryPolicyM IO
- _http :: HttpBackend m
- _httpErrorCallback :: Maybe (HttpErrorCallback m)
- _flowId :: Maybe FlowId
- _commitStrategy :: CommitStrategy
- _commitTimeout :: Maybe CommitTimeout
- _subscriptionStats :: Maybe SubscriptionStatsConf
- _maxUncommittedEvents :: Maybe Int32
- _batchLimit :: Maybe Int32
- _streamLimit :: Maybe Int32
- _batchFlushTimeout :: Maybe Int32
- _streamTimeout :: Maybe Int32
- _streamKeepAliveLimit :: Maybe Int32
- _worker :: WorkerConfig
- data HttpBackend b = HttpBackend {
- _httpLbs :: Config b -> Request -> Maybe Manager -> b (Response ByteString)
- _httpResponseOpen :: Config b -> Request -> Maybe Manager -> b (Response (ConduitM () ByteString b ()))
- _httpResponseClose :: Response () -> b ()
- data WorkerConfig = WorkerConfig {}
- data SubscriptionStatsConf = SubscriptionStatsConf {
- _showTimeLag :: Bool
- data SubscriptionCursorWithCounter = SubscriptionCursorWithCounter {}
- type StagedCursorsMap a = HashMap (EventTypeName, PartitionName) a
- data NakadiException
- = BatchPartiallySubmitted [BatchItemResponse]
- | BatchNotSubmitted [BatchItemResponse]
- | BatchValidationFailure [BatchItemResponse]
- | ClientNotAuthenticated Problem
- | AccessForbidden Problem
- | UnprocessableEntity Problem
- | Conflict Problem
- | DeserializationFailure ByteString Text
- | UnexpectedResponse (Response ())
- | NotFound Problem
- | TooManyRequests Problem
- | BadRequest Problem
- | SubscriptionNotFound Problem
- | CursorAlreadyCommitted CursorCommitResults
- | CursorResetInProgress Problem
- | EventTypeNotFound Problem
- | SubscriptionExistsAlready Subscription
- | RequestModificationException SomeException
- | CursorDistanceNoResult
- | StreamIdMissing
- | NakadiUrlMissing
- | ConfigurationMissing
- type LogFunc m = LogSource -> LogLevel -> LogStr -> m ()
- type LogFuncIO = LogFunc IO
- data Problem = Problem {}
- newtype CursorOffset = CursorOffset {}
- newtype EventTypeName = EventTypeName {}
- newtype PartitionName = PartitionName {}
- newtype PartitionCompactionKey = PartitionCompactionKey {}
- newtype CursorToken = CursorToken Text
- data Cursor = Cursor {}
- newtype ApplicationName = ApplicationName {}
- data SubscriptionCursor = SubscriptionCursor {}
- data SubscriptionCursorWithoutToken = SubscriptionCursorWithoutToken {}
- newtype SubscriptionCursorCommit = SubscriptionCursorCommit {
- _items :: [SubscriptionCursor]
- newtype CursorCommit = CursorCommit {}
- newtype SubscriptionId = SubscriptionId {}
- newtype StreamId = StreamId {
- unStreamId :: Text
- data SubscriptionEventStream = SubscriptionEventStream {}
- newtype Timestamp = Timestamp {}
- newtype FlowId = FlowId {}
- newtype EventId = EventId {}
- data Partition = Partition {}
- data ShiftedCursor = ShiftedCursor {}
- data CursorDistanceQuery = CursorDistanceQuery {}
- newtype CursorDistanceResult = CursorDistanceResult {}
- data SubscriptionReadFrom
- data SubscriptionPosition
- subscriptionPositionToObject :: SubscriptionPosition -> Object
- newtype ConsumerGroup = ConsumerGroup {}
- data Subscription = Subscription {}
- data SubscriptionRequest = SubscriptionRequest {}
- data PublishingStatus
- data Step
- data BatchItemResponse = BatchItemResponse {}
- newtype StreamKeepAliveLimit = StreamKeepAliveLimit {}
- newtype BatchFlushTimeout = BatchFlushTimeout {}
- data CursorCommitResultType
- data CursorCommitResult = CursorCommitResult {}
- newtype CursorCommitResults = CursorCommitResults {
- _items :: [CursorCommitResult]
- data SchemaType = SchemaTypeJson
- newtype SchemaVersion = SchemaVersion {}
- data EventTypeSchema = EventTypeSchema {}
- newtype PaginationLink = PaginationLink {}
- data PaginationLinks = PaginationLinks {}
- data EventTypeSchemasResponse = EventTypeSchemasResponse {}
- data SubscriptionsListResponse = SubscriptionsListResponse {
- _links :: PaginationLinks
- _items :: [Subscription]
- newtype Offset = Offset {}
- newtype Limit = Limit {}
- data PartitionState
- data PartitionStat = PartitionStat {}
- data SubscriptionEventTypeStats = SubscriptionEventTypeStats {}
- newtype SubscriptionStats = SubscriptionStats {}
- data EventTypeCategory
- data PartitionStrategy
- data EnrichmentStrategy = EnrichmentStrategyMetadata
- data CompatibilityMode
- data CleanupPolicy
- newtype PartitionKeyField = PartitionKeyField {}
- data EventTypeStatistics = EventTypeStatistics {}
- data EventTypeOptions = EventTypeOptions {}
- data EventType = EventType {
- _name :: EventTypeName
- _owningApplication :: Maybe ApplicationName
- _category :: Maybe EventTypeCategory
- _enrichmentStrategies :: Maybe [EnrichmentStrategy]
- _partitionStrategy :: Maybe PartitionStrategy
- _compatibilityMode :: Maybe CompatibilityMode
- _schema :: EventTypeSchema
- _partitionKeyFields :: Maybe [PartitionKeyField]
- _cleanupPolicy :: Maybe CleanupPolicy
- _defaultStatistic :: Maybe EventTypeStatistics
- _options :: Maybe EventTypeOptions
- data EventMetadata = EventMetadata {}
- data EventMetadataEnriched = EventMetadataEnriched {}
- data SubscriptionEventStreamBatch a = SubscriptionEventStreamBatch {
- _cursor :: SubscriptionCursor
- _events :: Maybe (Vector a)
- data DataOp
- data DataChangeEvent a = DataChangeEvent {}
- data DataChangeEventEnriched a = DataChangeEventEnriched {}
- data BusinessEvent a = BusinessEvent {
- _payload :: a
- _metadata :: EventMetadata
- data BusinessEventEnriched a = BusinessEventEnriched {}
- makeFieldRenamer :: [(String, String)] -> String -> String
- parseUUID :: String -> (UUID -> a) -> Value -> Parser a
- parseInteger :: (Integral i, Bounded i) => String -> (i -> a) -> Value -> Parser a
- parseString :: String -> (Text -> a) -> Value -> Parser a
- class (Monad b, Monad m) => MonadNakadiBase b m where
- nakadiLiftBase :: b a -> m a
- newtype NakadiBaseT m a = NakadiBaseT {
- runNakadiBaseT :: m a
- data CommitStrategy
- data CommitBufferingStrategy
- newtype CommitTimeout = CommitTimeout {}
- data Worker a = Worker {
- _queue :: TBQueue (SubscriptionEventStreamBatch a)
- _async :: Async ()
- data WorkerRegistry a = WorkerRegistry {}
- type PartitionIndexMap = HashMap (PartitionName, EventTypeName) Int
- class HasNakadiConfig b r | r -> b where
- nakadiConfig :: r -> Config b
- class (MonadNakadiBase b m, MonadThrow b, MonadMask b, MonadThrow m, MonadCatch m) => MonadNakadi b m | m -> b where
- type MonadNakadiIO = MonadNakadi IO
- newtype NakadiT b m a = NakadiT {
- _runNakadiT :: Config b -> m a
- runNakadiT :: Config b -> NakadiT b m a -> m a
- httpJsonBody :: (MonadNakadi b m, FromJSON a) => Status -> [(Status, ByteString -> m NakadiException)] -> (Request -> Request) -> m a
- httpJsonNoBody :: MonadNakadi b m => Status -> [(Status, ByteString -> m NakadiException)] -> (Request -> Request) -> m ()
- httpJsonBodyStream :: forall b m r. (MonadNakadi b m, MonadMask m) => Status -> [(Status, ByteString -> m NakadiException)] -> (Request -> Request) -> (Response (ConduitM () ByteString m ()) -> m r) -> m r
- httpBuildRequest :: MonadNakadi b m => (Request -> Request) -> m Request
- conduitDecode :: forall a b m. (FromJSON a, MonadNakadi b m) => ConduitM ByteString a m ()
- includeFlowId :: Config b -> Request -> Request
- errorClientNotAuthenticated :: MonadThrow m => ByteString -> m NakadiException
- errorUnprocessableEntity :: MonadThrow m => ByteString -> m NakadiException
- errorAccessForbidden :: MonadThrow m => ByteString -> m NakadiException
- errorTooManyRequests :: MonadThrow m => ByteString -> m NakadiException
- errorBadRequest :: MonadThrow m => ByteString -> m NakadiException
- errorSubscriptionNotFound :: MonadThrow m => ByteString -> m NakadiException
- errorCursorAlreadyCommitted :: MonadThrow m => ByteString -> m NakadiException
- errorCursorResetInProgress :: MonadThrow m => ByteString -> m NakadiException
- errorEventTypeNotFound :: MonadThrow m => ByteString -> m NakadiException
- errorSubscriptionExistsAlready :: MonadThrow m => ByteString -> m NakadiException
- errorBatchPartiallySubmitted :: MonadThrow m => ByteString -> m NakadiException
- errorBatchNotSubmitted :: MonadThrow m => ByteString -> m NakadiException
- setRequestQueryParameters :: [(ByteString, ByteString)] -> Request -> Request
Documentation
setRequestCheckStatus :: Request -> Request #
Modify the request so that non-2XX status codes generate a runtime
StatusCodeException
, by using throwErrorStatusCodes
Since: http-client-0.5.13
setRequestIgnoreStatus :: Request -> Request #
Modify the request so that non-2XX status codes do not generate a runtime
StatusCodeException
.
Since: http-client-0.4.29
A default request value, a GET request of localhost/:80, with an empty request body.
Note that the default checkResponse
does nothing.
Since: http-client-0.4.30
parseRequest_ :: String -> Request #
Same as parseRequest
, but parse errors cause an impure exception.
Mostly useful for static strings which are known to be correctly
formatted.
parseRequest :: MonadThrow m => String -> m Request #
Convert a URL into a Request
.
This function defaults some of the values in Request
, such as setting method
to
GET
and requestHeaders
to []
.
Since this function uses MonadThrow
, the return monad can be anything that is
an instance of MonadThrow
, such as IO
or Maybe
.
You can place the request method at the beginning of the URL separated by a space, e.g.:
@@
parseRequest "POST http://httpbin.org/post"
@@
Note that the request method must be provided as all capital letters.
A Request
created by this function won't cause exceptions on non-2XX
response status codes.
To create a request which throws on non-2XX status codes, see parseUrlThrow
Since: http-client-0.4.30
data HttpException #
An exception which may be generated by this library
Since: http-client-0.5.0
HttpExceptionRequest Request HttpExceptionContent | Most exceptions are specific to a Since: http-client-0.5.0 |
InvalidUrlException String String | A URL (first field) is invalid for a given reason (second argument). Since: http-client-0.5.0 |
Instances
Show HttpException | |
Defined in Network.HTTP.Client.Types showsPrec :: Int -> HttpException -> ShowS # show :: HttpException -> String # showList :: [HttpException] -> ShowS # | |
Exception HttpException | |
Defined in Network.HTTP.Client.Types | |
HasNakadiHttpErrorCallback (Config m) (Maybe (HttpErrorCallback m)) | |
Defined in Network.Nakadi.Internal.Lenses httpErrorCallback :: Lens' (Config m) (Maybe (HttpErrorCallback m)) |
proxyHost :: Proxy -> ByteString #
The host name of the HTTP proxy.
All information on how to connect to a host and what should be sent in the HTTP request.
If you simply wish to download from a URL, see parseRequest
.
The constructor for this data type is not exposed. Instead, you should use
either the defaultRequest
value, or parseRequest
to
construct from a URL, and then use the records below to make modifications.
This approach allows http-client to add configuration options without
breaking backwards compatibility.
For example, to construct a POST request, you could do something like:
initReq <- parseRequest "http://www.example.com/path" let req = initReq { method = "POST" }
For more information, please see http://www.yesodweb.com/book/settings-types.
Since 0.1.0
Instances
A simple representation of the HTTP response.
Since 0.1.0
Instances
getResponseBody :: Response a -> a #
Get the response body
Since: http-conduit-2.1.10
getResponseHeaders :: Response a -> [(HeaderName, ByteString)] #
Get all response headers
Since: http-conduit-2.1.10
getResponseHeader :: HeaderName -> Response a -> [ByteString] #
Get all response header values with the given name
Since: http-conduit-2.1.10
getResponseStatusCode :: Response a -> Int #
Get the integral status code of the response
Since: http-conduit-2.1.10
getResponseStatus :: Response a -> Status #
Get the status of the response
Since: http-conduit-2.1.10
setRequestProxy :: Maybe Proxy -> Request -> Request #
Override the default proxy server settings
Since: http-conduit-2.1.10
setRequestManager :: Manager -> Request -> Request #
Instead of using the default global Manager
, use the supplied
Manager
.
Since: http-conduit-2.1.10
:: ByteString | username |
-> ByteString | password |
-> Request | |
-> Request |
Set basic auth with the given username and password
Since: http-conduit-2.1.10
setRequestBodyURLEncoded :: [(ByteString, ByteString)] -> Request -> Request #
Set the request body as URL encoded data
Note: This will change the request method to POST
and set the content-type
to application/x-www-form-urlencoded
Since: http-conduit-2.1.10
setRequestBodyFile :: FilePath -> Request -> Request #
Set the request body as a file
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
Set the request body as a Source
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
setRequestBodyLBS :: ByteString -> Request -> Request #
Set the request body as a lazy ByteString
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
setRequestBodyJSON :: ToJSON a => a -> Request -> Request #
Set the request body as a JSON value
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
This also sets the Content-Type
to application/json; charset=utf-8
Since: http-conduit-2.1.10
setRequestBody :: RequestBody -> Request -> Request #
Set the request body to the given RequestBody
. You may want to
consider using one of the convenience functions in the modules, e.g.
requestBodyJSON
.
Note: This will not modify the request method. For that, please use
requestMethod
. You likely don't want the default of GET
.
Since: http-conduit-2.1.10
setRequestQueryString :: Query -> Request -> Request #
Set the query string parameters
Since: http-conduit-2.1.10
getRequestQueryString :: Request -> Query #
Get the query string parameters
Since: http-conduit-2.1.10
setRequestHeaders :: RequestHeaders -> Request -> Request #
Set the request headers, wiping out all previously set headers. This
means if you use setRequestHeaders
to set some headers and also use one of
the other setters that modifies the content-type
header (such as
setRequestBodyJSON
), be sure that setRequestHeaders
is evaluated
first.
Since: http-conduit-2.1.10
setRequestHeader :: HeaderName -> [ByteString] -> Request -> Request #
Set the given request header to the given list of values. Removes any previously set header values with the same name.
Since: http-conduit-2.1.10
getRequestHeader :: HeaderName -> Request -> [ByteString] #
Get all request header values for the given name
Since: http-conduit-2.1.10
addRequestHeader :: HeaderName -> ByteString -> Request -> Request #
Add a request header name/value combination
Since: http-conduit-2.1.10
setRequestPath :: ByteString -> Request -> Request #
Lens for the requested path info of the request
Since: http-conduit-2.1.10
setRequestPort :: Int -> Request -> Request #
Set the destination port of the request
Since: http-conduit-2.1.10
setRequestHost :: ByteString -> Request -> Request #
Set the destination host of the request
Since: http-conduit-2.1.10
setRequestSecure :: Bool -> Request -> Request #
Set whether this is a secureHTTPS (True
) or insecureHTTP
(False
) request
Since: http-conduit-2.1.10
setRequestMethod :: ByteString -> Request -> Request #
Set the request method
Since: http-conduit-2.1.10
httpLbs :: MonadIO m => Request -> m (Response ByteString) #
Alternate spelling of httpLBS
Since: http-conduit-2.1.10
parseRequestThrow_ :: String -> Request #
Same as parseRequestThrow
, but parse errors cause an impure
exception. Mostly useful for static strings which are known to be
correctly formatted.
Since: http-conduit-2.3.2
parseRequestThrow :: MonadThrow m => String -> m Request #
Same as parseRequest
, except will throw an HttpException
in the
event of a non-2XX response. This uses throwErrorStatusCodes
to
implement checkResponse
.
Exactly the same as parseUrlThrow
, but has a name that is more
consistent with the other parseRequest functions.
Since: http-conduit-2.3.2
withResponse :: (MonadUnliftIO m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> m a) -> m a #
Perform an action with the given request. This employes the bracket pattern.
This is similar to httpSource
, but does not require
MonadResource
and allows the result to not contain a ConduitM
value.
Since: http-conduit-2.2.3
httpSource :: (MonadResource m, MonadIO n) => Request -> (Response (ConduitM i ByteString n ()) -> ConduitM i o m r) -> ConduitM i o m r #
Perform an HTTP request, and get the response body as a Source.
The second argument to this function tells us how to make the
Source from the Response itself. This allows you to perform actions
with the status or headers, for example, in addition to the raw
bytes themselves. If you just care about the response body, you can
use getResponseBody
as the second argument here.
{-# LANGUAGE OverloadedStrings #-} import Control.Monad.IO.Class (liftIO) import Control.Monad.Trans.Resource (runResourceT) import Data.Conduit (($$)) import qualified Data.Conduit.Binary as CB import qualified Data.Conduit.List as CL import Network.HTTP.Simple import System.IO (stdout) main :: IO () main = runResourceT $ httpSource "http://httpbin.org/robots.txt" getSrc $$ CB.sinkHandle stdout where getSrc res = do liftIO $ print (getResponseStatus res, getResponseHeaders res) getResponseBody res
Since: http-conduit-2.2.1
httpSink :: MonadUnliftIO m => Request -> (Response () -> ConduitM ByteString Void m a) -> m a #
Perform an HTTP request and consume the body with the given Sink
Since: http-conduit-2.1.10
httpJSONEither :: (MonadIO m, FromJSON a) => Request -> m (Response (Either JSONException a)) #
Perform an HTTP request and parse the body as JSON. In the event of an
JSON parse errors, a Left
value will be returned.
Since: http-conduit-2.1.10
httpJSON :: (MonadIO m, FromJSON a) => Request -> m (Response a) #
Perform an HTTP request and parse the body as JSON. In the event of an
JSON parse errors, a JSONException
runtime exception will be thrown.
Since: http-conduit-2.1.10
httpNoBody :: MonadIO m => Request -> m (Response ()) #
Perform an HTTP request and ignore the response body.
Since: http-conduit-2.2.2
httpLBS :: MonadIO m => Request -> m (Response ByteString) #
Perform an HTTP request and return the body as a lazy
ByteString
. Note that the entire value will be read into memory
at once (no lazy I/O will be performed). The advantage of a lazy
ByteString
here (versus using httpBS
) is--if needed--a better
in-memory representation.
Since: http-conduit-2.1.10
httpBS :: MonadIO m => Request -> m (Response ByteString) #
Perform an HTTP request and return the body as a ByteString
.
Since: http-conduit-2.2.4
data JSONException #
An exception that can occur when parsing JSON
Since: http-conduit-2.1.10
JSONParseException Request (Response ()) ParseError | |
JSONConversionException Request (Response Value) String |
Instances
Show JSONException | |
Defined in Network.HTTP.Simple showsPrec :: Int -> JSONException -> ShowS # show :: JSONException -> String # showList :: [JSONException] -> ShowS # | |
Exception JSONException | |
Defined in Network.HTTP.Simple |
type ResponseHeaders = [Header] #
Response Headers
type RequestHeaders = [Header] #
Request Headers
type Header = (HeaderName, ByteString) #
Header
Query.
General form: a=b&c=d
, but if the value is Nothing, it becomes
a&c=d
.
type QueryItem = (ByteString, Maybe ByteString) #
Query item
module Network.HTTP.Types.Status
type StreamConnectCallback m = Response () -> m () Source #
Config
type HttpErrorCallback m = Request -> HttpException -> RetryStatus -> Bool -> m () Source #
Type synonym for user-provided callbacks which are used for HTTP Errror propagation.
Config | |
|
Instances
data HttpBackend b Source #
HttpBackend | |
|
Instances
HasNakadiHttp (Config m) (HttpBackend m) | |
Defined in Network.Nakadi.Internal.Lenses http :: Lens' (Config m) (HttpBackend m) | |
HasNakadiHttpResponseOpen (HttpBackend b) (Config b -> Request -> Maybe Manager -> b (Response (ConduitM () ByteString b ()))) | |
Defined in Network.Nakadi.Internal.Lenses httpResponseOpen :: Lens' (HttpBackend b) (Config b -> Request -> Maybe Manager -> b (Response (ConduitM () ByteString b ()))) | |
HasNakadiHttpResponseClose (HttpBackend b) (Response () -> b ()) | |
Defined in Network.Nakadi.Internal.Lenses httpResponseClose :: Lens' (HttpBackend b) (Response () -> b ()) | |
HasNakadiHttpLbs (HttpBackend b) (Config b -> Request -> Maybe Manager -> b (Response ByteString)) | |
Defined in Network.Nakadi.Internal.Lenses httpLbs :: Lens' (HttpBackend b) (Config b -> Request -> Maybe Manager -> b (Response ByteString)) |
data WorkerConfig Source #
Instances
HasNakadiNThreads WorkerConfig Int | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiWorker (Config m) WorkerConfig | |
Defined in Network.Nakadi.Internal.Lenses worker :: Lens' (Config m) WorkerConfig |
data SubscriptionStatsConf Source #
Instances
HasNakadiShowTimeLag SubscriptionStatsConf Bool | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiSubscriptionStats (Config m) (Maybe SubscriptionStatsConf) | |
Defined in Network.Nakadi.Internal.Lenses |
data SubscriptionCursorWithCounter Source #
Instances
HasNakadiCursor SubscriptionCursorWithCounter SubscriptionCursor | |
HasNakadiNEvents SubscriptionCursorWithCounter Int | |
type StagedCursorsMap a = HashMap (EventTypeName, PartitionName) a Source #
data NakadiException Source #
Instances
Show NakadiException Source # | |
Defined in Network.Nakadi.Internal.Types.Exceptions showsPrec :: Int -> NakadiException -> ShowS # show :: NakadiException -> String # showList :: [NakadiException] -> ShowS # | |
Exception NakadiException Source # | |
type LogFunc m = LogSource -> LogLevel -> LogStr -> m () Source #
Type of a logger callback provided to nakadi-client for logging purposes.
Type for RFC7807 Problem
objects.
Problem | |
|
Instances
newtype CursorOffset Source #
Type for cursor offsets.
CursorOffset | |
|
Instances
newtype EventTypeName Source #
Type for event type names.
EventTypeName | |
|
Instances
newtype PartitionName Source #
Type for partition names.
PartitionName | |
|
Instances
newtype PartitionCompactionKey Source #
Type for partition compaction keys.
PartitionCompactionKey | |
|
Instances
newtype CursorToken Source #
Type for cursor tokens.
Instances
Type for cursors.
Instances
newtype ApplicationName Source #
Type for application names.
Instances
data SubscriptionCursor Source #
Type fo rsubscription cursors.
SubscriptionCursor | |
|
Instances
data SubscriptionCursorWithoutToken Source #
Type for subscription cursors without token.
SubscriptionCursorWithoutToken | |
|
Instances
newtype SubscriptionCursorCommit Source #
Type for commit object for subscription cursor committing.
SubscriptionCursorCommit | |
|
Instances
newtype CursorCommit Source #
Type for commit objects for cursor committing.
Instances
newtype SubscriptionId Source #
Type for subscription IDs.
SubscriptionId | |
|
Instances
Type for stream IDs.
StreamId | |
|
Instances
Eq StreamId Source # | |
Ord StreamId Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
Show StreamId Source # | |
Generic StreamId Source # | |
ToJSON StreamId Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON StreamId Source # | |
HasNakadiStreamId SubscriptionEventStream StreamId | |
HasNakadiId StreamId Text | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiStreamId PartitionStat (Maybe StreamId) | |
Defined in Network.Nakadi.Internal.Lenses | |
type Rep StreamId Source # | |
Defined in Network.Nakadi.Internal.Types.Service |
data SubscriptionEventStream Source #
SubscriptionEventStream
Instances
Show SubscriptionEventStream Source # | |
Defined in Network.Nakadi.Internal.Types.Service showsPrec :: Int -> SubscriptionEventStream -> ShowS # show :: SubscriptionEventStream -> String # showList :: [SubscriptionEventStream] -> ShowS # | |
HasNakadiStreamId SubscriptionEventStream StreamId | |
HasNakadiSubscriptionId SubscriptionEventStream SubscriptionId | |
Type for timestamps.
Timestamp | |
|
Instances
Eq Timestamp Source # | |
Ord Timestamp Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
Show Timestamp Source # | |
Generic Timestamp Source # | |
Hashable Timestamp Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
ToJSON Timestamp Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON Timestamp Source # | |
HasNakadiOccurredAt EventMetadata Timestamp | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiOccurredAt EventMetadataEnriched Timestamp | |
HasNakadiReceivedAt EventMetadataEnriched Timestamp | |
HasNakadiCreatedAt Subscription Timestamp | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiUTCTime Timestamp UTCTime | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiCreatedAt EventTypeSchema (Maybe Timestamp) | |
Defined in Network.Nakadi.Internal.Lenses | |
type Rep Timestamp Source # | |
Defined in Network.Nakadi.Internal.Types.Service |
A Flow ID.
Instances
Eq FlowId Source # | |
Ord FlowId Source # | |
Show FlowId Source # | |
IsString FlowId Source # | |
Defined in Network.Nakadi.Internal.Types.Service fromString :: String -> FlowId # | |
Generic FlowId Source # | |
ToJSON FlowId Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON FlowId Source # | |
HasNakadiFlowId EventMetadataEnriched (Maybe FlowId) | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiFlowId (Config m) (Maybe FlowId) | |
type Rep FlowId Source # | |
Defined in Network.Nakadi.Internal.Types.Service |
ID of an Event
Instances
Eq EventId Source # | |
Ord EventId Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
Show EventId Source # | |
Generic EventId Source # | |
Hashable EventId Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
ToJSON EventId Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON EventId Source # | |
HasNakadiEid EventMetadata EventId | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiEid EventMetadataEnriched EventId | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiId EventId UUID | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiParentEids EventMetadata (Maybe [EventId]) | |
Defined in Network.Nakadi.Internal.Lenses parentEids :: Lens' EventMetadata (Maybe [EventId]) | |
HasNakadiParentEids EventMetadataEnriched (Maybe [EventId]) | |
Defined in Network.Nakadi.Internal.Lenses | |
type Rep EventId Source # | |
Defined in Network.Nakadi.Internal.Types.Service |
Partition Data
Partition | |
|
Instances
Show Partition Source # | |
ToJSON Partition Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON Partition Source # | |
HasNakadiPartition Partition PartitionName | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiOldestAvailableOffset Partition CursorOffset | |
HasNakadiNewestAvailableOffset Partition CursorOffset | |
HasNakadiUnconsumedEvents Partition (Maybe Int64) | |
Defined in Network.Nakadi.Internal.Lenses |
data ShiftedCursor Source #
Type for shift-cursor queries.
ShiftedCursor | |
|
Instances
data CursorDistanceQuery Source #
Type for cursor-distance queries. Represents the request to compute the distance between initial cursor and final cursor.
CursorDistanceQuery | |
|
Instances
newtype CursorDistanceResult Source #
Type for results of cursor-distance-queries.
Instances
data SubscriptionReadFrom Source #
This type models the "read_from" field contained in subscription objects.
Instances
data SubscriptionPosition Source #
Type modelling a subscription position.
SubscriptionPositionBegin | |
SubscriptionPositionEnd | |
SubscriptionPositionCursors [SubscriptionCursorWithoutToken] |
Instances
subscriptionPositionToObject :: SubscriptionPosition -> Object Source #
Internal helper function for converting a SubscriptionPosition
into a
JSON Object (not a JSON Value). Removes the need for partial pattern matching later.
newtype ConsumerGroup Source #
This type models the value describing the use case of a subscription. In general this is an additional identifier used to differ subscriptions having the same owning application and event types.
Instances
data Subscription Source #
Type for a Subscription which has already been created.
When a subscription object is retrieved from Nakadi the following fields are regarded as mandatory:
id
owning_application
event_types
consumer_group
created_at
read_from
- depending on
read_from
alsocursors
.
Instances
data SubscriptionRequest Source #
Type for a Subscription which is to be created.
When a subscription is to be created the following fields are regarded as mandatory in the subscription object:
owning_application
event_types
The remaining fields are regarded as optional:
consumer_group
read_from
- depending on
read_from
the fieldcursors
might have to be present as well.
Instances
data PublishingStatus Source #
Type for publishing status.
Instances
Step
Instances
Eq Step Source # | |
Ord Step Source # | |
Show Step Source # | |
Generic Step Source # | |
Hashable Step Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
ToJSON Step Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON Step Source # | |
type Rep Step Source # | |
Defined in Network.Nakadi.Internal.Types.Service type Rep Step = D1 (MetaData "Step" "Network.Nakadi.Internal.Types.Service" "nakadi-client-0.7.0.0-KOzkX3CyJmv3p5G5yolcIB" False) ((C1 (MetaCons "StepNone" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "StepValidating" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "StepPartitioning" PrefixI False) (U1 :: Type -> Type) :+: (C1 (MetaCons "StepEnriching" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "StepPublishing" PrefixI False) (U1 :: Type -> Type)))) |
data BatchItemResponse Source #
In case of failures during batch publishing, Nakadi returns detailed information about which events failed to be published. This per-event information is a batch item response.
Instances
newtype StreamKeepAliveLimit Source #
StreamKeepAliveLimit
Instances
newtype BatchFlushTimeout Source #
BatchFlushTimeout
Instances
data CursorCommitResultType Source #
CursorCommitResultType
Instances
data CursorCommitResult Source #
CursorCommitResult
Instances
newtype CursorCommitResults Source #
Instances
data SchemaType Source #
SchemaType
Instances
newtype SchemaVersion Source #
Type for the version of a schema.
Instances
data EventTypeSchema Source #
Type for the schema of an event type.
EventTypeSchema | |
|
Instances
newtype PaginationLink Source #
PaginationLink
Instances
data PaginationLinks Source #
PaginationLinks
Instances
data EventTypeSchemasResponse Source #
EventTypeSchemasResponse
Instances
data SubscriptionsListResponse Source #
SubscriptionsListResponse
Instances
Type for offset values.
Type for limit values.
data PartitionState Source #
Type for partition states.
Instances
data PartitionStat Source #
Type for per-partition statistics.
Instances
data SubscriptionEventTypeStats Source #
Nakadi type SubscriptionEventTypeStats
.
Instances
newtype SubscriptionStats Source #
Type modelling per-subscription statistics. Objects of this type are returned by requests to subscriptionsSUBSCRIPTION-ID/stats.
Instances
data EventTypeCategory Source #
Instances
data PartitionStrategy Source #
Type for a partitioning strategy.
Instances
data EnrichmentStrategy Source #
Type for an enrichment stragey.
Instances
data CompatibilityMode Source #
Type for an event type compatibility mode.
Instances
data CleanupPolicy Source #
Type for cleanup policy.
Instances
newtype PartitionKeyField Source #
Type for a partitioning key field.
Instances
data EventTypeStatistics Source #
Type for event type statistics.
Instances
data EventTypeOptions Source #
Type for event type options.
Instances
EventType
Instances
data EventMetadata Source #
Type of published event metadata values.
Instances
data EventMetadataEnriched Source #
Type of event metadata enriched by Nakadi
Instances
data SubscriptionEventStreamBatch a Source #
SubscriptionEventStreamBatch
SubscriptionEventStreamBatch | |
|
Instances
Type for "data_op" as contained in the DataChangeEvent.
Instances
Eq DataOp Source # | |
Ord DataOp Source # | |
Show DataOp Source # | |
ToJSON DataOp Source # | |
Defined in Network.Nakadi.Internal.Types.Service | |
FromJSON DataOp Source # | |
HasNakadiDataOp (DataChangeEvent a) DataOp | |
Defined in Network.Nakadi.Internal.Lenses dataOp :: Lens' (DataChangeEvent a) DataOp | |
HasNakadiDataOp (DataChangeEventEnriched a) DataOp | |
Defined in Network.Nakadi.Internal.Lenses dataOp :: Lens' (DataChangeEventEnriched a) DataOp |
data DataChangeEvent a Source #
DataChangeEvent
Instances
data DataChangeEventEnriched a Source #
A DataChangeEvent enriched by Nakadi
Instances
data BusinessEvent a Source #
Type modelling a "Business Event". Their JSON encodings are special since the payload
object is directly enriched with a metadata
field. "Data Change Events" on the other side
are JSON-encoded such that the complete event payload is contained in a seperate object field.
On the Haskell API side we split payload from meta data, which requires us to write custom
ToJSON
and FromJSON
implementations.
BusinessEvent | |
|
Instances
data BusinessEventEnriched a Source #
Type modelling a Nakadi-enriched "Business Event". JSON encoding is basically the same as for the non-enriched Business Events.
Instances
makeFieldRenamer :: [(String, String)] -> String -> String Source #
Construct a field renamer function from a field renamer map.
class (Monad b, Monad m) => MonadNakadiBase b m where Source #
Nothing
nakadiLiftBase :: b a -> m a Source #
nakadiLiftBase :: (MonadNakadiBase b n, MonadTrans t, m ~ t n) => b a -> m a Source #
Instances
newtype NakadiBaseT m a Source #
NakadiBaseT | |
|
Instances
data CommitStrategy Source #
This type encodes the supported strategies for subscription cursor committing.
CommitSync | This strategy synchronously commits every cursor. |
CommitAsync CommitBufferingStrategy | This strategy sends cursors to be committed to a dedicated thread responsible for committing them. Cursors are commited one by one, without special buffering logic. |
Instances
HasNakadiCommitStrategy (Config m) CommitStrategy | |
Defined in Network.Nakadi.Internal.Lenses commitStrategy :: Lens' (Config m) CommitStrategy |
data CommitBufferingStrategy Source #
This type encodes the supported buffering strategies for asynchronous subscription cursor committing.
CommitNoBuffer | No buffering at all. |
CommitTimeBuffer Int32 | Buffer for the specified duration, given in milliseconds. |
CommitSmartBuffer | Buffer for a fixed duration, but
committing cursors immediately if the
number of events processed since the
last commit crosses a threshold derived
from |
newtype CommitTimeout Source #
This type is used for specifying subscription commit timeouts in seconds.
Instances
Eq CommitTimeout Source # | |
Defined in Network.Nakadi.Internal.Types.Subscriptions (==) :: CommitTimeout -> CommitTimeout -> Bool # (/=) :: CommitTimeout -> CommitTimeout -> Bool # | |
Ord CommitTimeout Source # | |
Defined in Network.Nakadi.Internal.Types.Subscriptions compare :: CommitTimeout -> CommitTimeout -> Ordering # (<) :: CommitTimeout -> CommitTimeout -> Bool # (<=) :: CommitTimeout -> CommitTimeout -> Bool # (>) :: CommitTimeout -> CommitTimeout -> Bool # (>=) :: CommitTimeout -> CommitTimeout -> Bool # max :: CommitTimeout -> CommitTimeout -> CommitTimeout # min :: CommitTimeout -> CommitTimeout -> CommitTimeout # | |
Show CommitTimeout Source # | |
Defined in Network.Nakadi.Internal.Types.Subscriptions showsPrec :: Int -> CommitTimeout -> ShowS # show :: CommitTimeout -> String # showList :: [CommitTimeout] -> ShowS # | |
HasNakadiCommitTimeout (Config m) (Maybe CommitTimeout) | |
Defined in Network.Nakadi.Internal.Lenses commitTimeout :: Lens' (Config m) (Maybe CommitTimeout) |
Data type denoting an asynchronous worker.
Instances
HasNakadiQueue (Worker a) (TBQueue (SubscriptionEventStreamBatch a)) | |
Defined in Network.Nakadi.Internal.Lenses queue :: Lens' (Worker a) (TBQueue (SubscriptionEventStreamBatch a)) | |
HasNakadiAsync (Worker a) (Async ()) | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiWorkers (WorkerRegistry a) (NonEmpty (Worker a)) | |
Defined in Network.Nakadi.Internal.Lenses workers :: Lens' (WorkerRegistry a) (NonEmpty (Worker a)) |
data WorkerRegistry a Source #
Data type containing a non-empty list of worker references.
Instances
HasNakadiPartitionIndexMap (WorkerRegistry a) PartitionIndexMap | |
Defined in Network.Nakadi.Internal.Lenses | |
HasNakadiWorkers (WorkerRegistry a) (NonEmpty (Worker a)) | |
Defined in Network.Nakadi.Internal.Lenses workers :: Lens' (WorkerRegistry a) (NonEmpty (Worker a)) |
type PartitionIndexMap = HashMap (PartitionName, EventTypeName) Int Source #
Map used for mapping subscription batch cursors to worked indices.
class HasNakadiConfig b r | r -> b where Source #
nakadiConfig :: r -> Config b Source #
class (MonadNakadiBase b m, MonadThrow b, MonadMask b, MonadThrow m, MonadCatch m) => MonadNakadi b m | m -> b where Source #
The MonadNakadi
typeclass is implemented by monads in which
Nakadi can be called. The first parameter (b
) denotes the `base
monad`. This is the monad in which the core actions are run. This
includes executing (non-streaming) HTTP requests and running
user-provided callbacks. The typeclass provides methods for
* retrieving the Nakadi configuration
* locally changing the Nakadi configuration
* extracting specific Nakadi configuration values
* lifting actions from the
The MonadNakadi
typeclass is modelled closely after MonadReader
.
Nothing
nakadiAsk :: m (Config b) Source #
nakadiAsk :: (MonadNakadi b n, MonadTrans t, m ~ t n) => m (Config b) Source #
Instances
MonadNakadi IO IO Source # | |
MonadNakadi b m => MonadNakadi b (ResourceT m) Source # | |
MonadNakadi b m => MonadNakadi b (NoLoggingT m) Source # | |
Defined in Network.Nakadi.Internal.Types nakadiAsk :: NoLoggingT m (Config b) Source # | |
MonadNakadi b m => MonadNakadi b (LoggingT m) Source # | |
MonadNakadi b m => MonadNakadi b (StateT s m) Source # |
|
MonadNakadi b m => MonadNakadi b (StateT s m) Source # |
|
(MonadNakadi b m, Monoid w) => MonadNakadi b (WriterT w m) Source # |
|
(MonadNakadi b m, Monoid w) => MonadNakadi b (WriterT w m) Source # |
|
(MonadCatch m, MonadMask b, MonadNakadiBase b (NakadiT b m)) => MonadNakadi b (NakadiT b m) Source # | |
(MonadMask b, MonadCatch m, MonadNakadiBase b (ReaderT r m), HasNakadiConfig b r) => MonadNakadi b (ReaderT r m) Source # | |
type MonadNakadiIO = MonadNakadi IO Source #
newtype NakadiT b m a Source #
NakadiT | |
|
Instances
runNakadiT :: Config b -> NakadiT b m a -> m a Source #
httpJsonBody :: (MonadNakadi b m, FromJSON a) => Status -> [(Status, ByteString -> m NakadiException)] -> (Request -> Request) -> m a Source #
httpJsonNoBody :: MonadNakadi b m => Status -> [(Status, ByteString -> m NakadiException)] -> (Request -> Request) -> m () Source #
httpJsonBodyStream :: forall b m r. (MonadNakadi b m, MonadMask m) => Status -> [(Status, ByteString -> m NakadiException)] -> (Request -> Request) -> (Response (ConduitM () ByteString m ()) -> m r) -> m r Source #
:: MonadNakadi b m | |
=> (Request -> Request) | Pure request modifier |
-> m Request | Resulting request to execute |
:: (FromJSON a, MonadNakadi b m) | |
=> ConduitM ByteString a m () | Conduit deserializing bytestrings into custom values |
If no deserializationFailureCallback is set in the provided configuration (which is the default), a DeserializationFailureCallback exception will be thrown. Otherwise, simply run the callback.
errorClientNotAuthenticated :: MonadThrow m => ByteString -> m NakadiException Source #
errorUnprocessableEntity :: MonadThrow m => ByteString -> m NakadiException Source #
errorAccessForbidden :: MonadThrow m => ByteString -> m NakadiException Source #
errorTooManyRequests :: MonadThrow m => ByteString -> m NakadiException Source #
errorBadRequest :: MonadThrow m => ByteString -> m NakadiException Source #
errorSubscriptionNotFound :: MonadThrow m => ByteString -> m NakadiException Source #
errorCursorAlreadyCommitted :: MonadThrow m => ByteString -> m NakadiException Source #
errorCursorResetInProgress :: MonadThrow m => ByteString -> m NakadiException Source #
errorEventTypeNotFound :: MonadThrow m => ByteString -> m NakadiException Source #
errorSubscriptionExistsAlready :: MonadThrow m => ByteString -> m NakadiException Source #
errorBatchPartiallySubmitted :: MonadThrow m => ByteString -> m NakadiException Source #
errorBatchNotSubmitted :: MonadThrow m => ByteString -> m NakadiException Source #
setRequestQueryParameters :: [(ByteString, ByteString)] -> Request -> Request Source #