gocircuit - modrpc/info GitHub Wiki
- Circuit: http://gocircuit.github.io/circuit/
- Github gocircuit/circuit: https://github.com/gocircuit/circuit
- Github gocircuit/runtime: https://github.com/gocircuit/runtime
- Escher Language: http://gocircuit.github.io/escher/
The circuit is a minimal distributed operating system that enables programmatic, reactive control over hosts, processes and connections within a compute cluster.
The main operation provided by the Circuit Runtime is spawning a function on a remote (or local) host, in a new “worker” OS-process — in other words, in a new Go runtime. Spawning is performed by the library function circuit.Spawn, that is declared as follows:
Spawn(host circuit.Host, anchor []string, f circuit.Func, in ...interface{}) (out []interface{}, addr circuit.A
- arguments
- host: physical machine where Func is to be executed
- anchor: list of directories in the anchor file system
- f: worker function written in Go
- in: list of input arguments
-
spawn semantics:
- A new worker process is started on the desired host and a connection is established between the parent and child circuit runtimes
- the worker (an OS-process) proceeds to:
- execute the desired worker function
- send its return values back to the parent process, and
- die immediately after
- the calling process receives the return values (or detects failure) and returns (unblocks) from the call to Spawn
- Functions to be executed remotely using the Spawn command.
import "circuit/use/circuit" type MyWorkerFunc struct{} func (MyWorkerFunc) SingletonMethod(greeting string) (response string) { return "Hello " + greeting } func init() { circuit.RegisterFunc(MyWorkerFunc{}) }
- Two situations: where data transferred between worker processes
- cross calls (= Spawn): spawning worker functions
- cross invocations (= Cross-interfaces): invoking methods of objects that live on remote workers
- If function arguments or return value have concrete (non-interface) types, then whenever this function is cross-called the supplied Go value will be transported across the network by value.
- it will be flattened recursively, serialized and consequently reconstructed in the same form at the receiving worker's Go runtime environment
- (Pure) Go interface is a value, which embodies some state along with a list of callable methods over the underlying state
- GoCircuit cross-interface is different from pure Go interface in that it can refer to an underlying object that lives in a process other than the currently executing one