view

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsInitiatorCall

func AsInitiatorCall(context view.Context, initiator view.View, v func(context view.Context) (interface{}, error)) (interface{}, error)

AsInitiatorCall can be used by a responder to behave temporarily as an initiator. Recall that an initiator is characterized by having an initiator (`context.Initiator()`) set when the initiator is instantiated. AsInitiatorCall sets context.Initiator() to the passed initiator, and executes the passed view call. TODO: what happens to the sessions already openend with a different initiator (maybe an empty one)?

func AsInitiatorView

func AsInitiatorView(context view.Context, initiator view.View) (interface{}, error)

AsInitiatorView can be used by a responder to behave temporarily as an initiator. Recall that an initiator is characterized by having an initiator (`context.Initiator()`) set when the initiator is instantiated. AsInitiatorView sets context.Initiator() to the passed initiator, and executes it.

func AsResponder

func AsResponder(context view.Context, session view.Session, v func(context view.Context) (interface{}, error)) (interface{}, error)

AsResponder can be used by an initiator to behave temporarily as a responder. Recall that a responder is characterized by having a default session (`context.Session()`) established by an initiator.

func Initiate

func Initiate(context view.Context, initiator view.View) (interface{}, error)

Initiate initiates a new protocol whose initiator's view is the passed one. The execution happens in a freshly created context. This is a shortcut for `view.GetManager(context).InitiateView(initiator)`.

func RunCall

func RunCall(context view.Context, v func(context view.Context) (interface{}, error)) (interface{}, error)

RunCall is a shortcut for `context.RunView(nil, view.WithViewCall(v))` and can be used to run a view call in a given context.

func RunView added in v0.3.0

func RunView(context view.Context, view view.View, opts ...view.RunViewOption)

RunView runs passed view within the passed context and using the passed options in a separate goroutine

Types

type MockContext added in v0.3.0

type MockContext struct {
	Ctx view.Context
	// contains filtered or unexported fields
}

func (*MockContext) Context added in v0.3.0

func (c *MockContext) Context() context.Context

func (*MockContext) GetService added in v0.3.0

func (c *MockContext) GetService(v interface{}) (interface{}, error)

func (*MockContext) GetSession added in v0.3.0

func (c *MockContext) GetSession(caller view.View, party view.Identity) (view.Session, error)

func (*MockContext) GetSessionByID added in v0.3.0

func (c *MockContext) GetSessionByID(id string, party view.Identity) (view.Session, error)

func (*MockContext) ID added in v0.3.0

func (c *MockContext) ID() string

func (*MockContext) Initiator added in v0.3.0

func (c *MockContext) Initiator() view.View

func (*MockContext) IsMe added in v0.3.0

func (c *MockContext) IsMe(id view.Identity) bool

func (*MockContext) Me added in v0.3.0

func (c *MockContext) Me() view.Identity

func (*MockContext) OnError added in v0.3.0

func (c *MockContext) OnError(callback func())

func (*MockContext) ResetSessions added in v0.3.0

func (c *MockContext) ResetSessions() error

func (*MockContext) RespondToAs added in v0.3.0

func (c *MockContext) RespondToAs(initiator view.View, responder view.Identity, r view.View)

func (*MockContext) RunView added in v0.3.0

func (c *MockContext) RunView(view view.View, opts ...view.RunViewOption) (interface{}, error)

func (*MockContext) Session added in v0.3.0

func (c *MockContext) Session() view.Session

type Responders added in v0.3.0

type Responders struct {
	InitiatorView view.View
	ResponderID   view.Identity
	ResponderView view.View
	Lock          sync.RWMutex
	Channel       *session.LocalBidirectionalChannel
}

type Stream added in v0.3.0

type Stream interface {
	Recv(m interface{}) error
	Send(m interface{}) error
}

func GetStream added in v0.3.0

func GetStream(sp view.ServiceProvider) Stream

func GetStreamIfExists added in v0.3.0

func GetStreamIfExists(sp view.ServiceProvider) (Stream, error)

Jump to

Keyboard shortcuts

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