-
Notifications
You must be signed in to change notification settings - Fork 11
[GH-78] Generalize node IPC so it can be extended. #89
Conversation
| MultiMessage | ||
-- ^ Runs forever responding to messages | ||
deriving (Eq, Show) | ||
|
||
-- | Message expecting from Daedalus | ||
data MsgIn |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Messages that have to be defined.
liftIO $ void $ ipcListener protocolDuration readHandle writeHandle port | ||
|
||
-- | Function for handling the protocol | ||
handleIPCProtocol :: forall m. (MonadIO m) => Port -> MsgIn -> m MsgOut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The protocol handler function, which can be extended.
The Port
is there because it's the simplest way to include it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does extended mean you can have the shell to perform any arbitrary IO
action when handling the message? If so, this LGTM.
At glance I didn't understand why this function has MonadIO constraint
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At glance I didn't understand why this function has MonadIO constraint
It's there to enable adding any kind of message to the protocol.
So if somebody first needs to fetch something or do something with IO
before returning a response, they have nothing to fear (except the amount of freedom).
|
||
-- Fetch message and respond to it | ||
frequencyFunction $ do | ||
msgIn <- readMessage readHandle -- Read message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main reason why I can't generalize the function, we don't know what the type is.
liftIO $ void $ ipcListener protocolDuration readHandle writeHandle port | ||
|
||
-- | Function for handling the protocol | ||
handleIPCProtocol :: forall m. (MonadIO m) => Port -> MsgIn -> m MsgOut |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does extended mean you can have the shell to perform any arbitrary IO
action when handling the message? If so, this LGTM.
At glance I didn't understand why this function has MonadIO constraint
#85
I can't say I really managed to create what I planned to do, but it's still not bad - the protocol handling function is extracted and I have fixed the IPC behavior when running for a longer time (more than a single message).