cardano-shell-0.1.0.0
Copyright© 2018-2019 IOHK
LicenseMIT
Safe HaskellNone
LanguageHaskell2010

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

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 ipc child_process.

NodeChannelBadFD Text

The NODE_CHANNEL_FD environment variable has an incorrect value.

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.

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.

runNodeChannel Source #

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 setupNodeChannel

-> 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.