pubsub

package
Version: v0.20.1-0...-d0063a8 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: BSD-2-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package pubsub implements data storage using a publish–subscribe pattern.

Index

Constants

View Source
const (
	NS       = `http://jabber.org/protocol/pubsub`
	NSOwner  = `http://jabber.org/protocol/pubsub#owner`
	NSPaging = `http://jabber.org/protocol/pubsub#rsm`
)

Various namespaces used by this package, provided as a convenience.

Variables

This section is empty.

Functions

func CreateNode

func CreateNode(ctx context.Context, s *xmpp.Session, node string, cfg *form.Data) error

CreateNode adds a new node on the pubsub service with the provided configuration (or the default configuration if none is provided).

func CreateNodeIQ

func CreateNodeIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node string, cfg *form.Data) error

CreateNodeIQ is like Publish except that it allows modifying the IQ. Changes to the IQ type will have no effect.

func Delete

func Delete(ctx context.Context, s *xmpp.Session, node, id string, notify bool) error

Delete removes an item from the pubsub node.

func DeleteIQ

func DeleteIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node, id string, notify bool) error

DeleteIQ is like Publish except that it allows modifying the IQ. Changes to the IQ type will have no effect.

func GetConfig

func GetConfig(ctx context.Context, s *xmpp.Session, node string) (*form.Data, error)

GetConfig fetches the configurable options for the given node.

func GetConfigIQ

func GetConfigIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node string) (*form.Data, error)

GetConfigIQ is like GetConfig except that it allows modifying the IQ. Changes to the IQ type will have no effect.

func GetDefaultConfig

func GetDefaultConfig(ctx context.Context, s *xmpp.Session) (*form.Data, error)

GetDefaultConfig fetches the configurable options for the given node.

func GetDefaultConfigIQ

func GetDefaultConfigIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ) (*form.Data, error)

GetDefaultConfigIQ is like GetDefaultConfig except that it allows modifying the IQ. Changes to the IQ type will have no effect.

func Publish

func Publish(ctx context.Context, s *xmpp.Session, node, id string, item xml.TokenReader) (string, error)

Publish copies the first element from the provided token reader to a node on the server from which it can be retrieved later.

func PublishIQ

func PublishIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node, id string, item xml.TokenReader) (string, error)

PublishIQ is like Publish except that it allows modifying the IQ. Changes to the IQ type will have no effect.

func SetConfig

func SetConfig(ctx context.Context, s *xmpp.Session, node string, cfg *form.Data) error

SetConfig submits the provided dataform to the server for the given node.

func SetConfigIQ

func SetConfigIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node string, cfg *form.Data) error

SetConfigIQ is like SetConfig except that it allows modifying the IQ. Changes to the IQ type will have no effect.

Types

type Iter

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

Iter is an iterator over payload items.

func Fetch

func Fetch(ctx context.Context, s *xmpp.Session, q Query) *Iter

Fetch requests all items in a node and returns an iterator over each item.

Processing the session will become blocked until the iterator is closed. Any errors encountered while creating the iter are deferred until the iter is used.

func FetchIQ

func FetchIQ(ctx context.Context, iq stanza.IQ, s *xmpp.Session, q Query) *Iter

FetchIQ is like Fetch but it allows you to customize the IQ. Changing the type of the provided IQ has no effect.

func (*Iter) Close

func (i *Iter) Close() error

Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.

func (*Iter) Err

func (i *Iter) Err() error

Err returns the last error encountered by the iterator (if any).

func (*Iter) Item

func (i *Iter) Item() (id string, r xml.TokenReader)

Item returns the last item parsed by the iterator. If no payloads were requested in the original query the reader may be nil.

func (*Iter) Next

func (i *Iter) Next() bool

Next returns true if there are more items to decode.

type Query

type Query struct {
	// Node is the ID of a node to query.
	Node string

	// Item is a specific item to fetch by its ID.
	// Most users should use one of the methods specifically for fetching
	// individual items instead of filtering the results and using an iterator
	// over 0 or 1 items.
	Item string

	// MaxItems can be used to restrict results to the most recent items.
	MaxItems uint64
}

Query represents the options for fetching and iterating over pubsub items.

Jump to

Keyboard shortcuts

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