Copyright | (c) Serokell, 2016 |
---|---|
License | GPL-3 (see the file LICENSE) |
Maintainer | Serokell <hi@serokell.io> |
Stability | experimental |
Portability | POSIX, GHC |
Safe Haskell | None |
Language | Haskell2010 |
- data PureRpc m a
- runPureRpc :: (MonadIO m, MonadCatch m, DelaysSpecifier delays) => StdGen -> delays -> PureRpc m a -> m a
- class DelaysSpecifier d where
- newtype Delays = Delays {}
- data ConnectionOutcome
- getRandomTR :: MonadRandom m => (Microsecond, Microsecond) -> m Microsecond
Documentation
Implementation of RPC protocol for emulation, allows to manually define
network nastiness via Delays
datatype. TCP model is used.
List of known issues:
- Method, once being declared in net, can't be removed.
Even
throwTo
won't help. - In implementation, remote method is actually inlined at call position,
so
instance WithNamedLogger
would refer to caller's logger name, not server's one.
MonadTrans PureRpc Source # | |
MonadState s m => MonadState s (PureRpc m) Source # | |
Monad (PureRpc m) Source # | |
Functor (PureRpc m) Source # | |
Applicative (PureRpc m) Source # | |
MonadThrow m => MonadThrow (PureRpc m) Source # | |
MonadIO m => MonadIO (PureRpc m) Source # | |
MonadCatch m => MonadCatch (PureRpc m) Source # | |
(MonadIO m, MonadCatch m) => MonadMask (PureRpc m) Source # | |
WithNamedLogger (PureRpc m) Source # | |
(MonadIO m, MonadCatch m) => MonadTimed (PureRpc m) Source # | |
(MonadIO m, MonadCatch m) => MonadRpc (PureRpc m) Source # | |
type ThreadId (PureRpc m) Source # | |
runPureRpc :: (MonadIO m, MonadCatch m, DelaysSpecifier delays) => StdGen -> delays -> PureRpc m a -> m a Source #
Launches distributed scenario, emulating work of network.
class DelaysSpecifier d where Source #
Describes network nastiness.
DelaysSpecifier () Source # | Connection is never established. |
DelaysSpecifier Microsecond Source # | Specifies permanent connection delay. |
DelaysSpecifier Delays Source # | Detailed description of network nastiness. |
DelaysSpecifier (Microsecond, Microsecond) Source # | Connection delay varies is specified range. |
Allows to describe most complicated behaviour of network.
Examples:
- Always 1 second delay:
Delays $ \_ _ -> return $ ConnectedIn (interval 1 sec)
- Delay varies between 1 and 5 seconds (with granularity of 1 mcs):
Delays $ \_ _ -> ConnectedIn <$> getRandomTR (interval 1 sec, interval 5 sec)
- For first 10 seconds after scenario start connection is established with probability of 1/6:
Delays $ \_ time -> do p <- getRandomR (0, 5) if (p == 0) && (time <= interval 10 sec) then return $ ConnectedIn 0 else return NeverConnected
- Node with address
isolatedAddr
is not accessible:
Delays $ \serverAddr _ -> return if serverAddr == isolatedAddr then NeverConnected else ConnectedIn 0
Delays | |
|
data ConnectionOutcome Source #
Describes obstructions occured on executing RPC request.
ConnectedIn Microsecond | Connection established in specified amout of time. |
NeverConnected | Connection would be never established, client hangs. |
getRandomTR :: MonadRandom m => (Microsecond, Microsecond) -> m Microsecond Source #
Return a randomly-selected time value in specified range.