retrieval

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package retrieval implements bounded, deterministic read selection.

Index

Constants

View Source
const (
	MaxMentionAliases   = 64
	MaxMentionTermBytes = 256
)
View Source
const (
	MaxUnreadMembershipFallbacks = 100
	MaxUnreadPeekRequests        = 100
	MaxUnreadPeekConcurrency     = 8
)
View Source
const (
	MaxChannelHistoryPages = 100
)
View Source
const MaxDMHistoryRequests = 100
View Source
const MaxSearchPages = 100
View Source
const MaxThreadPages = 100

Variables

View Source
var (
	ErrInvalidUnreadRequest   = errors.New("invalid unread request")
	ErrIncompleteUnreadResult = errors.New("Mattermost did not provide a complete unread result")
)
View Source
var ErrInvalidChannelHistoryRequest = errors.New("invalid channel history request")
View Source
var ErrInvalidDMHistoryRequest = errors.New("invalid direct-message history request")
View Source
var ErrInvalidMentionsRequest = errors.New("invalid mentions request")
View Source
var ErrInvalidSearchRequest = errors.New("invalid search request")

Functions

This section is empty.

Types

type Boundary

type Boundary struct {
	CreateAt int64
	ID       string
}

type ChannelHistoryOptions

type ChannelHistoryOptions struct {
	Limit            int
	Since            *int64
	Boundary         *Boundary
	SafeBeforePostID string
	RequestBudget    *int
}

type ChannelHistoryResult

type ChannelHistoryResult struct {
	Posts           []mattermost.Post
	Completeness    Completeness
	SafeBeforeValid bool
}

func ChannelHistory

func ChannelHistory(ctx context.Context, source channelPageSource, channelID string, options ChannelHistoryOptions) (ChannelHistoryResult, error)

type Completeness

type Completeness uint8
const (
	CompletenessUnknown Completeness = iota
	CompletenessComplete
	CompletenessTruncated
)

type DMHistoryOptions

type DMHistoryOptions struct {
	Limit            int
	Since            *int64
	Boundary         *Boundary
	SafeBeforePostID string
}

type DMHistoryResult

type DMHistoryResult struct {
	Posts           []mattermost.Post
	Completeness    Completeness
	SafeBeforeValid bool
}

func DMHistory

func DMHistory(ctx context.Context, source channelPageSource, channelIDs []string, options DMHistoryOptions) (DMHistoryResult, error)

DMHistory retrieves each selected direct channel independently, then caps the merged known candidates. Completeness is unknown if any channel could not be queried completely, because a global top-N cannot then be proven.

type GroupDMHistoryOptions

type GroupDMHistoryOptions = DMHistoryOptions

GroupDMHistoryOptions intentionally shares the conversation-history contract with DMs: one command-wide request budget and one global seed cap.

type GroupDMHistoryResult

type GroupDMHistoryResult = DMHistoryResult

func GroupDMHistory

func GroupDMHistory(ctx context.Context, source channelPageSource, channelIDs []string, options GroupDMHistoryOptions) (GroupDMHistoryResult, error)

type HydrationResult

type HydrationResult struct {
	Posts          []mattermost.Post
	VisibleThreads VisibleThreadsMetadata
}

func HydrateVisibleThreads

func HydrateVisibleThreads(ctx context.Context, source threadPageSource, seeds []mattermost.Post, requested bool) (HydrationResult, error)

type MentionsOptions

type MentionsOptions struct {
	Username  string
	Aliases   []string
	Channel   *string
	ChannelID *string
	Since     *int64
	Limit     int
}

type MentionsResult

type MentionsResult struct {
	Posts        []mattermost.Post
	Completeness Completeness
}

func Mentions

func Mentions(ctx context.Context, source searchPageSource, teamID string, options MentionsOptions) (MentionsResult, error)

Mentions performs one bounded Search per distinct mention term, then applies the exact local predicate that the remote search endpoint cannot express.

type SearchOptions

type SearchOptions struct {
	Limit  int
	Accept func(mattermost.Post) bool
}

type SearchResult

type SearchResult struct {
	Posts        []mattermost.Post
	Matches      map[string][]string
	Completeness Completeness
}
func Search(ctx context.Context, source searchPageSource, teamID, terms string, options SearchOptions) (SearchResult, error)

type ThreadResult

type ThreadResult struct {
	Posts        []mattermost.Post
	Completeness Completeness
}

func Thread

func Thread(ctx context.Context, source threadPageSource, rootID string) (ThreadResult, error)

type UnreadEntry

type UnreadEntry struct {
	Channel      mattermost.Channel
	UnreadCount  int64
	MentionCount int64
	LastViewedAt int64
	Peek         []mattermost.Post
	PeekState    Completeness
}

type UnreadOptions

type UnreadOptions struct {
	TeamSelector      string
	PeekLimit         int
	PeekRequestBudget int
	PeekConcurrency   int
}

type UnreadResult

type UnreadResult struct {
	User    mattermost.User
	Team    mattermost.Team
	Entries []UnreadEntry
}

func Unread

func Unread(
	ctx context.Context,
	users currentUserSource,
	teams teamResolveSource,
	channels unreadChannelSource,
	posts channelPageSource,
	options UnreadOptions,
) (UnreadResult, error)

Unread builds one complete unread snapshot. Team membership metrics are the primary bounded source; only D/G channels absent from that team-scoped snapshot use exact per-channel membership reads.

type VisibleThreadsMetadata

type VisibleThreadsMetadata struct {
	Status            VisibleThreadsStatus
	HydratedRootCount int
	FailedRootIDs     []string
}

type VisibleThreadsStatus

type VisibleThreadsStatus uint8
const (
	VisibleThreadsNotRequested VisibleThreadsStatus = iota
	VisibleThreadsComplete
	VisibleThreadsPartial
)

Jump to

Keyboard shortcuts

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