store

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Overview

Package store owns Postgres connectivity and schema migration.

Index

Constants

This section is empty.

Variables

View Source
var ErrBranchReconciliationSuperseded = errors.New(
	"branch reconciliation superseded",
)

ErrBranchReconciliationSuperseded means a newer direct entity generation or branch generation won before a branch page's post-fetch write transaction. The remote result is deliberately discarded without retrying that target.

View Source
var ErrBranchRefreshGenerationContention = errors.New(
	"branch refresh generation contention",
)

ErrBranchRefreshGenerationContention asks dispatch to roll back and retry the complete batch after an already-open entity transaction releases a generation row. The bulk transaction has made no externally visible change until that retry commits.

View Source
var ErrObservationSuperseded = errors.New("observation superseded")

ErrObservationSuperseded means another write committed after the remote observation began. The stale response is discarded before any cache row or outbox event can commit; direct refresh handlers retry it with a new remote observation before returning control to River.

View Source
var ErrRefreshGenerationSuperseded = errors.New(
	"refresh generation superseded",
)

ErrRefreshGenerationSuperseded means a branch bulk transaction claimed a later direct-entity generation while this authoritative fetch was in flight. The response is discarded before any cache row can be committed.

Functions

func ChecksEntityKey

func ChecksEntityKey(
	installationID int64,
	repositoryGitHubID int64,
	sha string,
) string

ChecksEntityKey returns the normative lock and change-stream key for a head SHA's check runs.

func Connect

func Connect(
	ctx context.Context,
	databaseURL string,
	options ...ConnectOption,
) (*pgxpool.Pool, error)

Connect opens and verifies a Postgres pool with the cache durability invariants enabled.

func Migrate

func Migrate(ctx context.Context, pool *pgxpool.Pool) error

Migrate applies River's migrations followed by our own plain-SQL files, in lexical order, tracked in schema_migrations. Each of our migrations runs in its own transaction and is applied at most once.

func PullRequestEntityKey

func PullRequestEntityKey(
	installationID int64,
	repositoryGitHubID int64,
	number int,
) string

PullRequestEntityKey returns the normative lock, scope, and change-stream key for a pull request.

func RepoRulesEntityKey

func RepoRulesEntityKey(
	installationID int64,
	repositoryGitHubID int64,
) string

RepoRulesEntityKey returns the normative lock and change-stream key for repository rules.

func RepositoryEntityKey

func RepositoryEntityKey(installationID, repositoryGitHubID int64) string

RepositoryEntityKey returns the normative lock and change-stream key for a repository.

func StackEntityKey

func StackEntityKey(
	installationID int64,
	repositoryGitHubID int64,
	number int,
) string

StackEntityKey returns the normative lock, scope, and change-stream key for a stack.

func WithBranchReconciliationFence added in v0.5.0

func WithBranchReconciliationFence(
	ctx context.Context,
	fence *BranchReconciliationFence,
) context.Context

WithBranchReconciliationFence attaches a page target's generation proof to the context consumed by the entity writer.

func WithRefreshGenerationFence added in v0.5.0

func WithRefreshGenerationFence(
	ctx context.Context,
	fence RefreshGenerationFence,
) context.Context

WithRefreshGenerationFence attaches a direct worker's start generation to the short post-fetch entity transaction.

Types

type ApplyPullRequestResult

type ApplyPullRequestResult struct {
	Applied               bool
	DomainChanged         bool
	ReviewRequestsChanged bool
	ReviewsChanged        bool
	CommentsChanged       bool
	ChangeInputsChanged   bool
	StackStateChanged     bool
	OldStackNumber        *int
	NewStackNumber        *int
	OldHeadSHA            string
	NewHeadSHA            string
}

ApplyPullRequestResult describes the accepted pull-request transition.

type ApplyStackResult

type ApplyStackResult struct {
	Applied        bool
	JoinedPRs      []int
	LeftPRs        []int
	MovedPRs       []int
	PriorStackByPR map[int]int
}

ApplyStackResult describes stack membership changes caused by a write.

type BranchBulkResult added in v0.5.0

type BranchBulkResult struct {
	RepoID               int64
	Generation           int64
	Targets              []BranchReconciliationTarget
	RepositoryRefreshKey string
	Repositories         int
	PullRequests         int
	Stacks               int
	SupersededPages      int64
}

