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

contextservice

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package contextservice manages durable review targets independently of transports.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActivityTime added in v0.2.1

func ActivityTime(item Context) int64

ActivityTime returns advisory code activity, falling back to captured collection time for observations from producers without activity metadata.

func CompareActivity added in v0.2.1

func CompareActivity(left, right Context) int

CompareActivity orders most active first, with stable stream and context ties. It never changes stream freshness or catalog pagination.

Types

type Context

type Context struct {
	Stale            bool                            `json:"stale"`
	Sessions         []reviewdata.SessionAssociation `json:"sessions,omitempty"`
	Observation      *ingestion.Metadata             `json:"observation,omitempty"`
	ID               string                          `json:"id"`
	Kind             string                          `json:"kind"`
	Source           string                          `json:"source"`
	Name             string                          `json:"name"`
	Root             *string                         `json:"root"`
	LocationID       *string                         `json:"locationId"`
	RepositoryID     *string                         `json:"repositoryId"`
	CreatedAt        int64                           `json:"createdAt"`
	LastSubmittedAt  int64                           `json:"lastSubmittedAt"`
	LastChangedAt    int64                           `json:"lastChangedAt"`
	ScopeSummaries   []review.ScopeSummary           `json:"scopeSummaries,omitempty"`
	Commits          *review.CommitRange             `json:"commits,omitempty"`
	ChangedFileCount *int                            `json:"changedFileCount"`
	ExpiresAt        *int64                          `json:"expiresAt"`
	SubmittedFrom    *string                         `json:"submittedFrom"`
	Capabilities     reviewsession.Capabilities      `json:"capabilities"`
	Availability     string                          `json:"availability"`
	Branch           *string                         `json:"branch"`
	WorktreeName     *string                         `json:"worktreeName"`
	StreamID         *string                         `json:"streamId"`
	LatestContextID  *string                         `json:"latestContextId"`
}

type Option added in v0.2.2

type Option func(*Service)

Option adjusts a composition's service.

func ExternalEvents added in v0.2.2

func ExternalEvents() Option

ExternalEvents stops Ingest and Delete from notifying subscribers in-process. The composition instead relays changes its store announces, from every process, through Notify.

type Page

type Page struct {
	Contexts   []Context `json:"contexts"`
	NextCursor *string   `json:"nextCursor"`
}

type Publication added in v0.2.1

type Publication struct {
	Context  Context               `json:"context"`
	Snapshot review.RepositoryDiff `json:"snapshot"`
}

Publication is an ingested context with its snapshot.

type Scope added in v0.2.1

type Scope struct {
	SourceID     string
	Checkouts    []ingestion.Checkout
	SubmissionID string
	// contains filtered or unexported fields
}

Scope limits a composition to its selected checkouts or one capture. The zero value is unscoped. Contexts outside the scope behave as not found.

func ScopeFor added in v0.2.1

func ScopeFor(inputs ...ingestion.Request) Scope

ScopeFor selects the requests' checkouts, so later collections and branches of those checkouts stay visible. Captures without checkout identity select their own submission. An empty selection matches nothing until widened.

func (Scope) IsZero added in v0.2.1

func (scope Scope) IsZero() bool

type Service

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

func New

func New(store Store, user reviewdata.User) *Service

func NewScoped added in v0.2.1

func NewScoped(ctx context.Context, store Store, user reviewdata.User, scope Scope, options ...Option) *Service

func NewWithContext

func NewWithContext(ctx context.Context, store Store, user reviewdata.User, options ...Option) *Service

func (*Service) Close

func (service *Service) Close() error

Close cancels background work and ends every subscription.

func (*Service) Count

func (service *Service) Count(ctx context.Context) (int, error)

func (*Service) Delete

func (service *Service) Delete(ctx context.Context, id string) error

func (*Service) Get

func (service *Service) Get(ctx context.Context, id string) (Context, error)

func (*Service) Ingest

func (service *Service) Ingest(ctx context.Context, input ingestion.Request) (Publication, error)

func (*Service) List

func (service *Service) List(ctx context.Context, limit int, cursor string) (Page, error)

func (*Service) ListFiltered

func (service *Service) ListFiltered(ctx context.Context, limit int, cursor string, filter ingestion.Filter) (Page, error)

func (*Service) Notify added in v0.2.2

func (service *Service) Notify(contextID string)

Notify tells the owner's subscribers that contextID changed elsewhere. An empty contextID means changes may have been missed; subscribers reload.

func (*Service) Resolve

func (service *Service) Resolve(ctx context.Context, id string) (reviewsession.Session, error)

func (*Service) Select added in v0.2.1

func (service *Service) Select(input ingestion.Request)

Select widens a scoped composition to the request's checkout before it is ingested, so checkouts discovered after startup become visible. Unscoped services are unchanged; only local entry points select.

func (*Service) Subscribe

func (service *Service) Subscribe() (<-chan string, func())

Subscribe delivers changed context IDs until unsubscribed; the channel closes when the service closes.

func (*Service) UserID

func (service *Service) UserID() string

type Store

Store preserves atomic ingestion; callers cannot partially publish an observation.

Jump to

Keyboard shortcuts

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