routing

package
v0.0.0-...-07a1cdb Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(hub *Hub, w http.ResponseWriter, r *http.Request)

NewClient handles websocket requests from the peer.

Types

type Auth

type Auth struct {
	UID  string
	Role string
}

type Client

type Client struct {

	// User ID if authorized
	Auth Auth
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

func (*Client) Close

func (c *Client) Close()

func (*Client) GetAuth

func (c *Client) GetAuth() Auth

func (*Client) GetSubscriptions

func (c *Client) GetSubscriptions() []string

func (*Client) Send

func (c *Client) Send(s string)

func (*Client) SubscribePrivate

func (c *Client) SubscribePrivate(s string)

func (*Client) SubscribePublic

func (c *Client) SubscribePublic(s string)

func (*Client) UnsubscribePrivate

func (c *Client) UnsubscribePrivate(s string)

func (*Client) UnsubscribePublic

func (c *Client) UnsubscribePublic(s string)

type Event

type Event struct {
	Scope  string      // global, public, private
	Stream string      // channel routing key
	Type   string      // event type
	Topic  string      // topic routing key (stream.type)
	Body   interface{} // event json body
}

type Hub

type Hub struct {
	// Register Requests from the clients.
	Requests chan Request

	// Unregister requests from clients.
	Unregister chan IClient

	// List of clients registered to public topics
	PublicTopics map[string]*Topic

	// List of clients registered to private topics
	PrivateTopics map[string]map[string]*Topic

	// map[prefix -> map[topic -> *Topic]]
	PrefixedTopics map[string]map[string]*Topic

	// Storage for incremental objects
	IncrementalObjects map[string]*IncrementalObject

	// map[prefix -> allowed roles]
	RBAC map[string][]string
	// contains filtered or unexported fields
}

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub(rbac map[string][]string) *Hub

func (*Hub) ListenWebsocketEvents

func (h *Hub) ListenWebsocketEvents()

func (*Hub) ReceiveMsg

func (h *Hub) ReceiveMsg(delivery amqp.Delivery)

ReceiveMsg handles AMQP messages

func (*Hub) SkipPrivateMsg

func (h *Hub) SkipPrivateMsg(delivery amqp.Delivery)

type IClient

type IClient interface {
	Send(string)
	Close()
	GetAuth() Auth
	GetSubscriptions() []string
	SubscribePublic(string)
	SubscribePrivate(string)
	UnsubscribePublic(string)
	UnsubscribePrivate(string)
}

FIXME: IClient looks very wrong.

type IncrementalObject

type IncrementalObject struct {
	Snapshot   string
	Increments []string
}

type Request

type Request struct {
	msg.Request
	// contains filtered or unexported fields
}

type Topic

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

func NewTopic

func NewTopic(h *Hub) *Topic

Jump to

Keyboard shortcuts

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