Copyright | © 2018-2019 IOHK |
---|---|
License | MIT |
Safe Haskell | None |
Language | Haskell2010 |
Cardano.Shell.NodeIPC.General
Description
NodeJS child_process()
IPC message protocol.
See https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options for more information about the message protocol.
Synopsis
- data NodeChannel
- data NodeChannelError
- newtype NodeChannelFinished = NodeChannelFinished IOError
- setupNodeChannel :: IO (Either NodeChannelError NodeChannel)
- runNodeChannel :: (FromJSON msgin, ToJSON msgout) => (Either Text msgin -> IO (Maybe msgout)) -> ((msgout -> IO ()) -> IO a) -> NodeChannel -> IO (Either NodeChannelFinished a)
Documentation
data NodeChannel Source #
A h to the NodeJS parent process.
data NodeChannelError Source #
Possible reasons why the node channel can't be set up.
Constructors
NodeChannelDisabled | This process has not been started as a nodejs |
NodeChannelBadFD Text | The |
Instances
Eq NodeChannelError Source # | |
Defined in Cardano.Shell.NodeIPC.General Methods (==) :: NodeChannelError -> NodeChannelError -> Bool # (/=) :: NodeChannelError -> NodeChannelError -> Bool # | |
Show NodeChannelError Source # | |
Defined in Cardano.Shell.NodeIPC.General Methods showsPrec :: Int -> NodeChannelError -> ShowS # show :: NodeChannelError -> String # showList :: [NodeChannelError] -> ShowS # |
newtype NodeChannelFinished Source #
The only way a node channel finishes on its own is if there is some error reading or writing to its file descriptor.
Constructors
NodeChannelFinished IOError |
setupNodeChannel :: IO (Either NodeChannelError NodeChannel) Source #
Parse the NODE_CHANNEL_FD
variable, if it's set, and returns a h for
communicating with the parent process.
Arguments
:: (FromJSON msgin, ToJSON msgout) | |
=> (Either Text msgin -> IO (Maybe msgout)) | Handler for messages coming from the parent process. Left values are for JSON parse errors. The handler can optionally return a reply message. |
-> ((msgout -> IO ()) -> IO a) | Action to run with the channel. It is passed a function for sending messages to the parent process. |
-> NodeChannel | Channel provided by |
-> IO (Either NodeChannelFinished a) |
Communicate with a parent process using a NodeJS-specific protocol. This
process must have been spawned with one of stdio
array entries set to
.ipc