space

package
v0.0.0-...-59fb8d1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 7, 2021 License: MIT Imports: 11 Imported by: 4

Documentation

Index

Constants

View Source
const (
	SpaceInvalid = iota
	SpaceNoErrorMethod
	SpaceOperationFailed
)

Variables

This section is empty.

Functions

func Get

func Get(ptp PointToPoint, tempFields ...interface{}) bool

Get will open a TCP connection to the PointToPoint and send the message, which includes the type of operation and template specified by the user. The method returns a boolean to inform if the operation was carried out with any errors with communication.

func GetAll

func GetAll(ptp PointToPoint, tempFields ...interface{}) ([]Tuple, bool)

GetAll will open a TCP connection to the PointToPoint and send the message, which includes the type of operation specified by the user. The method is nonblocking and will return all tuples found in the tuple space as well as a bool to denote if there were any errors with the communication. NOTE: tuples is allowed to be an empty list, implying the tuple space was empty.

func GetP

func GetP(ptp PointToPoint, tempFields ...interface{}) (bool, bool)

GetP will open a TCP connection to the PointToPoint and send the message, which includes the type of operation and template specified by the user. The function will return two bool values. The first denotes if a tuple was found, the second if there were any erors with communication.

func NewRemoteSpaceAlt

func NewRemoteSpaceAlt(url string) (ptp *PointToPoint, ts *TupleSpace)

NewRemoteSpaceAlt creates a representaiton of a remote tuple space.

func NewSpaceAlt

func NewSpaceAlt(url string) (ptp *PointToPoint, ts *TupleSpace)

NewSpaceAlt creates a representation of a new tuple space.

func NewSpaceError

func NewSpaceError(spc *Space, value interface{}, state interface{}) error

NewSpaceError creates a new error given space spc, a value used in an operation and the return state of the implemented operation. NewSpaceError returns a structure which fulfils the error interface and if an operation error has occured. NewSpaceError returns nil if no operation failure has occured.

func Put

func Put(ptp PointToPoint, tupleFields ...interface{}) bool

Put will open a TCP connection to the PointToPoint and send the message, which includes the type of operation and tuple specified by the user. The method returns a boolean to inform if the operation was carried out with success or not.

func PutP

func PutP(ptp PointToPoint, tupleFields ...interface{}) bool

PutP will open a TCP connection to the PointToPoint and send the message, which includes the type of operation and tuple specified by the user. As the method is nonblocking it wont wait for a response whether or not the operation was successful. The method returns a boolean to inform if the operation was carried out with any errors with communication.

func Query

func Query(ptp PointToPoint, tempFields ...interface{}) bool

Query will open a TCP connection to the PointToPoint and send the message, which includes the type of operation and template specified by the user. The method returns a boolean to inform if the operation was carried out with any errors with communication.

func QueryAll

func QueryAll(ptp PointToPoint, tempFields ...interface{}) ([]Tuple, bool)

QueryAll will open a TCP connection to the PointToPoint and send the message, which includes the type of operation specified by the user. The method is nonblocking and will return all tuples found in the tuple space as well as a bool to denote if there were any errors with the communication. NOTE: tuples is allowed to be an empty list, implying the tuple space was empty.

func QueryP

func QueryP(ptp PointToPoint, tempFields ...interface{}) (bool, bool)

QueryP will open a TCP connection to the PointToPoint and send the message, which includes the type of operation and template specified by the user. The function will return two bool values. The first denotes if a tuple was found, the second if there were any erors with communication.

Types

type Interspace

type Interspace interface {
	Put(tuple ...interface{}) (Tuple, error)
	Get(template ...interface{}) (Tuple, error)
	Query(template ...interface{}) (Tuple, error)
	PutP(tuple ...interface{}) (Tuple, error)
	GetP(template ...interface{}) (Tuple, error)
	QueryP(template ...interface{}) (Tuple, error)
	GetAll(template ...interface{}) ([]Tuple, error)
	QueryAll(template ...interface{}) ([]Tuple, error)
}

Interspace defines the internal space interface. Interspace interface is meant to be used by both external or internal interfaces.

type Interstellar

type Interstellar interface {
	RawPut(tuple ...interface{}) (interface{}, interface{})
	RawGet(template ...interface{}) (interface{}, interface{})
	RawQuery(template ...interface{}) (interface{}, interface{})
	RawPutP(tuple ...interface{}) (interface{}, interface{})
	RawGetP(template ...interface{}) (interface{}, interface{})
	RawQueryP(template ...interface{}) (interface{}, interface{})
	RawGetAll(template ...interface{}) (interface{}, interface{})
	RawQueryAll(template ...interface{}) (interface{}, interface{})
}

Interstellar defines the internal space interface without any error checking. Interstellar interface is meant primarily for internal usage. This interface can change without any notice.

type Space

type Space struct {
	// contains filtered or unexported fields
}

Space is a structure for interacting with a space.

func NewRemoteSpace

func NewRemoteSpace(url string) (rs Space)

NewRemoteSpace connects to a remote space rs with the specified URL.

func NewSpace

func NewSpace(url string) (s Space)

NewSpace creates an empty space s with the specified URL.

func (*Space) Get

func (s *Space) Get(t ...interface{}) (tp Tuple, e error)

