Documentation
¶
Index ¶
- Constants
- Variables
- func AsInitiatorCall(context view.Context, initiator View, ...) (interface{}, error)
- func AsInitiatorView(context view.Context, initiator View) (interface{}, error)
- func AsResponder(context view.Context, session view.Session, ...) (interface{}, error)
- func GetIdentifier(f view.View) string
- func GetName(f view.View) string
- func Initiate(context view.Context, initiator View) (interface{}, error)
- func RunCall(context view.Context, v func(context view.Context) (interface{}, error)) (interface{}, error)
- func RunView(context view.Context, view View, opts ...view.RunViewOption)
- func RunViewNow(parent ParentContext, v View, opts ...view.RunViewOption) (res interface{}, err error)
- type ChildContext
- func NewChildContext(parentContext ParentContext, session view.Session, initiator view.View, ...) *ChildContext
- func NewChildContextFromParent(parentContext ParentContext) *ChildContext
- func NewChildContextFromParentAndInitiator(parentContext ParentContext, initiator view.View) *ChildContext
- func NewChildContextFromParentAndSession(parentContext ParentContext, session view.Session) *ChildContext
- func (w *ChildContext) Cleanup()
- func (w *ChildContext) Context() context.Context
- func (w *ChildContext) Dispose()
- func (w *ChildContext) GetService(v interface{}) (interface{}, error)
- func (w *ChildContext) GetSession(caller view.View, party view.Identity, boundToViews ...view.View) (view.Session, error)
- func (w *ChildContext) GetSessionByID(id string, party view.Identity) (view.Session, error)
- func (w *ChildContext) ID() string
- func (w *ChildContext) Initiator() view.View
- func (w *ChildContext) IsMe(id view.Identity) bool
- func (w *ChildContext) Me() view.Identity
- func (w *ChildContext) OnError(f func())
- func (w *ChildContext) PutService(v interface{}) error
- func (w *ChildContext) PutSession(caller view.View, party view.Identity, session view.Session) error
- func (w *ChildContext) ResetSessions() error
- func (w *ChildContext) RunView(v view.View, opts ...view.RunViewOption) (res interface{}, err error)
- func (w *ChildContext) Session() view.Session
- func (w *ChildContext) StartSpanFrom(c context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- type CommLayer
- type Context
- func (c *Context) Caller() view.Identity
- func (c *Context) Cleanup()
- func (c *Context) Context() context.Context
- func (c *Context) Dispose()
- func (c *Context) GetService(v interface{}) (interface{}, error)
- func (c *Context) GetSession(caller view.View, party view.Identity, boundToViews ...view.View) (view.Session, error)
- func (c *Context) GetSessionByID(id string, party view.Identity) (view.Session, error)
- func (c *Context) ID() string
- func (c *Context) Identity(ref string) (view.Identity, error)
- func (c *Context) Initiator() view.View
- func (c *Context) IsMe(id view.Identity) bool
- func (c *Context) Me() view.Identity
- func (c *Context) OnError(callback func())
- func (c *Context) PutService(service interface{}) error
- func (c *Context) PutSession(caller view.View, party view.Identity, session view.Session) error
- func (c *Context) ResetSessions() error
- func (c *Context) RunView(v view.View, opts ...view.RunViewOption) (res interface{}, err error)
- func (c *Context) Session() view.Session
- func (c *Context) StartSpan(name string, opts ...trace.SpanStartOption) trace.Span
- func (c *Context) StartSpanFrom(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
- type DisposableContext
- type EndpointService
- type Factory
- type IdentityProvider
- type LocalIdentityChecker
- type Manager
- func (cm *Manager) Context(contextID string) (view.Context, error)
- func (cm *Manager) ExistResponderForCaller(caller string) (view.View, view.Identity, error)
- func (cm *Manager) GetIdentifier(f view.View) string
- func (cm *Manager) GetResponder(initiatedBy interface{}) (view.View, error)
- func (cm *Manager) GetService(typ reflect.Type) (interface{}, error)
- func (cm *Manager) Initiate(id string, ctx context.Context) (interface{}, error)
- func (cm *Manager) InitiateContext(view view.View) (view.Context, error)
- func (cm *Manager) InitiateContextFrom(ctx context.Context, view view.View, id view.Identity, contextID string) (view.Context, error)
- func (cm *Manager) InitiateContextWithIdentity(view view.View, id view.Identity) (view.Context, error)
- func (cm *Manager) InitiateContextWithIdentityAndID(view view.View, id view.Identity, contextID string) (view.Context, error)
- func (cm *Manager) InitiateView(view view.View, ctx context.Context) (interface{}, error)
- func (cm *Manager) InitiateViewWithIdentity(view view.View, id view.Identity, ctx context.Context) (interface{}, error)
- func (cm *Manager) NewView(id string, in []byte) (f view.View, err error)
- func (cm *Manager) RegisterFactory(id string, factory Factory) error
- func (cm *Manager) RegisterResponder(responder view.View, initiatedBy interface{}) error
- func (cm *Manager) RegisterResponderWithIdentity(responder view.View, id view.Identity, initiatedBy interface{}) error
- func (cm *Manager) ResolveIdentities(endpoints ...string) ([]view.Identity, error)
- func (cm *Manager) Start(ctx context.Context)
- type Metrics
- type ParentContext
- type Registry
- func (cm *Registry) ExistResponderForCaller(caller string) (view.View, view.Identity, error)
- func (cm *Registry) GetIdentifier(f view.View) string
- func (cm *Registry) GetResponder(initiatedBy interface{}) (view.View, error)
- func (cm *Registry) GetView(id string) (view.View, error)
- func (cm *Registry) NewView(id string, in []byte) (f view.View, err error)
- func (cm *Registry) RegisterFactory(id string, factory Factory) error
- func (cm *Registry) RegisterResponder(responder view.View, initiatedBy interface{}) error
- func (cm *Registry) RegisterResponderFactory(factory Factory, initiatedBy interface{}) error
- func (cm *Registry) RegisterResponderWithIdentity(responder view.View, id view.Identity, initiatedBy interface{}) error
- type ServiceProvider
- type Session
- type SessionFactory
- type Sessions
- func (s *Sessions) Delete(viewId string, party view.Identity)
- func (s *Sessions) Get(viewId string, party view.Identity) view.Session
- func (s *Sessions) GetFirstOpen(viewId string, parties iterators.Iterator[view.Identity]) (view.Session, view.Identity)
- func (s *Sessions) GetSessionIDs() []string
- func (s *Sessions) Lock()
- func (s *Sessions) Put(viewId string, party view.Identity, session view.Session)
- func (s *Sessions) PutDefault(party view.Identity, session view.Session)
- func (s *Sessions) Reset()
- func (s *Sessions) Unlock()
- type Stream
- type View
- type ViewContext
- type WrappedContext
Constants ¶
Variables ¶
var (
ServiceNotFound = errors.New("service not found")
)
Functions ¶
func AsInitiatorCall ¶
func AsInitiatorCall(context view.Context, initiator 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 ¶
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 GetIdentifier ¶ added in v0.4.1
func Initiate ¶
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, opts ...view.RunViewOption)
RunView runs passed view within the passed context and using the passed options in a separate goroutine
func RunViewNow ¶ added in v0.7.0
func RunViewNow(parent ParentContext, v View, opts ...view.RunViewOption) (res interface{}, err error)
RunViewNow invokes the Call function of the given view. The view context used to the run view is either ctx or the one extracted from the options (see view.WithContext), if present.
Types ¶
type ChildContext ¶ added in v0.7.0
type ChildContext struct {
Parent ParentContext
// contains filtered or unexported fields
}
ChildContext is a view context with a parent. It allows the developer to override session and initiator. It also supports error callbacks.
func NewChildContext ¶ added in v0.7.0
func NewChildContext(parentContext ParentContext, session view.Session, initiator view.View, errorCallbackFuncs ...func()) *ChildContext
NewChildContext return a new ChildContext from the given arguments
func NewChildContextFromParent ¶ added in v0.7.0
func NewChildContextFromParent(parentContext ParentContext) *ChildContext
NewChildContextFromParent return a new ChildContext from the given parent
func NewChildContextFromParentAndInitiator ¶ added in v0.7.0
func NewChildContextFromParentAndInitiator(parentContext ParentContext, initiator view.View) *ChildContext
NewChildContextFromParentAndInitiator return a new ChildContext from the given parent and initiator view
func NewChildContextFromParentAndSession ¶ added in v0.7.0
func NewChildContextFromParentAndSession(parentContext ParentContext, session view.Session) *ChildContext
NewChildContextFromParentAndSession return a new ChildContext from the given parent and session
func (*ChildContext) Cleanup ¶ added in v0.7.0
func (w *ChildContext) Cleanup()
func (*ChildContext) Context ¶ added in v0.7.0
func (w *ChildContext) Context() context.Context
func (*ChildContext) Dispose ¶ added in v0.7.0
func (w *ChildContext) Dispose()
func (*ChildContext) GetService ¶ added in v0.7.0
func (w *ChildContext) GetService(v interface{}) (interface{}, error)
func (*ChildContext) GetSession ¶ added in v0.7.0
func (*ChildContext) GetSessionByID ¶ added in v0.7.0
func (*ChildContext) ID ¶ added in v0.7.0
func (w *ChildContext) ID() string
func (*ChildContext) Initiator ¶ added in v0.7.0
func (w *ChildContext) Initiator() view.View
func (*ChildContext) Me ¶ added in v0.7.0
func (w *ChildContext) Me() view.Identity
func (*ChildContext) OnError ¶ added in v0.7.0
func (w *ChildContext) OnError(f func())
func (*ChildContext) PutService ¶ added in v0.7.0
func (w *ChildContext) PutService(v interface{}) error
func (*ChildContext) PutSession ¶ added in v0.7.0
func (*ChildContext) ResetSessions ¶ added in v0.7.0
func (w *ChildContext) ResetSessions() error
func (*ChildContext) RunView ¶ added in v0.7.0
func (w *ChildContext) RunView(v view.View, opts ...view.RunViewOption) (res interface{}, err error)
func (*ChildContext) Session ¶ added in v0.7.0
func (w *ChildContext) Session() view.Session
func (*ChildContext) StartSpanFrom ¶ added in v0.7.0
func (w *ChildContext) StartSpanFrom(c context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span)
type CommLayer ¶ added in v0.4.1
type CommLayer interface {
NewSessionWithID(sessionID, contextID, endpoint string, pkid []byte, caller view.Identity, msg *view.Message) (view.Session, error)
NewSession(caller string, contextID string, endpoint string, pkid []byte) (view.Session, error)
MasterSession() (view.Session, error)
DeleteSessions(ctx context.Context, sessionID string)
}
func GetCommLayer ¶ added in v0.4.1
type Context ¶ added in v0.7.0
type Context struct {
// contains filtered or unexported fields
}
Context implements the view.Context interface
func NewContext ¶ added in v0.4.1
func NewContext( context context.Context, sp services.Provider, contextID string, sessionFactory SessionFactory, resolver EndpointService, idProvider IdentityProvider, party view.Identity, session view.Session, caller view.Identity, tracer trace.Tracer, localIdentityChecker LocalIdentityChecker, ) (*Context, error)
NewContext returns a new Context
func NewContextForInitiator ¶ added in v0.4.1
func NewContextForInitiator( contextID string, context context.Context, sp services.Provider, sessionFactory SessionFactory, resolver EndpointService, idProvider IdentityProvider, party view.Identity, initiator view.View, tracer trace.Tracer, localIdentityChecker LocalIdentityChecker, ) (*Context, error)
NewContextForInitiator returns a new Context for an initiator view
func (*Context) GetService ¶ added in v0.7.0
func (*Context) GetSession ¶ added in v0.7.0
func (*Context) GetSessionByID ¶ added in v0.7.0
func (*Context) Identity ¶ added in v0.7.0
Identity returns the identity matching the passed argument
func (*Context) PutService ¶ added in v0.7.0
func (*Context) PutSession ¶ added in v0.7.0
func (*Context) ResetSessions ¶ added in v0.7.0
type DisposableContext ¶ added in v0.7.0
DisposableContext extends view.Context with additional functions
type EndpointService ¶ added in v0.4.1
type EndpointService interface {
GetIdentity(endpoint string, pkID []byte) (view.Identity, error)
Resolver(ctx context.Context, party view.Identity) (*endpoint.Resolver, []byte, error)
}
EndpointService models the dependency to the view-sdk's endpoint service
type Factory ¶ added in v0.4.1
type Factory interface {
// NewView returns an instance of the View interface build using the passed argument.
NewView(in []byte) (view.View, error)
}
Factory is used to create instances of the View interface
type IdentityProvider ¶ added in v0.4.1
IdentityProvider models the dependency to the view-sdk's identity provider
type LocalIdentityChecker ¶ added in v0.4.1
LocalIdentityChecker models the dependency to the view-sdk's sig service
type Manager ¶ added in v0.4.1
type Manager struct {
// contains filtered or unexported fields
}
func GetManager ¶ added in v0.4.1
GetManager returns an instance of *Manager, if available, an error otherwise
func NewManager ¶ added in v0.4.1
func NewManager( serviceProvider services.Provider, commLayer CommLayer, endpointService EndpointService, identityProvider IdentityProvider, registry *Registry, tracerProvider tracing.Provider, metricsProvider metrics.Provider, localIdentityChecker LocalIdentityChecker, ) *Manager
func (*Manager) Context ¶ added in v0.4.1
Context returns a view.Context for a given contextID. If the context does not exist, an error is returned.
func (*Manager) ExistResponderForCaller ¶ added in v0.4.1
func (*Manager) GetIdentifier ¶ added in v0.4.1
func (*Manager) GetResponder ¶ added in v0.4.1
func (*Manager) GetService ¶ added in v0.4.1
func (*Manager) InitiateContext ¶ added in v0.4.1
func (*Manager) InitiateContextFrom ¶ added in v0.4.1
func (*Manager) InitiateContextWithIdentity ¶ added in v0.4.1
func (*Manager) InitiateContextWithIdentityAndID ¶ added in v0.4.1
func (*Manager) InitiateView ¶ added in v0.4.1
func (*Manager) InitiateViewWithIdentity ¶ added in v0.4.1
func (*Manager) RegisterFactory ¶ added in v0.4.1
func (*Manager) RegisterResponder ¶ added in v0.4.1
func (*Manager) RegisterResponderWithIdentity ¶ added in v0.4.1
func (*Manager) ResolveIdentities ¶ added in v0.4.1
type ParentContext ¶ added in v0.7.0
type Registry ¶ added in v0.4.1
type Registry struct {
// contains filtered or unexported fields
}
func GetRegistry ¶ added in v0.4.1
GetRegistry returns an instance of the view registry. It panics, if no instance is found.
func NewRegistry ¶ added in v0.4.1
func NewRegistry() *Registry
func (*Registry) ExistResponderForCaller ¶ added in v0.4.1
func (*Registry) GetIdentifier ¶ added in v0.4.1
func (*Registry) GetResponder ¶ added in v0.4.1
func (*Registry) RegisterFactory ¶ added in v0.4.1
func (*Registry) RegisterResponder ¶ added in v0.4.1
func (*Registry) RegisterResponderFactory ¶ added in v0.4.1
type ServiceProvider ¶ added in v0.4.1
type ServiceProvider struct {
// contains filtered or unexported fields
}
func NewServiceProvider ¶ added in v0.4.1
func NewServiceProvider() *ServiceProvider
func (*ServiceProvider) GetService ¶ added in v0.4.1
func (sp *ServiceProvider) GetService(v interface{}) (interface{}, error)
func (*ServiceProvider) RegisterService ¶ added in v0.4.1
func (sp *ServiceProvider) RegisterService(service interface{}) error
func (*ServiceProvider) String ¶ added in v0.4.1
func (sp *ServiceProvider) String() string
type SessionFactory ¶ added in v0.4.1
type SessionFactory interface {
NewSessionWithID(sessionID, contextID, endpoint string, pkid []byte, caller view.Identity, msg *view.Message) (view.Session, error)
NewSession(caller string, contextID string, endpoint string, pkid []byte) (view.Session, error)
DeleteSessions(ctx context.Context, sessionID string)
}
SessionFactory is used to create new communication sessions
type Sessions ¶ added in v0.4.1
type Sessions struct {
// contains filtered or unexported fields
}
func (*Sessions) GetFirstOpen ¶ added in v0.4.1
func (*Sessions) GetSessionIDs ¶ added in v0.4.1
func (*Sessions) PutDefault ¶ added in v0.4.1
type ViewContext ¶ added in v0.7.0
ViewContext is an alias for view.Context
type WrappedContext ¶ added in v0.7.0
type WrappedContext struct {
ParentContext
// contains filtered or unexported fields
}
WrappedContext wraps an existing view context to provider a different context.Context
func WrapContext ¶ added in v0.7.0
func WrapContext(parent ParentContext, ctx context.Context) *WrappedContext
WrapContext returns a new WrappedContext for the given arguments
func (*WrappedContext) Context ¶ added in v0.7.0
func (c *WrappedContext) Context() context.Context
Context returns the overrode go context