BranchBulkResult describes one committed-ready local transition and the bounded remote work that must follow it.

type BranchPushHint added in v0.5.0

type BranchPushHint struct {
	RepoFullName    string
	Branch          string
	BeforeSHA       string
	AfterSHA        string
	TransitionKnown bool
	Deleted         bool
	Forced          bool
	DeliveryGUID    string
	ReceivedAt      time.Time
}

BranchPushHint is the narrow local fact proven by a push payload. It is not an authoritative pull-request, stack, or repository observation.

type BranchReconciliationFence added in v0.5.0

type BranchReconciliationFence struct {
	RepoID            int64
	Branch            string
	BranchGeneration  int64
	RefreshKind       string
	RefreshKey        string
	RefreshGeneration int64
	EntityKey         string
}

BranchReconciliationFence is the local generation proof attached to one bounded page target. It is checked only after all external I/O, inside the short entity write transaction (C-C6).

type BranchReconciliationTarget added in v0.5.0

type BranchReconciliationTarget struct {
	RefreshKind       string `json:"kind"`
	RefreshKey        string `json:"key"`
	EntityKey         string `json:"entity_key"`
	RefreshGeneration int64  `json:"generation"`
}

BranchReconciliationTarget is one pointer in a bounded branch page. The bulk transaction advances and claims its entity generation locally; any later direct intent advances it again and therefore supersedes this target.

type BranchRefreshGenerationKey added in v0.5.0

type BranchRefreshGenerationKey struct {
	Kind string `json:"kind"`
	Key  string `json:"refresh_key"`
}

BranchRefreshGenerationKey is one direct-refresh generation advanced by a branch transition. Bulk apply locks these keys nonblockingly after its entity-row transition, using the same advisory/row protocol as ordinary refresh producers without inverting transactional entity follow-up hooks.

type CacheObserver

type CacheObserver interface {
	CacheWrite(context.Context, string, bool, bool)
}

CacheObserver is M6's C-C2 compare-and-swap accounting seam.

type ChangedFileRecord added in v0.3.0

type ChangedFileRecord struct {
	Path         string
	PreviousPath string
	ChangeType   string
}

ChangedFileRecord is one member of the bounded current PR diff snapshot.

type CheckRunRecord

type CheckRunRecord struct {
	GitHubID        int64           `json:"gh_id"`
	NodeID          string          `json:"node_id"`
	Name            string          `json:"name"`
	Status          string          `json:"status"`
	Conclusion      string          `json:"conclusion"`
	DetailsURL      string          `json:"details_url"`
	AppSlug         string          `json:"app_slug"`
	StartedAt       *time.Time      `json:"started_at"`
	CompletedAt     *time.Time      `json:"completed_at"`
	GitHubUpdatedAt *time.Time      `json:"gh_updated_at"`
	SemanticVersion string          `json:"semantic_version"`
	Observed        json.RawMessage `json:"observed"`
}

CheckRunRecord is one check run in an authoritative head-SHA snapshot.

type ChecksRecord

type ChecksRecord struct {
	Repository RepositoryRecord
	HeadSHA    string
	Runs       []CheckRunRecord
	ETag       string
	SyncedAt   time.Time
	Source     SyncSource
}

ChecksRecord is the authoritative check-run set for one repository head SHA.

type CodeownersSourceRecord added in v0.4.0

type CodeownersSourceRecord struct {
	Ref     string
	SHA     string
	Path    string
	State   string
	Content string
	Hash    string
	ETag    string
}

CodeownersSourceRecord is the durable effective source mirrored by a prior PR observation, including the exact ref/SHA provenance required for reuse.

type ConnectOption

type ConnectOption func(*connectOptions)

ConnectOption customizes Postgres connectivity.

func WithRDSIAMAuthentication added in v0.2.0

func WithRDSIAMAuthentication() ConnectOption

WithRDSIAMAuthentication generates a fresh Amazon RDS IAM authentication token for every new physical pool connection. DATABASE_URL must not contain a password when this option is used.

func WithTracerProvider

func WithTracerProvider(provider trace.TracerProvider) ConnectOption

WithTracerProvider instruments pgx operations with the supplied provider.

type EntityWriter

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

