Documentation
¶
Overview ¶
Package pubsub implements data storage using a publish–subscribe pattern.
Index ¶
- Constants
- func CreateNode(ctx context.Context, s *xmpp.Session, node string, cfg *form.Data) error
- func CreateNodeIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node string, ...) error
- func Delete(ctx context.Context, s *xmpp.Session, node, id string, notify bool) error
- func DeleteIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node, id string, ...) error
- func GetConfig(ctx context.Context, s *xmpp.Session, node string) (*form.Data, error)
- func GetConfigIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node string) (*form.Data, error)
- func GetDefaultConfig(ctx context.Context, s *xmpp.Session) (*form.Data, error)
- func GetDefaultConfigIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ) (*form.Data, error)
- func Publish(ctx context.Context, s *xmpp.Session, node, id string, item xml.TokenReader) (string, error)
- func PublishIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node, id string, ...) (string, error)
- func SetConfig(ctx context.Context, s *xmpp.Session, node string, cfg *form.Data) error
- func SetConfigIQ(ctx context.Context, s *xmpp.Session, iq stanza.IQ, node string, ...) error
- type Condition
- type Feature
- type Iter
- type Query
- type SubType
Constants ¶
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 ¶
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 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 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 ¶
GetDefaultConfig fetches the configurable options for the given node.
func GetDefaultConfigIQ ¶
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.
Types ¶
type Condition ¶ added in v0.21.4
type Condition uint32
Condition is the underlying cause of a pubsub error.
const ( CondNone Condition = iota CondClosedNode // closed-node CondConfigRequired // configuration-required CondInvalidJID // invalid-jid CondInvalidOptions // invalid-options CondInvalidPayload // invalid-payload CondInvalidSubID // invalid-subid CondItemForbidden // item-forbidden CondItemRequired // item-required CondJIDRequired // jid-required CondMaxItemsExceeded // max-items-exceeded CondMaxNodesExceeded // max-nodes-exceeded CondNodeIDRequired // nodeid-required CondNotInRosterGroup // not-in-roster-group CondNotSubscribed // not-subscribed CondPayloadTooBig // payload-too-big CondPayloadRequired // payload-required CondPendingSubscription // pending-subscription CondPresenceRequired // presence-subscription-required CondSubIDRequired // subid-required CondTooManySubscriptions // too-many-subscriptions CondUnsupported // unsupported CondUnsupportedAccessModel // unsupported-access-model )
Valid pubsub Conditions.
func (*Condition) UnmarshalXML ¶ added in v0.22.0
UnmarshalXML implements xml.Unmarshaler.
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.
type Iter ¶
type Iter struct {
// contains filtered or unexported fields
}
Iter is an iterator over payload items.
func Fetch ¶
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 ¶
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 ¶
Close indicates that we are finished with the given iterator and processing the stream may continue. Calling it multiple times has no effect.
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.