Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Network.Craze.Types
- type RacerHandler headerTy bodyTy a = CurlResponse_ headerTy bodyTy -> IO a
- type RacerChecker a = a -> Bool
- type RacerProvider = IO ProviderOptions
- data ProviderOptions = ProviderOptions {}
- data ClientStatus a
- = Successful a
- | Failed a
- | Errored SomeException
- | Pending
- data RacerResult a = RacerResult {
- rrResponse :: Maybe a
- rrWinner :: Maybe ProviderOptions
- rrProviders :: [RacerProvider]
- rrStatuses :: [(Text, ClientStatus a)]
- data Racer headerTy bodyTy a = Racer {
- racerHandler :: RacerHandler headerTy bodyTy a
- racerChecker :: RacerChecker a
- racerProviders :: [RacerProvider]
- racerDebug :: Bool
- racerReturnLast :: Bool
Documentation
type RacerHandler headerTy bodyTy a = CurlResponse_ headerTy bodyTy -> IO a Source
A RacerHandler
is simply a function for transforming a response after it
is received. The handler is only applied to successful requests before they
are checked by the RacerChecker
.
This is primarily for extracting or parsing a CurlResponse_
before doing
any further work. The type returned by the handler will be used as the
input of the checker and will be the return type of functions like
raceGet
.
type RacerChecker a = a -> Bool Source
A function that computes whether or not a result is valid or not.
A racer will discard successful responses it get from its clients if they do not pass the checker.
This step allows the racer to potentially discard responses that, while technically successful, do not contain the expected result (e.g. APIs that return errors as HTTP 200s, rate limitting messages, or unexpected formats).
type RacerProvider = IO ProviderOptions Source
A provider is simply a factory function for ProviderOptions
, which are
used to configure a client.
data ProviderOptions Source
Configuration used to set up an individual client in the race.
Constructors
ProviderOptions | |
Fields
|
Instances
data ClientStatus a Source
The status of running a single client.
Constructors
Successful a | A successful response (passed the checker). A race will usually only have one successful response. |
Failed a | A response that was received but failed to pass the checker. |
Errored SomeException | An exception thrown while using the client. |
Pending | The operation is still pending, was cancelled, or was never started. |
Instances
Show a => Show (ClientStatus a) Source |
data RacerResult a Source
The result of a racing operation. This can be used to collect statistics on which providers win more often, etc.
Constructors
RacerResult | |
Fields
|
data Racer headerTy bodyTy a Source
A record describing the rules for racing requests.
Constructors
Racer | |
Fields
|
Instances
Default (Racer [(String, String)] ByteString ByteString) Source |