EntityWriter owns C-C1..C-C6. Network fetches never enter this package.

func NewEntityWriter

func NewEntityWriter(
	pool *pgxpool.Pool,
	observers ...CacheObserver,
) *EntityWriter

NewEntityWriter constructs a cache writer backed by pool.

func (*EntityWriter) ApplyBranchPushTx added in v0.5.0

func (w *EntityWriter) ApplyBranchPushTx(
	ctx context.Context,
	tx pgx.Tx,
	hint *BranchPushHint,
) (BranchBulkResult, error)

ApplyBranchPushTx advances the branch generation, applies only exact before-SHA matches, retains dependent observations behind read-time SHA fences, marks derivation dirty, and emits reference events. The caller owns tx and must acquire the C-S2 writer fence before calling this method. No method on this path performs network I/O (C-C6).

func (*EntityWriter) ApplyChecksObserved

func (w *EntityWriter) ApplyChecksObserved(
	ctx context.Context,
	observation *Observation,
	checks ChecksRecord,
) (bool, error)

ApplyChecksObserved conditionally replaces a head SHA's check runs against its optimistic observation version.

func (*EntityWriter) ApplyPullRequest

func (w *EntityWriter) ApplyPullRequest(
	ctx context.Context,
	pull PullRequestRecord,
) (ApplyPullRequestResult, error)

ApplyPullRequest conditionally applies a direct pull-request observation.

func (*EntityWriter) ApplyPullRequestBatch

func (w *EntityWriter) ApplyPullRequestBatch(
	ctx context.Context,
	applies []PullRequestApply,
) map[string]PullRequestApplyOutcome

ApplyPullRequestBatch preserves independent outcomes. Transport errors are handled by the caller; one poisoned entity never discards healthy siblings.

func (*EntityWriter) ApplyPullRequestObserved

func (w *EntityWriter) ApplyPullRequestObserved(
	ctx context.Context,
	observation *Observation,
	pull PullRequestRecord,
	hook PullRequestHook,
) (ApplyPullRequestResult, error)

ApplyPullRequestObserved conditionally applies a pull request against its optimistic observation version.

func (*EntityWriter) ApplyRepoRulesObserved

func (w *EntityWriter) ApplyRepoRulesObserved(
	ctx context.Context,
	observation *Observation,
	rules RepoRulesRecord,
) (bool, error)

ApplyRepoRulesObserved conditionally replaces repository rules against the optimistic repository-rules observation version.

func (*EntityWriter) ApplyRepository

func (w *EntityWriter) ApplyRepository(
	ctx context.Context,
	repository RepositoryRecord,
	source SyncSource,
	etag string,
	observedAt time.Time,
) (bool, error)

ApplyRepository conditionally applies a direct repository observation.

func (*EntityWriter) ApplyRepositoryObserved

func (w *EntityWriter) ApplyRepositoryObserved(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	source SyncSource,
	etag string,
	observedAt time.Time,
) (bool, error)

ApplyRepositoryObserved conditionally applies a repository against its optimistic observation version.

func (*EntityWriter) ApplyStack

func (w *EntityWriter) ApplyStack(
	ctx context.Context,
	stack StackRecord,
) (ApplyStackResult, error)

ApplyStack conditionally applies a direct stack observation.

func (*EntityWriter) ApplyStackObserved

func (w *EntityWriter) ApplyStackObserved(
	ctx context.Context,
	observation *Observation,
	stack StackRecord,
	hook StackHook,
) (ApplyStackResult, error)

ApplyStackObserved conditionally applies a stack against its optimistic observation version.

func (*EntityWriter) BeginObservation

func (w *EntityWriter) BeginObservation(
	ctx context.Context,
	entityKey string,
) (*Observation, error)

BeginObservation snapshots the entity's last committed write version. The query checks out a connection only for its own duration; the returned token owns no database resource while callers perform remote I/O.

func (*EntityWriter) BranchReconciliationGenerationKeysTx added in v0.5.0

func (w *EntityWriter) BranchReconciliationGenerationKeysTx(
	ctx context.Context,
	tx pgx.Tx,
	repoFullName string,
	branch string,
) ([]BranchRefreshGenerationKey, error)

