pubsub

package
v0.21.4 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 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`
	NSErrors  = `http://jabber.org/protocol/pubsub#errors`
	NSEvent   = `http://jabber.org/protocol/pubsub#event`
	NSOptions = `http://jabber.org/protocol/pubsub#subscription-options`
	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 Condition added in v0.21.4

type Condition uint32

Condition is the underlying cause of a pubsub error.

const (
	ClosedNode             Condition = iota // closed-node
	ConfigRequired                          // configuration-required
	InvalidJID                              // invalid-jid
	InvalidOptions                          // invalid-options
	InvalidPayload                          // invalid-payload
	InvalidSubID                            // invalid-subid
	ItemForbidden                           // item-forbidden
	ItemRequired                            // item-required
	JIDRequired                             // jid-required
	MaxItemsExceeded                        // max-items-exceeded
	MaxNodesExceeded                        // max-nodes-exceeded
	NodeIDRequired                          // nodeid-required
	NotInRosterGroup                        // not-in-roster-group
	NotSubscribed                           // not-subscribed
	PayloadTooBig                           // payload-too-big
	PayloadRequired                         // payload-required
	PendingSubscription                     // pending-subscription
	PresenceRequired                        // presence-subscription-required
	SubIDRequired                           // subid-required
	TooManySubscriptions                    // too-many-subscriptions
	Unsupported                             // unsupported
	UnsupportedAccessModel                  // unsupported-access-model
)

Valid pubsub Conditions.

func (Condition) String added in v0.21.4

func (i Condition) String() string

type Feature added in v0.21.4

type Feature uint32

Feature is a specific pubsub feature that may be reported in an error as being unsupported.

const (
	FeatureAccessAuthorize           Feature = iota // access-authorize
	FeatureAccessOpen                               // access-open
	FeatureAccessPresence                           // access-presence
	FeatureAccessRoster                             // access-roster
	FeatureAccessWhitelist                          // access-whitelist
	FeatureAutoCreate                               // auto-create
	FeatureAutoSubscribe                            // auto-subscribe
	FeatureCollections                              // collections
	FeatureConfigNode                               // config-node
	FeatureCreateAndConfigure                       // create-and-configure
	FeatureCreateNodes                              // create-nodes
	FeatureDeleteItems                              // delete-items
	FeatureDeleteNodes                              // delete-nodes
	FeatureFilteredNotifications                    // filtered-notifications
	FeatureGetPending                               // get-pending
	FeatureInstantNodes                             // instant-nodes
	FeatureItemIDs                                  // item-ids
	FeatureLastPublished                            // last-published
	FeatureLeasedSubscription                       // leased-subscription
	FeatureManageSubscriptions                      // manage-subscriptions
	FeatureMemberAffiliation                        // member-affiliation
	FeatureMetaData                                 // meta-data
	FeatureModifyAffiliations                       // modify-affiliations
	FeatureMultiCollection                          // multi-collection
	FeatureMultiSubscribe                           // multi-subscribe
	FeatureOutcastAffiliation                       // outcast-affiliation
	FeaturePersistentItems                          // persistent-items
	FeaturePresenceNotifications                    // presence-notifications
	FeaturePresenceSubscribe                        // presence-subscribe
	FeaturePublish                                  // publish
	FeaturePublishOptions                           // publish-options
	FeaturePublishOnlyAffiliation                   // publish-only-affiliation
	FeaturePublisherAffiliation                     // publisher-affiliation
	FeaturePurgeNodes                               // purge-nodes
	FeatureRetractItems                             // retract-items
	FeatureRetrieveAffiliations                     // retrieve-affiliations
	FeatureRetrieveDefault                          // retrieve-default
	FeatureRetrieveItems                            // retrieve-items
	FeatureRetrieveSubscriptions                    // retrieve-subscriptions
	FeatureSubscribe                                // subscribe
	FeatureSubscriptionOptions                      // subscription-options
	FeatureSubscriptionNotifications                // subscription-notifications
)

Valid pubsub Features.

func (Feature) String added in v0.21.4

func (i Feature) String() string

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.

type SubType added in v0.21.4

type SubType uint8

SubType represents the state of a particular subscription.

const (
	SubNone         SubType = iota // none
	SubPending                     // pending
	SubSubscribed                  // subscribed
	SubUnconfigured                // unconfigured
)

A list of possible subscription types.

func (SubType) String added in v0.21.4

func (i SubType) String() string

Jump to

Keyboard shortcuts

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