ide-backend-0.10.0: An IDE backend library

Safe HaskellNone
LanguageHaskell2010

IdeSession.RPC.Client

Synopsis

Documentation

data RpcServer Source

Abstract data type representing RPC servers

data RpcConversation :: *

Constructors

RpcConversation 

Fields

get :: forall a. (Typeable * a, Binary a) => IO a
 
put :: forall a. (Typeable * a, Binary a) => a -> IO ()
 

forkRpcServer Source

Arguments

:: FilePath

Filename of the executable

-> [String]

Arguments

-> Maybe FilePath

Working directory

-> Maybe [(String, String)]

Environment

-> IO RpcServer 

Fork an RPC server as a separate process

forkRpcServer exec args starts executable exec with arguments args ++ args' where args' are internal arguments generated by forkRpcServer. These internal arguments should be passed as arguments to rpcServer.

As a typical example, you might pass ["--server"] as args, and the main function of exec might look like

main = do
  args <- getArgs
  case args of
    "--server" : args' ->
      rpcServer args' <<your request handler>>
    _ ->
      <<deal with other cases>>

connectToRpcServer Source

Arguments

:: FilePath

stdin named pipe

-> FilePath

stdout named pipe

-> FilePath

logfile for storing exceptions

-> (RpcServer -> IO a) 
-> IO a 

Connect to an existing RPC server

It is the responsibility of the caller to make sure that each triplet of named pipes is only used for RPC connection.

rpc :: (Typeable req, Typeable resp, Binary req, Binary resp) => RpcServer -> req -> IO resp Source

Specialized form of rpcConversation to do single request and wait for a single response.

rpcConversation :: RpcServer -> (RpcConversation -> IO a) -> IO a Source

Run an RPC conversation. If the handler throws an exception during the conversation the server is terminated.

shutdown :: RpcServer -> IO () Source

Shut down the RPC server

This simply kills the remote process. If you want to shut down the remote process cleanly you must implement your own termination protocol before calling shutdown.

forceShutdown :: RpcServer -> IO () Source

Force shutdown.

In order to faciliate a force shutdown while another thread may be communicating with the RPC server, we _try_ to update the MVar underlying the RPC server, but if we fail, we terminate the server anyway. This means that this may leave the RpcServer in an invalid state -- so you shouldn't be using it anymore after calling forceShutdown!

data ExternalException :: *

Exceptions thrown by the remote server

Constructors

ExternalException 

Fields

externalStdErr :: String

The output from the server on stderr

externalException :: Maybe IOException

The local exception that was thrown and alerted us to the problem

serverKilledException :: Maybe IOException -> ExternalException

Generic exception thrown if the server gets killed for unknown reason

getRpcExitCode :: RpcServer -> IO (Maybe ExitCode) Source

Get the exit code of the RPC server, unless still running.

Thross an exception for connections to existing RPC servers.