BranchReconciliationGenerationKeysTx returns the direct entity generation keys that the corresponding bulk transaction will advance. ApplyBranchPushTx acquires their standard refresh-generation locks only after changing entity rows so it composes with entity writers whose transactional hooks produce refresh generations.

func (*EntityWriter) BranchTargets

func (w *EntityWriter) BranchTargets(
	ctx context.Context,
	repoFullName string,
	branch string,
) ([]string, error)

BranchTargets returns the derivation scopes affected by a branch change.

func (*EntityWriter) ChecksMetadata

func (w *EntityWriter) ChecksMetadata(
	ctx context.Context,
	repo string,
	headSHA string,
) (FetchMetadata, error)

ChecksMetadata returns conditional-fetch metadata for one head SHA.

func (*EntityWriter) PullRequestChangeMetadata added in v0.4.0

func (w *EntityWriter) PullRequestChangeMetadata(
	ctx context.Context,
	repo string,
	number int,
	baseSHA string,
	headSHA string,
) (PullRequestChangeFetchMetadata, error)

PullRequestChangeMetadata returns the changed-files validator and cached rename supplements. The query completes before callers perform REST I/O (C-C6).

func (*EntityWriter) PullRequestMetadata

func (w *EntityWriter) PullRequestMetadata(
	ctx context.Context,
	repo string,
	number int,
) (FetchMetadata, error)

PullRequestMetadata returns conditional-fetch metadata for one pull request.

func (*EntityWriter) RecordBranchReconciliationPagesTx added in v0.5.0

func (w *EntityWriter) RecordBranchReconciliationPagesTx(
	ctx context.Context,
	tx pgx.Tx,
	repoID int64,
	branch string,
	generation int64,
	pageTargetCounts []int,
) error

RecordBranchReconciliationPagesTx makes the durable page manifest part of the same transaction that inserts its River jobs.

func (*EntityWriter) RefreshGeneration added in v0.5.0

func (w *EntityWriter) RefreshGeneration(
	ctx context.Context,
	kind string,
	refreshKey string,
) (int64, error)

RefreshGeneration returns the current generation for a pointer without creating it. A zero generation is a meaningful snapshot proving that no row existed when an incidental parent observation began.

func (*EntityWriter) RepoRulesMetadata

func (w *EntityWriter) RepoRulesMetadata(
	ctx context.Context,
	repo string,
) (FetchMetadata, int64, error)

RepoRulesMetadata returns conditional-fetch metadata for repository rules.

func (*EntityWriter) Repository

func (w *EntityWriter) Repository(
	ctx context.Context,
	fullName string,
) (RepositoryRecord, error)

Repository resolves a current repository record by full name or alias.

func (*EntityWriter) ResolveFileOwnerIdentities added in v0.3.0

func (w *EntityWriter) ResolveFileOwnerIdentities(
	ctx context.Context,
	repoGitHubID int64,
	repositoryOwner string,
	owners []FileOwnerRecord,
) ([]FileOwnerRecord, error)

ResolveFileOwnerIdentities fills stable identities from facts already mirrored for this repository. It never performs a live GitHub lookup and leaves unknown users, teams, email owners, and malformed tokens explicit.

func (*EntityWriter) StackMetadata

func (w *EntityWriter) StackMetadata(
	ctx context.Context,
	repo string,
	number int,
) (FetchMetadata, error)

StackMetadata returns conditional-fetch metadata for one stack.

func (*EntityWriter) TombstonePullRequestObserved

func (w *EntityWriter) TombstonePullRequestObserved(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	number int,
	source SyncSource,
	at time.Time,
	hook PullRequestHook,
) (ApplyPullRequestResult, error)

TombstonePullRequestObserved conditionally tombstones a pull request against its optimistic observation version.

func (*EntityWriter) TombstoneRepositoryObserved

func (w *EntityWriter) TombstoneRepositoryObserved(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	source SyncSource,
	at time.Time,
) (bool, error)

TombstoneRepositoryObserved applies C-R3's verified repository disappearance through the same lock/dirty/outbox transaction as every other authoritative cache mutation. Child mirrors remain retained history; live readers and future sweeps exclude them through the repository tombstone.

func (*EntityWriter) TombstoneStackObserved

func (w *EntityWriter) TombstoneStackObserved(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	number int,
	source SyncSource,
	at time.Time,
	hook StackHook,
) (ApplyStackResult, error)

