goSpace, a pSpace implementation in Go.
To get goSpace, do:
go get -u github.com/pspaces/gospace
To import goSpace into your project, add:
import (
"github.com/pspaces/gospace"
)Documentation for goSpace can be accessed through the terminal with go doc or viewed online with godoc.
A space can be created by using NewSpace for creating a local space or NewRemoteSpace for connecting to a remote space.
To create a space on the local host, one can do:
spc := gospace.NewSpace("space")To connect to a remote space with name space, one can do:
spc := gospace.NewRemoteSpace("tcp://example.com/space")In order to use goSpace efficiently, there are certain rules one needs to be aware of:
- An operation acts on a
Spacestructure. - Tuples contain values. Templates contain values and types.
- Ordinary operations such as
Put,Getand so forth are blocking operations. - Ordinary operations postfixed by a
Psuch asPutP,GetPand so forth are non-blocking operations. - Aggregation operations postfixed by a
Aggsuch asPutAgg,GetAggand so forth are non-blocking operations. - Aggregation operations require inclusion of a user defined function
fwhich operate on aTuplestructure and has the signaturefunc(Tuple, Tuple) Tuple. - Aggregation operations require that the user defined function
fexists on all peers that will use that function. - For
PutandPutPoperations the parameters must be values. For the remaining operations the parameters must be values or binding variables for pattern matching. - Return signature of an operations is always
func(...) (Tuple, error).
Due to aggregation operators, binding variables are not written to when an operation completes.
goSpace strives to follow the pSpace specification. It contains the following operations:
Put(x_1, x_2, ..., x_n)
PutP(x_1, x_2, ..., x_n)
Get(x_1, x_2, ..., x_n)
GetP(x_1, x_2, ..., x_n)
GetAll(x_1, x_2, ..., x_n)
Query(x_1, x_2, ..., x_n)
QueryP(x_1, x_2, ..., x_n)
QueryAll(x_1, x_2, ..., x_n)Do note that GetAll and QueryAll are non-blocking operators.
goSpace has experimental operators for aggregating tuples in a space. It contains the following operations:
PutAgg(f, x_1, x_2, ..., x_n)
GetAgg(f, x_1, x_2, ..., x_n)
QueryAgg(f, x_1, x_2, ..., x_n)The specification for the pSpace can be found here.
There are currently some limitations to the implementation:
- Strict 4 GiB size limit on the tuple space.
- Only TCP over IPv4 is supported.
- Gates and space repositories are not supported.
- Multiplexing of multiple spaces over a single gate is not supported.
- Performance is bouded by the amount of connections established due to networking code.
These limitations are currently being resolved.
Examples and cases for goSpace can be found here.
Want to contribute? See CONTRIBUTING.md.
See AUTHORS.md.
MIT License. See LICENSE.md.