Safe Haskell | None |
---|
- class (MonadBaseControl IO m, MonadIO m) => MonadKRPC h m | m -> h where
- getManager :: m (Manager h)
- liftHandler :: h a -> m a
- data Manager h
- newManager :: SockAddr -> [Handler h] -> IO (Manager h)
- closeManager :: Manager m -> IO ()
- withManager :: SockAddr -> [Handler h] -> (Manager h -> IO a) -> IO a
- query :: forall h m a b. (MonadKRPC h m, KRPC a b) => SockAddr -> a -> m b
- type Handler h = (MethodName, HandlerBody h)
- handler :: forall h a b. (KRPC a b, Monad h) => (SockAddr -> a -> h b) -> Handler h
- listener :: MonadKRPC h m => m ()
- listen :: MonadKRPC h m => m ()
Documentation
class (MonadBaseControl IO m, MonadIO m) => MonadKRPC h m | m -> h whereSource
A monad which can perform or handle queries.
getManager :: m (Manager h)Source
Ask for manager.
liftHandler :: h a -> m aSource
Can be used to add logging for instance.
Keep track pending queries made by this node and handle queries made by remote nodes.
:: SockAddr | address to listen on; |
-> [Handler h] | handlers to run on incoming queries. |
-> IO (Manager h) | new manager. |
Bind socket to the specified address. To enable query handling
run listen
.
closeManager :: Manager m -> IO ()Source
Unblock all pending calls and close socket.
withManager :: SockAddr -> [Handler h] -> (Manager h -> IO a) -> IO aSource
Normally you should use Control.Monad.Trans.Resource.allocate function.
query :: forall h m a b. (MonadKRPC h m, KRPC a b) => SockAddr -> a -> m bSource
Enqueue query to the given node.
This function will throw exception if quered node respond with
error
message or timeout expires.
type Handler h = (MethodName, HandlerBody h)Source
Handler is a function which will be invoked then some remote node querying this node.