TombstoneStackObserved conditionally tombstones a stack against its optimistic observation version.

func (*EntityWriter) TouchChecks

func (w *EntityWriter) TouchChecks(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	headSHA string,
	checkedAt time.Time,
	etag string,
) error

TouchChecks records a successful unchanged check-runs observation.

func (*EntityWriter) TouchPullRequest

func (w *EntityWriter) TouchPullRequest(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	number int,
	checkedAt time.Time,
	etag string,
) (bool, error)

TouchPullRequest records a successful unchanged pull-request metadata observation. The supplied validator must still belong to the current row; GraphQL participation and changed-file clocks are owned by their own fetches.

func (*EntityWriter) TouchRepoRules

func (w *EntityWriter) TouchRepoRules(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	checkedAt time.Time,
	etag string,
) error

TouchRepoRules records a successful unchanged repository-rules observation.

func (*EntityWriter) TouchStack

func (w *EntityWriter) TouchStack(
	ctx context.Context,
	observation *Observation,
	repository RepositoryRecord,
	number int,
	checkedAt time.Time,
	etag string,
) error

TouchStack records a successful unchanged stack observation.

func (*EntityWriter) WithObservationTransaction added in v0.5.1

func (w *EntityWriter) WithObservationTransaction(
	ctx context.Context,
	observation *Observation,
	fn func(pgx.Tx) error,
) error

WithObservationTransaction runs fn while holding the observation's short transaction-scoped entity lock and committed-version fence. It is intended for non-cache state that must remain consistent with an observed cache snapshot. It does not advance the cache write version.

type FetchMetadata

type FetchMetadata struct {
	NodeID                 string
	ETag                   string
	Title                  string
	State                  string
	Draft                  bool
	AuthorLogin            string
	HeadRef                string
	BaseRef                string
	ReviewDecision         string
	MergeableState         string
	StackNumber            *int
	StackPosition          *int
	GitHubUpdatedAt        time.Time
	BaseSHA                string
	HeadSHA                string
	RepoGitHubID           int64
	InstallationID         int64
	RepoFullName           string
	Codeowners             *CodeownersSourceRecord
	ForceCodeownersRefresh bool
}

FetchMetadata is the cache metadata needed for a conditional GitHub fetch.

type FileOwnerRecord added in v0.3.0

type FileOwnerRecord struct {
	Path            string
	OwnerToken      string
	OwnerType       string
	OwnerName       string
	ResolutionState string
	OwnerGitHubID   int64
	OwnerNodeID     string
	OwnerLogin      string
	SourcePattern   string
	SourceLine      int
}

FileOwnerRecord is one CODEOWNERS token selected by the last matching rule for a changed path. OwnerType is syntactic; ResolutionState distinguishes a stable identity from an unresolved or explicitly deleted identity.

type Observation

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

Observation is an optimistic snapshot of one entity's committed write version. It never owns a transaction, connection, or advisory lock, so it is safe to retain across remote I/O. The writer verifies the version under the short transaction-scoped entity lock and advances it only on commit.

func (*Observation) Close

func (o *Observation) Close() error

Close is retained for API compatibility. Observations own no resources.

func (*Observation) CloseContext

func (o *Observation) CloseContext(ctx context.Context) error

CloseContext is retained for API compatibility. Observations own no resources, including after cancellation.

func (*Observation) Key

func (o *Observation) Key() string

Key returns the entity key protected by the observation.

type PullRequestApply

type PullRequestApply struct {
	Context     context.Context //nolint:containedctx // each batched item retains its independent cancellation and values
	Record      PullRequestRecord
	Observation *Observation
	Hook        PullRequestHook
}

PullRequestApply describes one independently handled batch write.

type PullRequestApplyOutcome

type PullRequestApplyOutcome struct {
	Result ApplyPullRequestResult
	Err    error
}

PullRequestApplyOutcome captures one batch write's result and error.

type PullRequestChangeFetchMetadata added in v0.4.0

type PullRequestChangeFetchMetadata struct {
	ETag          string
	PreviousPaths map[string]string
}

PullRequestChangeFetchMetadata is the persisted conditional-request state for the REST changed-files supplement.

type PullRequestChangeSnapshotRecord added in v0.3.0

