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

inventory

package
v0.2.48 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const MaxWebhookBytes = 1 << 20

Variables

View Source
var ErrBusy = errors.New("inventory queue is full")
View Source
var ErrIncomplete = errors.New("provider inventory is incomplete")
View Source
var ErrStale = errors.New("inventory observation or lease is stale")
View Source
var ErrWebhookUnconfigured = errors.New("webhook is not configured")

Functions

func RequestRefreshTx

func RequestRefreshTx(ctx context.Context, tx pgx.Tx, org, repo string) error

func RequireFreshTx

func RequireFreshTx(ctx context.Context, tx pgx.Tx, org, repo string) error

Types

type ChangePage

type ChangePage struct {
	domain.Page[forge.Change]
	SnapshotState     string     `json:"snapshot_state"`
	ObservedAt        *time.Time `json:"observed_at,omitempty"`
	ConnectionVersion int64      `json:"connection_version"`
}

type Decoder

type Decoder func(string, string, http.Header, []byte) (forge.Event, error)

type ImportInput

type ImportInput struct {
	All       bool     `json:"all"`
	NativeIDs []string `json:"native_ids"`
	TeamIDs   []string `json:"team_ids"`
}

type IssuedWebhook

type IssuedWebhook struct {
	Webhook
	Secret string `json:"secret"`
}

func (IssuedWebhook) GoString

func (w IssuedWebhook) GoString() string

func (IssuedWebhook) LogValue

func (w IssuedWebhook) LogValue() slog.Value

func (IssuedWebhook) String

func (w IssuedWebhook) String() string

type Job

type Job struct {
	ID                string     `json:"id"`
	OrgID             string     `json:"org_id"`
	ConnectionID      string     `json:"connection_id"`
	ConnectionVersion int64      `json:"connection_version"`
	Namespace         string     `json:"namespace"`
	Kind              string     `json:"kind"`
	RepositoryID      string     `json:"repository_id,omitempty"`
	ParentID          string     `json:"parent_id,omitempty"`
	RequestedBy       string     `json:"-"`
	Input             []byte     `json:"-"`
	State             string     `json:"state"`
	Reason            string     `json:"reason,omitempty"`
	Cursor            string     `json:"-"`
	Phase             string     `json:"-"`
	Pages             int        `json:"pages"`
	Processed         int        `json:"processed"`
	Failures          int        `json:"failures"`
	Fence             int64      `json:"-"`
	LeaseOwner        string     `json:"-"`
	LeaseUntil        *time.Time `json:"-"`
	AvailableAt       time.Time  `json:"available_at"`
	Version           int64      `json:"version"`
	CreatedAt         time.Time  `json:"created_at"`
	UpdatedAt         time.Time  `json:"updated_at"`
}

type Repository

type Repository struct {
	domain.Repository
	SyncState         string     `json:"sync_state"`
	SyncReason        string     `json:"sync_reason,omitempty"`
	ConnectionVersion int64      `json:"connection_version"`
	ChangesObservedAt *time.Time `json:"changes_observed_at,omitempty"`
	PauseVersion      int64      `json:"pause_version"`
}

type RepositoryFilter

type RepositoryFilter struct {
	Query    string
	Provider string
	TeamID   string
	Status   string
}

type Service

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

func New

func New(db *store.Store, identity *auth.Service, vault *secrets.Vault, reader Reader, decode Decoder) *Service

func (*Service) AdoptWebhookTx

func (s *Service) AdoptWebhookTx(ctx context.Context, tx pgx.Tx, a domain.Actor, org, connectionID, id, secret, request string) (string, error)

func (*Service) Cancel

func (s *Service) Cancel(ctx context.Context, session auth.Session, org, id string, expected int64, request string) (Job, error)

func (*Service) Candidates

func (s *Service) Candidates(ctx context.Context, session auth.Session, org, id string, limit int, cursor string) (domain.Page[forge.Repository], error)

func (*Service) Changes

func (s *Service) Changes(ctx context.Context, session auth.Session, org, repo string, limit int, cursor string) (ChangePage, error)

func (*Service) Claim

func (s *Service) Claim(ctx context.Context, org, worker string) (*Job, error)

func (*Service) ConfigureWebhook

func (s *Service) ConfigureWebhook(ctx context.Context, session auth.Session, org, connectionID string, expected int64, request string) (IssuedWebhook, error)

func (*Service) HandleHostedWebhook

func (s *Service) HandleHostedWebhook(ctx context.Context, org, connectionID, endpointID string, appID int64, secret []byte, headers http.Header, body []byte) error

func (*Service) HandleWebhook

func (s *Service) HandleWebhook(ctx context.Context, org, id string, headers http.Header, body []byte) error

func (*Service) Job

func (s *Service) Job(ctx context.Context, session auth.Session, org, id string) (Job, error)

func (*Service) Jobs

func (s *Service) Jobs(ctx context.Context, session auth.Session, org string, limit int, cursor string) (domain.Page[Job], error)

func (*Service) Maintain

func (s *Service) Maintain(ctx context.Context, org string) error

func (*Service) Repositories

func (s *Service) Repositories(ctx context.Context, session auth.Session, org string, limit int, cursor string) (domain.Page[Repository], error)

func (*Service) RepositoriesFiltered

func (s *Service) RepositoriesFiltered(ctx context.Context, session auth.Session, org string, limit int, cursor string, filter RepositoryFilter) (domain.Page[Repository], error)

func (*Service) Repository

func (s *Service) Repository(ctx context.Context, session auth.Session, org, id string) (Repository, error)

func (*Service) RevokeWebhook

func (s *Service) RevokeWebhook(ctx context.Context, session auth.Session, org, connectionID string, expected int64, request string) error

func (*Service) Run

func (s *Service) Run(ctx context.Context, worker string) error

func (*Service) RunOnce

func (s *Service) RunOnce(ctx context.Context, worker string) (bool, error)

func (*Service) StartImport

func (s *Service) StartImport(ctx context.Context, session auth.Session, org, syncID string, in ImportInput, expected int64, request string) (Job, error)

func (*Service) StartSync

func (s *Service) StartSync(ctx context.Context, session auth.Session, org string, in SyncInput, request string) (Job, error)

func (*Service) Step

func (s *Service) Step(ctx context.Context, lease Job) error

func (*Service) Webhook

func (s *Service) Webhook(ctx context.Context, session auth.Session, org, connectionID string) (Webhook, error)

type SyncInput

type SyncInput struct {
	ConnectionID string `json:"connection_id"`
	Namespace    string `json:"namespace"`
}

type Webhook

type Webhook struct {
	ID           string `json:"id"`
	ConnectionID string `json:"connection_id"`
	Version      int64  `json:"version"`
	Path         string `json:"path"`
	Revoked      bool   `json:"revoked"`
}

Jump to

Keyboard shortcuts

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