Documentation ¶
Overview ¶
Package circuit exposes the core functionalities provided by the circuit programming environment
Index ¶
- func Bind(v runtime)
- func DialSelf(service string) interface{}
- func Export(val ...interface{}) interface{}
- func Hang()
- func HangInBack()
- func Import(exported interface{}) ([]interface{}, string, error)
- func Kill(addr n.Addr) error
- func Listen(service string, receiver interface{})
- func RegisterFunc(fn Func)
- func RegisterValue(v interface{})
- func RunInBack(fn func())
- func ServerAddr() n.Addr
- func Spawn(host worker.Host, anchor []string, fn Func, in ...interface{}) (retrn []interface{}, addr n.Addr, err error)
- type Func
- type HandleID
- type PermX
- type X
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bind ¶
func Bind(v runtime)
Bind is used internally to bind an implementation of this package to the public methods of this package
func DialSelf ¶
func DialSelf(service string) interface{}
DialSelf works similarly to Dial, except it dials into the calling worker itself and instead of returning a cross-interface to the service receiver, it returns a native Go interface. DialSelf never fails.
func Export ¶
func Export(val ...interface{}) interface{}
Export recursively rewrites the values val into a Go type that can be serialiazed with package encoding/gob. The values val can contain permanent cross-interfaces (but no non-permanent ones).
func HangInBack ¶
func HangInBack()
func Import ¶
Import converts the exported value, that was produced as a result of Export, back into its original form.
func Listen ¶
func Listen(service string, receiver interface{})
Listen registers the receiver object as a receiver for the named service. Subsequent calls to Dial from other works, addressing this worker and the same service name, will return a cross-interface to receiver.
func RegisterFunc ¶
func RegisterFunc(fn Func)
RegisterFunc registers the worker function type fn with the circuit runtime type system. fn must be of a not-necessarily public type having a single public method. As a result, this program is able to spawn fn on remote hosts, as well as to host remote invokations of fn. By convention, RegisterFunc should be invoked from a dedicated init function within of the package that defines the type of fn.
func RegisterValue ¶
func RegisterValue(v interface{})
RegisterValue registers the type of v with the circuit runtime type system. As a result this program becomes able to send and receive cross-interfaces pointing to objects of this type. By convention, RegisterValue should be invoked from a dedicated init function within of the package that defines the type of v.
func RunInBack ¶
func RunInBack(fn func())
RunInBack can only be called during the execution of a worker function, invoked with Spawn, and can only be called once. RunInBack instructs the circuit runtime that the hosting worker should not be killed until fn completes, even if the invoking worker function completes prior to that.
func Spawn ¶
func Spawn(host worker.Host, anchor []string, fn Func, in ...interface{}) (retrn []interface{}, addr n.Addr, err error)
Spawn starts a new worker process on host. The worker is registered under all directories in the anchor file system named by anchor. The worker function fn, whose type must have previously been registered with RegisterFunc, is executed on the newly spawned worker with arguments given by in. Spawn blocks until the execution of fn completes. Spawn returns the return values of fn's invokation in the slice retrn. The types of the elements of retrn exactly match the declared return types of fn's singleton public method. Spawn also returns the address of the spawned worker in addr. The new worker will be killed as soon as fn completes, unless an extension of its life is explicitly requested during the execution of fn via a call to RunInBack. Spawn does not panic. It returns any error conditions in err, in which case retrn and addr are undefined.
Types ¶
type Func ¶
type Func interface{}
Func is a symbolic type that refers to circuit worker function types. These are types with a singleton public method.
type HandleID ¶
type HandleID uint64
HandleID is a universal ID referring to a circuit value accessible across workers
type PermX ¶
type PermX interface { // A permanent cross-interface can be used as a non-permanent one. X // IsPerm is used internally. IsPermX() }
PermX represents a permanent cross-interface value.
func Dial ¶
Dial contacts the worker specified by addr and requests a cross-worker interface to the named service. If service is not being listened to at this worker, nil is returned. Failures to contact the worker for external/physical reasons result in a panic.
type X ¶
type X interface { // Addr returns the address of the runtime, hosting the object underlying the cross-interface value. Addr() n.Addr // HandleID uniquely identifies the local reference to the receiver that was exported for this cross-reference HandleID() HandleID // Call invokes the method named proc of the actual object (possibly // living remotely) underlying the cross-interface. The invokation // arguments are take from in, and the returned values are placed in // the returned slice. // // Errors can only occur as a result of physical/external circumstances // that impede cross-worker communication. Such errors are returned in // the form of panics. Call(proc string, in ...interface{}) []interface{} // IsX is used internally. IsX() // String returns a human-readable representation of the cross-interface. String() string }
X represents a cross-interface value.