fetchprotocol

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package fetchprotocol is the internal contract between diffx-server and diffx-fetcher. The server owns GitHub credentials and identity; the fetcher leases one pull request at a time, mirrors it and returns an owner-free snapshot. It never claims an account or pull request metadata.

Index

Constants

View Source
const (
	LeasePath  = "/internal/v1/fetch-jobs/lease"
	ResultPath = "/internal/v1/fetch-jobs/result"
)
View Source
const MaxResultBytes = ingestion.MaxRequestBytes + 1<<20

MaxResultBytes bounds a result: one snapshot plus envelope.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is the fetcher's view of the server's internal listener.

func NewClient

func NewClient(baseURL, secret string) (*Client, error)

func (*Client) Complete

func (c *Client) Complete(ctx context.Context, job Job, request ingestion.Request) error

func (*Client) Fail

func (c *Client) Fail(ctx context.Context, job Job, detail string) error

func (*Client) Lease

func (c *Client) Lease(ctx context.Context) (*Job, error)

Lease returns nil when no pull request needs fetching.

type Job

type Job struct {
	ID             string     `json:"id"`
	LeaseToken     string     `json:"leaseToken"`
	LeaseExpiresAt int64      `json:"leaseExpiresAt"`
	Repository     Repository `json:"repository"`
	Number         int        `json:"number"`
	HeadSHA        string     `json:"headSha"`
	BaseRef        string     `json:"baseRef"`
	BaseSHA        string     `json:"baseSha"`
	Token          string     `json:"token"`
	TokenExpiresAt int64      `json:"tokenExpiresAt"`
}

Job leases one pull request head. Token is a short-lived installation token limited to Repository with contents:read; it is valid only for fetching.

type Repository

type Repository struct {
	ID       int64  `json:"id"`
	FullName string `json:"fullName"`
	CloneURL string `json:"cloneUrl"`
}

type Result

type Result struct {
	ID         string             `json:"id"`
	LeaseToken string             `json:"leaseToken"`
	Request    *ingestion.Request `json:"request,omitempty"`
	Error      string             `json:"error,omitempty"`
}

Result completes a lease with a snapshot, or fails it with a detail for retry.

type StatusError

type StatusError struct {
	Status int
	Detail string
}

StatusError reports a non-success response; 409 means the lease was lost.

func (*StatusError) Error

func (err *StatusError) Error() string

Jump to

Keyboard shortcuts

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