type PullRequestChangeSnapshotRecord struct {
	BaseSHA          string
	HeadSHA          string
	ETag             string
	FilesTotalCount  int
	FilesTruncated   bool
	CodeownersRef    string
	CodeownersSHA    string
	CodeownersPath   string
	CodeownersState  string
	CodeownersSource string
	CodeownersHash   string
	CodeownersETag   string
	Files            []ChangedFileRecord
	Owners           []FileOwnerRecord
}

PullRequestChangeSnapshotRecord fences changed files and resolved ownership by the exact base/head pair returned in one PR observation.

type PullRequestCommentRecord added in v0.3.0

type PullRequestCommentRecord struct {
	GitHubID        int64
	NodeID          string
	AuthorKind      string
	AuthorNodeID    string
	AuthorLogin     string
	CreatedAt       time.Time
	GitHubUpdatedAt time.Time
}

PullRequestCommentRecord is one identity-keyed ordinary issue comment on a pull request. Bodies are deliberately absent from the public fact record.

type PullRequestHook

type PullRequestHook func(ApplyPullRequestResult) TransactionHook

PullRequestHook derives transaction work from a pull-request write result.

type PullRequestRecord

type PullRequestRecord struct {
	Repository          RepositoryRecord
	GitHubID            int64
	NodeID              string
	Number              int
	Title               string
	State               string
	Draft               bool
	AuthorLogin         string
	HeadRef             string
	HeadSHA             string
	BaseRef             string
	BaseSHA             string
	ReviewDecision      string
	MergeableState      string
	StackNumber         *int
	StackPosition       *int
	StackSummary        *StackSummaryRecord
	MembershipKnown     bool
	GitHubUpdatedAt     time.Time
	ReviewThreads       []ReviewThreadRecord
	ThreadsKnown        bool
	ReviewRequests      []ReviewRequestRecord
	ReviewRequestsKnown bool
	Reviews             []PullRequestReviewRecord
	ReviewsKnown        bool
	Comments            []PullRequestCommentRecord
	CommentsKnown       bool
	ChangeSnapshot      *PullRequestChangeSnapshotRecord
	ChangeInputsKnown   bool
	ETag                string
	SyncedAt            time.Time
	Source              SyncSource
}

PullRequestRecord is the authoritative pull-request state accepted by the cache.

type PullRequestReviewRecord added in v0.3.0

type PullRequestReviewRecord struct {
	GitHubID        int64
	NodeID          string
	AuthorKind      string
	AuthorNodeID    string
	AuthorLogin     string
	State           string
	SubmittedAt     *time.Time
	CommitOID       string
	GitHubUpdatedAt time.Time
}

PullRequestReviewRecord is one identity-keyed GitHub pull-request review. Lifecycle state plus SubmittedAt and GitHubUpdatedAt form the per-row monotonic basis; a dismissed review remains present with State set to "dismissed".

type RefreshGenerationFence added in v0.5.0

type RefreshGenerationFence struct {
	Kind       string
	RefreshKey string
	Generation int64
}

RefreshGenerationFence is the generation a direct River worker observed immediately before it began remote I/O.

type RepoRuleRecord

type RepoRuleRecord struct {
	Key             string          `json:"rule_key"`
	Rule            json.RawMessage `json:"rule"`
	GitHubUpdatedAt *time.Time      `json:"gh_updated_at"`
	HeadSHA         string          `json:"head_sha"`
}

RepoRuleRecord is one normalized repository rule.

type RepoRulesRecord

type RepoRulesRecord struct {
	Repository RepositoryRecord
	Rules      []RepoRuleRecord
	ETag       string
	SyncedAt   time.Time
	Source     SyncSource
}

RepoRulesRecord is the authoritative repository-rules snapshot.

type RepositoryRecord

type RepositoryRecord struct {
	InstallationID  int64
	OrgID           int64
	GitHubID        int64
	NodeID          string
	Owner           string
	Name            string
	FullName        string
	DefaultBranch   string
	DefaultHeadSHA  string
	Archived        bool
	GitHubUpdatedAt time.Time
	ETag            string
	LastCheckedAt   time.Time
}

RepositoryRecord is the validated repository state accepted by the cache.

type ReviewCommentRecord

