Documentation ¶
Index ¶
Constants ¶
const ( OK = 200 ERROR = 500 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface { // GetService returns an instance of the given type GetService(v interface{}) (interface{}, error) // ID returns the identifier of this context ID() string // RunView runs the passed view on input this context RunView(view View, opts ...RunViewOption) (interface{}, error) // Me returns the identity bound to this context Me() Identity // IsMe returns true if the passed identity is an alias // of the identity bound to this context, false otherwise IsMe(id Identity) bool // Initiator returns the View that initiate a call Initiator() View // GetSession returns a session to the passed remote // party for the given view caller. // Cashing may be be used. GetSession(caller View, party Identity) (Session, error) // GetSessionByID returns a session to the passed remote party and id. // Cashing may be used. GetSessionByID(id string, party Identity) (Session, error) ResetSessions() error // Session returns the session created to respond to a // remote party, nil if the context was created // not to respond to a remote call Session() Session // Context return the associated context.Context Context() context.Context // OnError appends to passed callback function to the list of functions called when // the current execution return an error or panic. // This is useful to release resources. OnError(callback func()) }
Context gives a view information about the environment in which it is in execution
type Identity ¶
type Identity []byte
Identity wraps the byte representation of a lower level identity.
type Message ¶
type Message struct { SessionID string // Session Identifier ContextID string // Context Identifier Caller string // View Identifier of the caller FromEndpoint string // Endpoint identifier of the caller FromPKID []byte // PK identifier of the caller Status int32 // Message Status (OK, ERROR) Payload []byte // Payload }
type MutableContext ¶
type MutableContext interface { // ResetSessions disposes all sessions created in this context ResetSessions() error // PutService registers a service in this context PutService(v interface{}) error }
MutableContext models a mutable context
type RunViewOption ¶
type RunViewOption func(*RunViewOptions) error
RunViewOption models a function that set options to run a view
func AsInitiator ¶
func AsInitiator() RunViewOption
AsInitiator tells the context to initialize the initiator to the executing view
func AsResponder ¶
func AsResponder(session Session) RunViewOption
AsResponder sets the context's session to the passed session
func WithSameContext ¶
func WithSameContext() RunViewOption
WithSameContext is used to reuse the context
func WithViewCall ¶
func WithViewCall(f func(Context) (interface{}, error)) RunViewOption
WithViewCall sets the Call function to invoke. When specified, it overrides all options and arguments passing a view
type RunViewOptions ¶
type RunViewOptions struct { Session Session AsInitiator bool Call func(Context) (interface{}, error) SameContext bool }
RunViewOptions models the options to run a view
func CompileRunViewOptions ¶
func CompileRunViewOptions(opts ...RunViewOption) (*RunViewOptions, error)
CompileRunViewOptions compiles a set of RunViewOption to a RunViewOptions
type Session ¶
type Session interface { Info() SessionInfo // Send sends the payload to the endpoint Send(payload []byte) error // SendError sends an error to the endpoint with the passed payload SendError(payload []byte) error // Receive returns a channel of messages received from the endpoint Receive() <-chan *Message // Close releases all the resources allocated by this session Close() }
Session encapsulates a communication channel to an endpoint