Code Monkey home page Code Monkey logo

out-of-proc-server's Introduction

Out-of-proc Server

Launch the gRPC server (or other type of server) on demand from the application.

Out-of-proc-server (+ gRPC) provides interoperability between Node.js JavaScript and .NET framework (and other languages you additionally implement the "out-of-proc-server" sequence).

It helps you to create the desktop applications based on distributed architecture.


Install

Node.js

Prerequirements

  • Node >= 10
$ npm install out-of-proc-server --save

.NET framework

Note: We have not published this to NuGet yet.

Prerequirements

  • .NET Core SDK >= 2.1

Install

  1. Download the source archive from https://github.com/shellyln/out-of-proc-server/archive/master.zip and extract it.
  2. Add src/dotnet/OutOfProcServer/OutOfProcServer.csproj to your solution.

Usage

See examples.


APIs

Node.js

launchServer

[Call from gRPC Client (Pipe Server)]
Launch the out-of-proc server process.

interface ServerContext {
    serverPipe: Server;
    conn: Socket;
    childProc: ChildProcess;
    shutdown: () => Promise<void>;
}

function launchServer(pipeName: string, command: string, args: string[], spawnOpts?: SpawnOptions): Promise<ServerContext>
  • returns : launched server process info.
    • promise will resolved when the server process connect to the pipe.
  • pipeName : name of the named pipe.
  • command : executable path.
  • args : command line arguments.
  • spawnOpts : options of child_process.spawn().

ServerContext#shutdown

[Call from gRPC Client (Pipe Server)]
Close the server pipe and end listening.

function shutdown(): Promise<void>
  • returns : none.
    • promise will resolved when the pipe is closed.

notifyReadyToClient

[Call from gRPC Server (Pipe Client)]
Notify to the client process that the out-of-proc server is ready to accept the requests.

function notifyReadyToClient(pipeName: string, handler: (event: string, eventArg?: any) => void): Socket;
  • returns : Socket of client pipe.
  • pipeName : name of the named pipe.
  • handler : event handler that called if 'close' or 'error' event is occured to the client pipe.

.NET framework

Launcher.LaunchServer

[Call from gRPC Client (Pipe Server)]
Launch the out-of-proc server process.

public static ServerContext LaunchServer(string pipeName, string command, string[] args);
  • returns : launched server process info.
  • pipeName : name of the named pipe.
  • command : executable path.
  • args : command line arguments.

ServerContext#Shutdown

[Call from gRPC Client (Pipe Server)]
Close the server pipe and end listening.

public ServerContext Shutdown();
  • returns : this object.

Notifier.NotifyReadyToClient

[Call from gRPC Server (Pipe Client)]
Notify to the client process that the out-of-proc server is ready to accept the requests.

public static Notifier NotifyReadyToClient(string pipeName);
  • returns : client pipe info.
  • pipeName : name of the named pipe.

Notifier#Wait

[Call from gRPC Server (Pipe Client)]
Wait forever until the client pipe is closed or broken.

public Notifier Wait();
  • returns : this object.

Notifier#Shutdown

[Call from gRPC Server (Pipe Client)]
Close the client pipe.

public Notifier Shutdown();
  • returns : this object.

Sequence diagram

Note: *nix environments use UNIX domain sockets instead of named pipes.

Graceful shutdown

Graceful

Unexpected shutdown

Unexpected


License

Apache-2.0

Copyright (c) 2019, Shellyl_N and Authors.

License of examples (./examples)

Apache-2.0

Copyright 2015 gRPC authors.
Copyright (c) 2019, Shellyl_N and Authors.

out-of-proc-server's People

Contributors

shellyln avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.