patrick

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: BSD-3-Clause Imports: 8 Imported by: 2 modules, 3 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PushEventJobID added in v1.2.0

func PushEventJobID(meta *Meta) string

PushEventJobID returns a stable job id for a GitHub push webhook payload. It uses repository id, ref, after, and repository.pushed_at. When pushed_at is missing (zero) or ref/after are empty, it falls back to a random id for legacy payloads and backward compatibility.

Types

type Client

type Client interface {
	Dequeue() (*Job, error)
	IsAssigned(jid string) (bool, error)
	Refresh(jid string) (bool, error)
	Done(jid string, cid_log map[string]string, assetCid map[string]string) error
	// Failed reports a failed run. A non-empty reason means another run would fail the same way, so the job is not retried.
	Failed(jid string, cid_log map[string]string, assetCid map[string]string, reason string) error
	List() ([]string, error)
	Get(jid string) (*Job, error)
	Timeout(jid string) error
	Cancel(jid string, cid_log map[string]string) (interface{}, error)
	DatabaseStats() (kvdb.Stats, error)
	Peers(...peerCore.ID) Client
	Close()
}

type DelayConfig

type DelayConfig struct {
	Time int `cbor:"1,keyasint"` // Inject delay in second
}

type HeadCommit

type HeadCommit struct {
	ID string `json:"id" cbor:"33,keyasint"`
}

type Job

type Job struct {
	Id        string    `cbor:"1,keyasint"`
	Timestamp int64     `cbor:"2,keyasint"`
	Status    JobStatus `cbor:"3,keyasint"`
	LogLock   sync.Mutex
	Logs      map[string]string `cbor:"11,keyasint"` // Cid of logs
	Meta      Meta              `cbor:"15,keyasint"`
	CidLock   sync.Mutex
	AssetCid  map[string]string `cbor:"20,keyasint"` // Build Cid
	Attempt   int               `cbor:"30,keyasint"`
	Reason    string            `cbor:"31,keyasint"` // why the job failed without a retry
	Delay     *DelayConfig      `cbor:"99,keyasint"` // Inject a delay to run a job
}

func (*Job) SetCid

func (j *Job) SetCid(key, value string)

func (*Job) SetLog

func (j *Job) SetLog(key, value string)

func (*Job) Unmarshal added in v1.1.10

func (j *Job) Unmarshal(data []byte) error

Unmarshal decodes CBOR data into the job and normalizes the repository (e.g. promotes SSHURL to URI).

type JobStatus

type JobStatus int

TODO: Shouldn't JobStatus just be typed string?

const (
	JobStatusFailed JobStatus = iota - 1
	JobStatusOpen
	JobStatusLocked
	JobStatusSuccess
	JobStatusCancelled
)

func (JobStatus) String

func (s JobStatus) String() string

func (JobStatus) Unicode

func (s JobStatus) Unicode() string

type Meta

type Meta struct {
	Ref        string     `json:"ref" cbor:"4,keyasint"`
	Before     string     `json:"before" cbor:"8,keyasint"`
	After      string     `json:"after" cbor:"16,keyasint"`
	HeadCommit HeadCommit `json:"head_commit" cbor:"32,keyasint"`
	Repository Repository `cbor:"64,keyasint"`
}

TODO: optimize cbor storage

type Repository

type Repository struct {
	ID       int    `json:"id" cbor:"65,keyasint"`
	Provider string `json:"provider" cbor:"66,keyasint"`
	SSHURL   string `json:"ssh_url" cbor:"67,keyasint"` // deprecated: use URI; kept for backward compat
	URI      string `json:"uri" cbor:"69,keyasint"`
	Branch   string `json:"default_branch" cbor:"68,keyasint"`
	PushedAt int64  `json:"pushed_at" cbor:"70,keyasint"`
}

func (*Repository) UnmarshalJSON added in v1.1.10

func (r *Repository) UnmarshalJSON(data []byte) error

UnmarshalJSON decodes JSON and runs normalize so URI is set from SSHURL when empty.

type Service

type Service interface {
	services.DBService
}

Jump to

Keyboard shortcuts

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