Help us shape the future of Go! Take the 2026 Go Developer Survey

feed

package
v0.69.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package feed is the desktop's GitHub fetch layer: the wire Item type and a cached, coalesced LiveProvider the pipeline producer uses to turn a source into event_log rows. The old profiles/feeds config machinery folded into the flow graph (cmd/desktop/internal/app/flow); what remains here is the GitHub fetch core.

Index

Constants

View Source
const (

	// DefaultPollInterval is how often the pipeline producer ticks; matches
	// the settings design's default ("Every 60s").
	DefaultPollInterval = time.Minute
)

Variables

View Source
var ErrNotAuthenticated = errors.New("feed: not authenticated")

ErrNotAuthenticated is returned when no GitHub token is available.

Functions

This section is empty.

Types

type AbsentRef

type AbsentRef struct {
	Repo string
	Num  int
}

AbsentRef identifies one item that disappeared from a source result and needs its current lifecycle state confirmed.

type Item

type Item struct {
	ID        string `json:"id"`
	Kind      string `json:"kind"` // "PR" | "Issue"
	Repo      string `json:"repo"`
	Num       int    `json:"num"`
	Title     string `json:"title"`
	Author    string `json:"author"`
	State     string `json:"state,omitempty"`
	UpdatedAt int64  `json:"updatedAt"` // GitHub's last-updated time, unix milliseconds
	Unread    bool   `json:"unread"`
	// Reason is the GitHub notification reason (e.g. "review_requested"),
	// empty for items known only from search.
	Reason    string   `json:"reason,omitempty"`
	Labels    []string `json:"labels"`
	Branch    string   `json:"branch"`
	CI        string   `json:"ci,omitempty"`
	Review    string   `json:"review,omitempty"`
	Additions *int     `json:"additions,omitempty"`
	Deletions *int     `json:"deletions,omitempty"`
	Body      string   `json:"body"`
	Prompt    string   `json:"prompt"`
	URL       string   `json:"url"`
}

Item is a normalized GitHub item (PR or issue) produced by a source fetch. Its JSON payload is stored in a durable inbox row.

type LiveProvider

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

LiveProvider fetches source items from the GitHub API with per-source caching and singleflight coalescing. It is the seam the desktop pipeline producer uses to turn a sources.github node into event_log rows — the only GitHub-fetch implementation in the desktop.

func NewLiveProvider

func NewLiveProvider(client *ghclient.Client, tokens credentials.Resolver, logger zerolog.Logger) *LiveProvider

func (*LiveProvider) ConfirmTerminal

func (p *LiveProvider) ConfirmTerminal(ctx context.Context, refs []AbsentRef) ([]ghclient.ItemState, error)

ConfirmTerminal hydrates the current state of items that disappeared from a source result. The caller uses each state to distinguish terminal lifecycle changes from non-terminal query churn. It uses the same token and rate-limit cooldown as polling.

A ref whose repo does not split into owner/name, or whose number is not positive, comes back Found: false rather than failing the batch.

func (*LiveProvider) Invalidate

func (p *LiveProvider) Invalidate()

Invalidate drops the fetch cache so the next call refetches. Auth changes call it: a different account must never be served the previous token's data.

func (*LiveProvider) PrefetchSearch

func (p *LiveProvider) PrefetchSearch(ctx context.Context, defs []SourceDef) error

PrefetchSearch batch-fetches search defs and stores their results in the SourceItems cache. A failed batch is retained per key so draining the individual sources does not retry it during this tick.

func (*LiveProvider) SetRecorder

func (p *LiveProvider) SetRecorder(r activity.Recorder)

SetRecorder attaches an activity recorder so rate-limit pauses surface in the Activity view. Nil is valid and disables recording.

func (*LiveProvider) SetSearchTTL

func (p *LiveProvider) SetSearchTTL(ttl time.Duration)

SetSearchTTL sets the search cache TTL. Values <= 0 retain the default poll interval. It may be updated while the producer is running.

func (*LiveProvider) SourceItems

func (p *LiveProvider) SourceItems(ctx context.Context, src SourceDef) ([]Item, error)

SourceItems returns one source's current items — served from cache within the fetch TTL, otherwise fetched via the conditional, singleflight-coalesced path (see fetchSource).

type SourceDef

type SourceDef struct {
	ID    string `json:"id"`
	Kind  string `json:"kind"` // "search" | "notifications"
	Query string `json:"query,omitempty"`
	// Limit bounds items per fetch. 0 uses defaultSourceLimit.
	Limit int `json:"limit,omitempty"`
}

SourceDef is one GitHub fetch request. It is no longer a config entry — the sources.github flow node embeds these fields — but it survives as the value type LiveProvider.SourceItems takes and caches on (keyed by kind+query+limit via sourceKey), so any number of source nodes requesting the same data share one API request.

Jump to

Keyboard shortcuts

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