Documentation
¶
Index ¶
- Constants
- func EventFilter(filter Filter) primitive.M
- func ListenForMessages(ctx context.Context, r MessageReader) <-chan WebsocketMessage
- func SubscriptionFilter(e event.Event) primitive.M
- type A
- type Filter
- type M
- type MessageReader
- type MessageType
- type SessionID
- type Subscription
- type SubscriptionID
- type SubscriptionUUID
- type WebsocketMessage
Constants ¶
View Source
const ( EVENT = "EVENT" REQ = "REQ" CLOSE = "CLOSE" )
Variables ¶
This section is empty.
Functions ¶
func EventFilter ¶
MongoDB filter for StructuredEvents matching filter.
func ListenForMessages ¶
func ListenForMessages(ctx context.Context, r MessageReader) <-chan WebsocketMessage
Types ¶
type Filter ¶
type Filter struct {
IDs []event.ID `json:"ids" bson:"ids"`
Authors []event.PubKey `json:"authors" bson:"authors"`
Kinds []event.Kind `json:"kinds" bson:"kinds"`
E []event.ID `json:"#e" bson:"#e"`
P []event.PubKey `json:"#p" bson:"#p"`
Since event.Timestamp `json:"since" bson:"since"`
Until event.Timestamp `json:"until" bson:"until"`
Limit int64 `json:"limit" bson:"limit"`
}
type MessageReader ¶
type MessageType ¶
type MessageType string
type Subscription ¶
type Subscription struct {
ID SubscriptionID `bson:"id"`
Filters []Filter `bson:"filter"`
SessionID SessionID `bson:"session"`
}
func (Subscription) UUID ¶ added in v0.1.6
func (e Subscription) UUID() SubscriptionUUID
func (Subscription) UniqueMatch ¶ added in v0.1.6
func (e Subscription) UniqueMatch() primitive.M
type SubscriptionID ¶
type SubscriptionID string
type SubscriptionUUID ¶ added in v0.1.6
type SubscriptionUUID string
func GenerateSubscriptionUUID ¶ added in v0.1.6
func GenerateSubscriptionUUID(id SubscriptionID, session SessionID) SubscriptionUUID
type WebsocketMessage ¶
type WebsocketMessage struct {
MsgType MessageType
Err error
Value interface{}
}
func (WebsocketMessage) AsCLOSE ¶
func (msg WebsocketMessage) AsCLOSE(session SessionID) (SubscriptionUUID, bool)
func (WebsocketMessage) AsREQ ¶
func (msg WebsocketMessage) AsREQ(session SessionID) (Subscription, bool)
SessionID is needed to make the requests globaly unique.
Click to show internal directories.
Click to hide internal directories.