Get performs a blocking retrieval for a tuple from space s with template t. Get returns the matched tuple tp and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) GetAll

func (s *Space) GetAll(t ...interface{}) (ts []Tuple, e error)

GetAll performs a non-blocking retrieval for all tuples from space s with template t. GetAll returns the matching tuples ts and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) GetP

func (s *Space) GetP(t ...interface{}) (tp Tuple, e error)

GetP performs a non-blocking retrieval for a tuple from space s with template t. GetP returns the matched tuple tp and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) InterpretError

func (s *Space) InterpretError(state interface{}) (msg string)

InterpretError returns an error message msg given a return state by an operation. The state is given by the implementation and this method maps from the state to sane error messages. This is an internal method and may change without notice.

func (*Space) InterpretOperation

func (s *Space) InterpretOperation(state interface{}) (status bool)

InterpretOperation returns a status for an operation that has been succesful given a return state by an operation. The state is given by the implementation and this method maps the returned state to a boolean value. This is an internal method and may change without notice.

func (*Space) InterpretValue

func (s *Space) InterpretValue(value interface{}) (str string)

InterpretValue returns a representation of the value that was passed to the operation. The representation for now is a print friendly string value. This is an internal method and may change without notice.

func (*Space) Put

func (s *Space) Put(t ...interface{}) (tp Tuple, e error)

Put performs a blocking placement a tuple t into space s. Put returns the original tuple tp and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) PutP

func (s *Space) PutP(t ...interface{}) (tp Tuple, e error)

PutP performs a non-blocking placement a tuple t into space s. PutP returns the original tuple tp and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) Query

func (s *Space) Query(t ...interface{}) (tp Tuple, e error)

Query performs a blocking query for a tuple from space s with template t. Query returns the matched tuple tp and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) QueryAll

func (s *Space) QueryAll(t ...interface{}) (ts []Tuple, e error)

QueryAll performs a non-blocking query for all tuples from space s with template t. QueryAll returns the matching tuples ts and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) QueryP

func (s *Space) QueryP(t ...interface{}) (tp Tuple, e error)

QueryP performs a non-blocking query for a tuple from space s with template t. QueryP returns the matched tuple tp and an error e. Error e contains a structure adhering to the error interface if the operation fails, and nil if no error occured.

func (*Space) RawGet

func (s *Space) RawGet(t ...interface{}) (tp interface{}, e interface{})

RawGet performs a blocking retrieval a tuple from space s with template t and without any error checking. RawGet returns the implementation result tp and error state e.

func (*Space) RawGetAll

func (s *Space) RawGetAll(t ...interface{}) (ts interface{}, e interface{})

RawGetAll performs a non-blocking retrieval for all tuples from space s with template t and without any error checking. RawGetAll returns the implementation result ts and error state e.

func (*Space) RawGetP

func (s *Space) RawGetP(t ...interface{}) (tp interface{}, e interface{})

RawGetP performs a non-blocking retrieval a tuple from space s with template t and without any error checking. RawGetP returns the implementation result tp and error state e.

func (*Space) RawPut

func (s *Space) RawPut(t ...interface{}) (tp interface{}, e interface{})

RawPut performs a blocking placement of a tuple t into space s without any error checking. RawPut returns the implementation result tp and error state e.

func (*Space) RawPutP

func (s *Space) RawPutP(t ...interface{}) (tp interface{}, e interface{})

RawPut performs a non-blocking placement of a tuple t into space s without any error checking. RawPut returns the implementation result tp and error state e.

func (*Space) RawQuery

func (s *Space) RawQuery(t ...interface{}) (tp interface{}, e interface{})

RawQuery performs a blocking query for a tuple from space s with template t and without any error checking. RawQuery returns the implementation result tp and error state e.

func (*Space) RawQueryAll

func (s *Space) RawQueryAll(t ...interface{}) (ts interface{}, e interface{})

RawQueryAll performs a non-blocking query for all tuples from space s with template t and without any error checking. RawQueryAll returns the implementation result ts and error state e.

func (*Space) RawQueryP

func (s *Space) RawQueryP(t ...interface{}) (tp interface{}, e interface{})

RawQueryP performs a blocking query for a tuple from space s with template t and without any error checking. RawQueryP returns the implementation result tp and error state e.

func (*Space) Size

func (s *Space) Size() (sz int)

Size returns the size of the space.

type SpaceError

type SpaceError struct {
	// contains filtered or unexported fields
}

SpaceError represents an internal error type used when printing error messages.

func (SpaceError) Error

func (e SpaceError) Error() string

Error prints the error message represented by SpaceError.

func (SpaceError) Operation

func (e SpaceError) Operation() bool

Operation returns a boolean value if an operation has succeeded.

type TupleSpace

type TupleSpace struct {
	// contains filtered or unexported fields
}

TupleSpace contains a set of tuples and it has a mutex lock associated with it to secure mutual exclusion. Furthermore a port number to locate it.

func CreateTupleSpace

func CreateTupleSpace(port int) (ts *TupleSpace)

func (*TupleSpace) Listen

func (ts *TupleSpace) Listen()

listen will listen and accept all incoming connections. Once a connection has been established, the connection is passed on to the handler.

func (*TupleSpace) Size

func (ts *TupleSpace) Size() int

Size return the number of tuples in the tuple space.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL