Skip to content
This repository has been archived by the owner on Dec 5, 2017. It is now read-only.
/ michi Public archive

A simple framework for implementing transport-agnostic IPC.

License

Notifications You must be signed in to change notification settings

SnowflakePowered/michi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Michi

NuGet Codecov AppVeyor branch

Michi is a lightweight, barebones framework on implementing inter-process function calls from .NET. Michi does not specify a wire format, handling of consumers must be implemented manually.

With Michi, you can call this:

public class MyCustomObject 
{
  public string StringToEcho { get; }
}

// some class declaration ...

[RemoteFunction("EchoObject", "@")]
public string Echo(MyCustomObject myObject)
{
  return myObject.StringToEcho;
}

[RemoteFunction("Echo", "@")]
public string Echo(string stringToEcho)
{
  return stringToEcho + " from C#!";
}

like this*:

let requestObj = michi.create("EchoObject", "@", { "myObject" : { "StringToEcho" : "Hello World" } });
let response = await michi.request(requestObj);
console.log(response.Result); // "Hello World"

// ...

let requestObj = michi.create("Echo", "@", { "stringToEcho" : "Hello World" } );
let response = await michi.request(requestObj);
console.log(response.Result); // "Hello World from C#!"

or like this

curl -XPOST -d '{ "stringToEcho" : "There's a man they call The Skipper fast asleep" }' 'http://localhost:8080/michi/@/Echo'

Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/json
Vary: Accept-Encoding
X-Michi-Ver: 3.2.0

"There's a man they call The Skipper fast asleep from C#!"

You can do more things too like..

[RemoteFunction("ObjectsAreCool", "@")]
public object EchoObject(string stringToEcho)
{
  return { WhenYou = "Are too lazy to create a real class" };
}

and use that like this..

let requestObj = michi.create("ObjectsAreCool", "@");
let response = await michi.request(requestObj);
console.log(response.Result.WhenYou); // "Are too lazy to create a real class"

You can do even do things like..

[RemoteFunction("Error", "@")]
public void Error()
{
  throw new Exception("Error World!"); //throw a .NET Exception
}

[RemoteFunction("IGotYouFam", "BadIdeas")]
public void Exit()
{
  Environment.Exit(0); //Close everything unexpectedly
}

and call them like this:

let requestObj = michi.create("Error", "@");
let response = await michi.request(requestObj);
console.log(response.IsSuccess); // false
console.log(response.Error.Message); // "Error World!"

// ...

let requestObj = michi.create("IGotYouFam", "BadIdeas");
let response = await michi.request(requestObj);
//Error: WebSocket connection closed unexpectedly by the server. 

*michi.js not (yet) included

But Michi is designed to be barebones and dependency-less, so none of these examples are possible until you implement a IRemoteHandler for these transports, see the wiki for more details.

Why not JSON-RPC/XML-RPC/SOAP/(some other way of doing RPC)

Other RPC libraries specify a format that you have to follow and have a lot of cruft involved to make sure the spec is followed.

Michi doesn't come with a spec. You can use whatever serialization format or transport you want, just handle it in an IRemoteHandler. You could pipe the RemoteRequest/RemoteResponse objects through a pipe as binary objects, use Protobufs, or serialize it in a binary format and send it using carrier pigeons.

Michi isn't concerned with the way it sends and receives data, only that the data is there for a function when it runs. It's basically a fancy dictionary for Func<> objects!

Michi was created for Snowflake.

About

A simple framework for implementing transport-agnostic IPC.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages