messages

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: MIT Imports: 9 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, l DebugLogger) <-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 DebugLogger added in v0.1.7

type DebugLogger interface {
	Debug(msg string, keyVals ...interface{})
}

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 SessionID added in v0.1.6

type SessionID 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) AsEvent

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

func (WebsocketMessage) AsREQ

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

SessionID is needed to make the requests globaly unique.

Jump to

Keyboard shortcuts

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