Documentation ¶
Overview ¶
+build generate
Index ¶
- Variables
- func Broker() *broker
- func Dealer() *dealer
- func ErrorFromContext(ctx context.Context) (error, bool)
- func NewErrorContext(ctx context.Context, err error) context.Context
- func NewRealm() *realmHandler
- func NewSessionContext(ctx context.Context, session *Session) context.Context
- func Pipe() (Conn, Conn)
- type Abort
- type Call
- type Chain
- type Client
- func (c *Client) Call(ctx context.Context, procedure URI, args []interface{}, ...) (*Result, error)
- func (c *Client) Close() error
- func (c *Client) JoinRealm(ctx context.Context, realm URI, details Details) error
- func (c *Client) Publish(ctx context.Context, options Options, topic URI, args []interface{}, ...) error
- func (c *Client) Register(ctx context.Context, name URI, h InvocationHandler) error
- func (c *Client) Send(ctx context.Context, message Message) error
- func (c *Client) Subscribe(ctx context.Context, topic URI) (<-chan *Event, error)
- func (c *Client) Unregister(ctx context.Context, name URI) error
- func (c *Client) Unsubscribe(ctx context.Context, topic URI) error
- type ClientDetails
- type Conn
- type Details
- type DialInfo
- type Error
- type Event
- type Goodbye
- type Handler
- type Hello
- type ID
- type Invocation
- type InvocationHandler
- type Message
- type MessageType
- type Options
- type Publish
- type PublishOption
- type Published
- type Realm
- func (r *Realm) Details() map[string]interface{}
- func (r *Realm) Name() URI
- func (r *Realm) RegisterFeatures(name string, features ...string) error
- func (r *Realm) RegisterRole(name string) error
- func (r *Realm) SetValue(key interface{}, value interface{})
- func (r *Realm) Value(key interface{}) (interface{}, bool)
- type Register
- type Registered
- type RegistrationDetails
- type Response
- type Result
- type Router
- type Session
- type Subscribe
- type Subscribed
- type Subscription
- type URI
- type Unregister
- type Unregistered
- type Unsubscribe
- type Unsubscribed
- type WebsocketConn
- type Welcome
- type Yield
Constants ¶
This section is empty.
Variables ¶
var ( ErrNoSession = errors.New("session does not exist in context") ErrNoSub = errors.New("subscription does not exist") )
var ( ErrNotWS = errors.New("not a websocket schema") ErrNoProcedure = errors.New("procedure does not exist") )
var ( EvOnCreate = URI("wamp.registration.on_create") EvOnRegister = URI("wamp.registration.on_register") EvOnUnregister = URI("wamp.registration.on_unregister") EvOnDelete = URI("wamp.registration.on_delete") ProcList = URI("wamp.registration.list") ProcLookUp = URI("wamp.registration.lookup") ProcMatch = URI("wamp.registration.match") ProcGet = URI("wamp.registration.get") ProcListCallees = URI("wamp.registration.list_callees") ProcCountCallees = URI("wamp.registration.count_callees") ErrNoCaller = errors.New("caller does not exist") ErrNoCall = errors.New("call does not exist") )
var ( ErrRoleExist = errors.New("role already exists") ErrRoleNotExist = errors.New("role does not exist") ErrProtocolViolation = errors.New("protocol violation") ErrRealmExist = errors.New("realm already exists") ErrRealmNoExist = errors.New("realm doesn not exist") )
var ( InvalidURI = URI("wamp.error.invalid_uri") // The provided URI is not valid. NoSuchProcedure = URI("wamp.error.no_such_procedure") // No procedure registered under the given URL. ProcedureAlreadyExists = URI("wamp.error.procedure_already_exists") // A procedure with the given URI is already registered. NoSuchRegistration = URI("wamp.error.no_such_registration") // A Dealer could not perform an unregister, since the given registration is not active. NoSuchSubscription = URI("wamp.error.no_such_subscription") // A Broker could not perform an unsubscribe, since the given subscription is not active. InvalidArument = URI("wamp.error.invalid_argument") // A Call failed since the given argument types or values are not acceptable to the called procedure. SystemShutdown = URI("wamp.error.system_shutdown") // Used as a GOODBYE or ABORT reason. CloseRealm = URI("wamp.error.close_realm") // Used as a GOODBYE reason when a Peer wants to leave the realm. GoodbyeAndOut = URI("wamp.error.goodbye_and_out") // Used as a GOODBYE reply reason to acknowledge the end of a Peers session. NotAuthorized = URI("wamp.error.not_authorized") // Peer is not authorized to perform the operation. AuthorizationFailed = URI("wamp.error.authorization_failed") // Dealer or Broker could not determine if the Peer is authorized to perform the operation. NoSuchRealm = URI("wamp.error.no_such_realm") // Peer wanted to join non-exsisting realm. NoSuchRole = URI("wamp.error.no_such_role") // Authenticated Role does not or no longer exists. Canceled = URI("wamp.error.canceled") // Previously issued call is canceled. OptionNotAllowed = URI("wamp.error.option_not_allowed") // Requested interaction with an option was disallowed by the Router. NoEligibleCallee = URI("wamp.error.no_eligible_callee") // Callee black list or Caller exclusion lead to an exclusion of any Callee providing the procedure. DiscloseMe = URI("wamp.error.option_disallowed.disclose_me") // A Router rejected client request to disclose its identity. NetworkFailure = URI("wamp.error.network_failure") // A Router encountered a network failure. )
var ErrInvalidURI = errors.New("invalid uri")
var (
ErrWrongSubprotocol = errors.New("wrong subprotocol")
)
Functions ¶
func Broker ¶
func Broker() *broker
Broker returns a handler that handles messages by routing incoming events from Publishers to Subscribers that are subscribed to respective topics. Requires a Realm handler chained before the Broker.
func Dealer ¶
func Dealer() *dealer
Dealer returns a handler that handles messages by routing calls from incoming Callers to Callees implementing the procedure called, and route call results back from Callees to Callers. Requires a Realm handler chained before the Dealer.
func ErrorFromContext ¶
ErrorFromContext extracts the error value from the context.
func NewErrorContext ¶
NewErrorContext returns a child context with the error value stored in it.
func NewRealm ¶
func NewRealm() *realmHandler
NewRealm returns a realm handler that handles realm specific messages.
func NewSessionContext ¶
NewSessionContext returns a child context with the session value stored in it.
Types ¶
type Abort ¶
type Abort struct { T MessageType Details map[string]interface{} Reason URI }
func (*Abort) Type ¶
func (msg *Abort) Type() MessageType
type Call ¶
type Call struct { T MessageType Request ID Options map[string]interface{} Procedure URI Args []interface{} ArgsKW map[string]interface{} }
func (*Call) Type ¶
func (msg *Call) Type() MessageType
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
A Client is a Peer which connects to a Router.
func DialWithInfo ¶
type ClientDetails ¶
func (*ClientDetails) Details ¶
func (d *ClientDetails) Details() map[string]interface{}
type Conn ¶
type Conn interface { Read(context.Context) (Message, error) Send(context.Context, Message) error Close() error }
A Conn represents a connection between two Peers.
type Error ¶
type Error struct { T MessageType ErrCode MessageType Request ID Details map[string]interface{} Error URI Args []interface{} ArgsKW map[string]interface{} }
func (*Error) Type ¶
func (msg *Error) Type() MessageType
type Event ¶
type Event struct { T MessageType Subscription ID Publication ID Details map[string]interface{} Args []interface{} ArgsKW map[string]interface{} }
func (*Event) Type ¶
func (msg *Event) Type() MessageType
type Goodbye ¶
type Goodbye struct { T MessageType Details map[string]interface{} Reason URI }
func (*Goodbye) Type ¶
func (msg *Goodbye) Type() MessageType
type Hello ¶
type Hello struct { T MessageType Realm URI Details map[string]interface{} }
func (*Hello) Type ¶
func (msg *Hello) Type() MessageType
type ID ¶
type ID uint64
func NewGlobalID ¶
func NewGlobalID() ID
NewGlobalID draws a randomly, uniformly distributed ID from the complete range of [0, 2^53]. The drawn ID is allowed to be used in the global scope.
type Invocation ¶
type Invocation struct { T MessageType Request ID Registration ID Details map[string]interface{} Args []interface{} ArgsKW map[string]interface{} }
func (*Invocation) Type ¶
func (msg *Invocation) Type() MessageType
type InvocationHandler ¶
type InvocationHandler func(context.Context, *Invocation) ([]interface{}, map[string]interface{}, error)
type Message ¶
type Message interface {
Type() MessageType
}
func NewMessage ¶
func NewMessage(t MessageType) Message
type MessageType ¶
type MessageType uint32
const ( HelloCode MessageType = 1 WelcomeCode MessageType = 2 AbortCode MessageType = 3 GoodbyeCode MessageType = 6 ErrorCode MessageType = 8 PublishCode MessageType = 16 PublishedCode MessageType = 17 SubscribeCode MessageType = 32 SubscribedCode MessageType = 33 UnsubscribeCode MessageType = 34 UnsubscribedCode MessageType = 35 EventCode MessageType = 36 CallCode MessageType = 48 ResultCode MessageType = 50 RegisterCode MessageType = 64 RegisteredCode MessageType = 65 UnregisterCode MessageType = 66 UnregisteredCode MessageType = 67 InvocationCode MessageType = 68 YieldCode MessageType = 70 ChallengeCode MessageType = 4 AuthenticateCode MessageType = 5 CancelCode MessageType = 49 InterruptCode MessageType = 69 )
type Publish ¶
type Publish struct { T MessageType Request ID Options map[string]interface{} Topic URI Args []interface{} ArgsKW map[string]interface{} }
func (*Publish) Type ¶
func (msg *Publish) Type() MessageType
type PublishOption ¶
type PublishOption struct {
AcknowledgePublish bool
}
func (*PublishOption) Options ¶
func (opt *PublishOption) Options() map[string]interface{}
type Published ¶
type Published struct { T MessageType Request ID Publication ID }
func (*Published) Type ¶
func (msg *Published) Type() MessageType
type Realm ¶
type Realm struct {
// contains filtered or unexported fields
}
func (*Realm) RegisterFeatures ¶
func (*Realm) RegisterRole ¶
type Register ¶
type Register struct { T MessageType Request ID Options map[string]interface{} Procedure URI }
func (*Register) Type ¶
func (msg *Register) Type() MessageType
type Registered ¶
type Registered struct { T MessageType Request ID Registration ID }
func (*Registered) Response ¶
func (reg *Registered) Response() ID
func (*Registered) Type ¶
func (msg *Registered) Type() MessageType
type RegistrationDetails ¶
type Result ¶
type Result struct { T MessageType Request ID Details map[string]interface{} Args []interface{} ArgsKW map[string]interface{} }
func (*Result) Type ¶
func (msg *Result) Type() MessageType
type Router ¶
type Router struct { // TODO Router.Handler provides a potential data race Handler Handler // contains filtered or unexported fields }
A Router performs message routing between components and may handle either or both the roles of Dealer or Broker.
func NewRouter ¶
func NewRouter() *Router
NewRouter creates a new router ready to accept new connections.
func (*Router) AcceptConn ¶
AcceptConn starts the routing process for the connection.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
func SessionFromContext ¶
SessionFromContext extracts the session value from the context.
type Subscribe ¶
type Subscribe struct { T MessageType Request ID Options map[string]interface{} Topic URI }
func (*Subscribe) Type ¶
func (msg *Subscribe) Type() MessageType
type Subscribed ¶
type Subscribed struct { T MessageType Request ID Subscription ID }
func (*Subscribed) Response ¶
func (sub *Subscribed) Response() ID
func (*Subscribed) Type ¶
func (msg *Subscribed) Type() MessageType
type Subscription ¶
type Subscription struct {
// contains filtered or unexported fields
}
type Unregister ¶
type Unregister struct { T MessageType Request ID Registration ID }
func (*Unregister) Type ¶
func (msg *Unregister) Type() MessageType
type Unregistered ¶
type Unregistered struct { T MessageType Request ID }
func (*Unregistered) Response ¶
func (unreg *Unregistered) Response() ID
func (*Unregistered) Type ¶
func (msg *Unregistered) Type() MessageType
type Unsubscribe ¶
type Unsubscribe struct { T MessageType Request ID Subscription ID }
func (*Unsubscribe) Type ¶
func (msg *Unsubscribe) Type() MessageType
type Unsubscribed ¶
type Unsubscribed struct { T MessageType Request ID }
func (*Unsubscribed) Response ¶
func (unsub *Unsubscribed) Response() ID
func (*Unsubscribed) Type ¶
func (msg *Unsubscribed) Type() MessageType
type WebsocketConn ¶
type WebsocketConn struct {
// contains filtered or unexported fields
}
func (*WebsocketConn) Close ¶
func (c *WebsocketConn) Close() error
type Welcome ¶
type Welcome struct { T MessageType Session ID Details map[string]interface{} }
func (*Welcome) Type ¶
func (msg *Welcome) Type() MessageType