type ReviewCommentRecord struct {
	ID          string    `json:"id"`
	Body        string    `json:"body"`
	UpdatedAt   time.Time `json:"updated_at"`
	AuthorLogin string    `json:"author_login"`
}

ReviewCommentRecord is one review comment embedded in a review thread.

type ReviewRequestKind added in v0.3.0

type ReviewRequestKind string

ReviewRequestKind distinguishes GitHub user and team review requests.

const (
	ReviewRequestUser ReviewRequestKind = "user"
	ReviewRequestTeam ReviewRequestKind = "team"
)

type ReviewRequestRecord added in v0.3.0

type ReviewRequestRecord struct {
	Kind        ReviewRequestKind
	GitHubID    int64
	NodeID      string
	Login       string
	RequestedAt *time.Time
}

ReviewRequestRecord is one member of GitHub's authoritative current pull-request reviewRequests set. RequestedAt is nil when GitHub does not expose an authoritative request timestamp.

type ReviewThreadRecord

type ReviewThreadRecord struct {
	ID              string
	IsResolved      bool
	IsOutdated      bool
	Path            string
	Line            *int
	Comments        []ReviewCommentRecord
	GitHubUpdatedAt time.Time
}

ReviewThreadRecord is one authoritative pull-request review thread.

type StackEntry

type StackEntry struct {
	Number    int        `json:"number"`
	State     string     `json:"state"`
	Draft     bool       `json:"draft"`
	MergedAt  *time.Time `json:"merged_at,omitempty"`
	UpdatedAt time.Time  `json:"updated_at"`
	HeadRef   string     `json:"head_ref"`
	HeadSHA   string     `json:"head_sha"`
}

StackEntry is one ordered pull request in a stack snapshot.

type StackHook

type StackHook func(ApplyStackResult) TransactionHook

StackHook derives transaction work from a stack write result.

type StackRecord

type StackRecord struct {
	Repository      RepositoryRecord
	GitHubID        int64
	NodeID          string
	Number          int
	BaseRef         string
	BaseSHA         string
	Open            bool
	Entries         []StackEntry
	GitHubUpdatedAt time.Time
	ETag            string
	SyncedAt        time.Time
	Source          SyncSource
}

StackRecord is the authoritative stack state accepted by the cache. BaseSHA is empty when GitHub reports the base ref without a resolvable commit. This is authoritative upstream truth, including for open stacks.

type StackSummaryRecord

type StackSummaryRecord struct {
	GitHubID int64
	Number   int
	Size     int
	Position int
	BaseRef  string
	BaseSHA  string
}

StackSummaryRecord is the stack tuple embedded in an authoritative pull-request response. Position and Size are independently reported positive integers: Position greater than Size records historical membership after the current stack shrank. This is accepted for open and closed PRs because PR state cannot prove that the embedded summary still describes current ordered membership. BaseSHA is empty when GitHub reports the stack base ref but can no longer resolve its commit, including historical stacks whose base branch was deleted.

type SyncSource

type SyncSource string

SyncSource identifies the workflow that supplied an authoritative cache observation.

const (
	// SyncSourceWebhook identifies observations triggered by GitHub webhooks.
	SyncSourceWebhook SyncSource = "webhook"
	// SyncSourceReconcile identifies observations from reconciliation work.
	SyncSourceReconcile SyncSource = "reconcile"
	// SyncSourceBackfill identifies observations from historical backfills.
	SyncSourceBackfill SyncSource = "backfill"
	// SyncSourceManual identifies operator-requested observations.
	SyncSourceManual SyncSource = "manual"
	// SyncSourceInteractive identifies user-blocking interactive refreshes.
	SyncSourceInteractive SyncSource = "interactive"
)

func (SyncSource) Valid

func (s SyncSource) Valid() bool

Valid reports whether s is a supported cache observation source.

type TransactionHook

type TransactionHook func(context.Context, pgx.Tx) error

TransactionHook runs after the accepted cache mutation, dirty marking, and event insert but before commit. Fetch workers use it for durable generation bumps and River follow-ups (C-C3). C-C6 forbids network I/O in this callback.

Directories

Path Synopsis
Package rdsiam generates short-lived Amazon RDS IAM database auth tokens.
Package rdsiam generates short-lived Amazon RDS IAM database auth tokens.

Jump to

Keyboard shortcuts

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