messages

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EVENT = "EVENT"
	REQ   = "REQ"
	CLOSE = "CLOSE"
)

Variables

This section is empty.

Functions

func EventFilter

func EventFilter(filter Filter) primitive.M

MongoDB filter for StructuredEvents matching filter.

func ListenForMessages

func ListenForMessages(ctx context.Context, r MessageReader) <-chan WebsocketMessage

func SubscriptionFilter

func SubscriptionFilter(e event.Event) primitive.M

MongoDB filter for subscriptions that would match event.

Types

type A

type A primitive.A

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 M

type M primitive.M

type MessageReader

type MessageReader interface {
	Read(ctx context.Context) (websocket.MessageType, []byte, error)
}

type MessageType

type MessageType string

type Subscription

type Subscription struct {
	ID      SubscriptionID `json:"id" bson:"id"`
	Filters []Filter       `bson:"filter"`
}

func (Subscription) UniqueID

func (e Subscription) UniqueID() string

func (Subscription) UniqueIDFieldName

func (e Subscription) UniqueIDFieldName(format string) (string, error)

type SubscriptionID

type SubscriptionID string

type WebsocketMessage

type WebsocketMessage struct {
	MsgType MessageType
	Err     error
	Value   interface{}
}

func (WebsocketMessage) AsCLOSE

func (msg WebsocketMessage) AsCLOSE() (SubscriptionID, bool)

func (WebsocketMessage) AsEvent

func (msg WebsocketMessage) AsEvent() (event.Event, bool)

func (WebsocketMessage) AsREQ

func (msg WebsocketMessage) AsREQ() (Subscription, bool)

Jump to

Keyboard shortcuts

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