Documentation ¶
Overview ¶
Package history implements fetching messages from an archive.
Index ¶
Constants ¶
const ( NS = `urn:xmpp:mam:2` NSExt = `urn:xmpp:mam:2#extended` )
The namespaces used by this package, provided as a convenience.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles incoming messages from an archive and either passes them on to the underlying handler if they are not being tracked or ensures they are passed to the correct iterator for syncronous processing if they are.
func NewHandler ¶
func NewHandler(inner mux.MessageHandler) *Handler
NewHandler returns a handler capable of handling messages sent from an archive. Any messages that are part of untracked queries will be passed to the inner handler.
func (*Handler) Fetch ¶
Fetch requests messages from the archive and returns an iterator over the results. Any errors encountered are deferred and returned by the iterator.
func (*Handler) FetchIQ ¶
FetchIQ is like Fetch but it allows modifying the underlying IQ. Changing the type of the IQ has no effect.
func (*Handler) HandleMessage ¶
HandleMessage implements mux.MessageHandler.
type Iter ¶
type Iter struct {
// contains filtered or unexported fields
}
Iter is an iterator over message history.
func (*Iter) Close ¶
Close stops iterating over this query. Future messages will still be received but will be handled by the fallback handler instead.
func (*Iter) Current ¶
func (i *Iter) Current() xml.TokenReader
Current returns the current message stream read from the iterator.
type Query ¶
type Query struct { // Query parameters ID string // Filters With jid.JID Start time.Time End time.Time BeforeID string AfterID string IDs []string // Limit limits the total number of messages returned. Limit uint64 // Last starts fetching from the last page (or before PageID if set). Last bool // PageID is the ID of a message within the existing query that we should // start paging after (or before, if Last is set). // This lets us skip over the redundant message when querying with Start/End, // or skip to a later page within the query if we abandoned it and need to // start over (but don't want to fetch all the pages we've already processed). PageID string // Reverse flips messages returned within a page. Reverse bool }
Query is a request to the archive for data. An empty query indicates all messages should be fetched without a filter and with a random ID.
func (*Query) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*Query) TokenReader ¶
func (f *Query) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
func (*Query) UnmarshalXML ¶
UnmarshalXML implements xml.Unmarshaler.
type Result ¶
Result is the metadata (not messages) returned from a MAM query.
func Fetch ¶
Fetch requests messages from the archive. Messages are received asyncronously and Fetch blocks until the session handler has processed them all.
func FetchIQ ¶
FetchIQ is like Fetch but it allows modifying the underlying IQ. Changing the type of the IQ has no effect.
func (*Result) MarshalXML ¶
MarshalXML implements xml.Marshaler.
func (*Result) TokenReader ¶
func (r *Result) TokenReader() xml.TokenReader
TokenReader implements xmlstream.Marshaler.
func (*Result) UnmarshalXML ¶
UnmarshalXML implements xml.Unmarshaler.