Documentation ¶
Overview ¶
Package poll defines an interface for periodically polling repositories for status updates.
Index ¶
- Variables
- func CleanRepoURL(url string) string
- func FixRepoURL(s string) string
- func RepoExists(ctx context.Context, url string) bool
- func ShouldCheck(stat *Status, min time.Duration) bool
- type CheckOptions
- type CheckResult
- type DB
- func (db *DB) Check(ctx context.Context, url string, opts *CheckOptions) (*CheckResult, error)
- func (db *DB) Remove(ctx context.Context, url, tag string) error
- func (db *DB) Scan(ctx context.Context, f func(string) error) error
- func (db *DB) Status(ctx context.Context, url string) (*Status, error)
- func (db *DB) Tags(ctx context.Context, base string) ([]*Status, error)
- type Status
- func (*Status) Descriptor() ([]byte, []int)deprecated
- func (x *Status) GetDigest() []byte
- func (x *Status) GetErrorCount() int32
- func (x *Status) GetLastCheck() *timestamppb.Timestamp
- func (x *Status) GetPrefix() string
- func (x *Status) GetRefName() string
- func (x *Status) GetRepository() string
- func (x *Status) GetTag() string
- func (x *Status) GetUpdates() []*Status_Update
- func (s *Status) MarshalJSON() ([]byte, error)
- func (*Status) ProtoMessage()
- func (x *Status) ProtoReflect() protoreflect.Message
- func (x *Status) Reset()
- func (x *Status) String() string
- func (s *Status) UnmarshalJSON(data []byte) error
- type Status_Update
- func (*Status_Update) Descriptor() ([]byte, []int)deprecated
- func (x *Status_Update) GetDigest() []byte
- func (x *Status_Update) GetWhen() *timestamppb.Timestamp
- func (*Status_Update) ProtoMessage()
- func (x *Status_Update) ProtoReflect() protoreflect.Message
- func (x *Status_Update) Reset()
- func (x *Status_Update) String() string
Constants ¶
This section is empty.
Variables ¶
var File_poll_proto protoreflect.FileDescriptor
Functions ¶
func CleanRepoURL ¶
CleanRepoURL removes protocol and format tags from a repository URL.
func FixRepoURL ¶
FixRepoURL ensures s has a valid protocol prefix for Git.
func RepoExists ¶
RepoExists reports whether there is a repository at the specified URL.
A true result means the repository is definitely present, though it may require authentication. A false result may be incorrect, for example if the caller's network filters outbound git requests.
func ShouldCheck ¶
ShouldCheck reports whether the given status message should be checked, based on its history of previous updates.
No update will be suggested within min of the most recent check. Otherwise, schedule an update once the current time is at least the average gap between updates. // As a special case if min == 0 the answer is always true.
Types ¶
type CheckOptions ¶
type CheckOptions struct { // If set, append this label to the repository key. Label string // If set, use this reference name to resolve a target digest. Reference string // If set, attribute this prefix to the packages found in the repository. Prefix string }
CheckOptions control optional features of repostory checks. A nil *CheckOptions is ready for use with default values.
type CheckResult ¶
type CheckResult struct { URL string // repository fetch URL Name string // remote head name Digest string // current digest value Errors int // errors since last successful update Prefix string // package prefix, if defined // contains filtered or unexported fields }
CheckResult records the update status of a repository.
func (*CheckResult) Clone ¶
func (c *CheckResult) Clone(ctx context.Context, path string) error
Clone clones the repository state denoted by c in specified directory path. The directory is created if it does not exist.
func (*CheckResult) NeedsUpdate ¶
func (c *CheckResult) NeedsUpdate() bool
NeedsUpdate reports whether c requires an update.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
A DB represents a cache of update statuses for repositories.
func (*DB) Check ¶
func (db *DB) Check(ctx context.Context, url string, opts *CheckOptions) (*CheckResult, error)
Check reports whether the specified repository requires an update. If the repository does not exist, it is added and reported as needing update.
If there is an error in updating the status, the check result will be non-nil and the caller can check the Errors field to see how often an update has been attempted without success. Repositories that fail too often may be pruned from the database.
If url has the form <base>@@<tag>, the specified tag is applied.
func (*DB) Scan ¶
Scan scans all the URLs in the database. If f reports an error, that error is propagated to the caller.
type Status ¶
type Status struct { Repository string `protobuf:"bytes,1,opt,name=repository,proto3" json:"repository,omitempty"` // repository fetch URL RefName string `protobuf:"bytes,2,opt,name=ref_name,json=refName,proto3" json:"ref_name,omitempty"` // reference name to fetch (default is HEAD) Digest []byte `protobuf:"bytes,3,opt,name=digest,proto3" json:"digest,omitempty"` // latest known digest ErrorCount int32 `protobuf:"varint,6,opt,name=error_count,json=errorCount,proto3" json:"error_count,omitempty"` // fetch errors since last successful check Prefix string `protobuf:"bytes,7,opt,name=prefix,proto3" json:"prefix,omitempty"` // package prefix to attribute to this repository Tag string `protobuf:"bytes,8,opt,name=tag,proto3" json:"tag,omitempty"` // storage tag for this status // When the last check of this repository was made. If unset, the repository // has never been checked. LastCheck *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=last_check,json=lastCheck,proto3" json:"last_check,omitempty"` // The history of updates, oldest to newest. Updates []*Status_Update `protobuf:"bytes,5,rep,name=updates,proto3" json:"updates,omitempty"` // contains filtered or unexported fields }
A Status records the status of a single repository.
func (*Status) Descriptor
deprecated
func (*Status) GetErrorCount ¶
func (*Status) GetLastCheck ¶
func (x *Status) GetLastCheck() *timestamppb.Timestamp
func (*Status) GetRefName ¶
func (*Status) GetRepository ¶
func (*Status) GetUpdates ¶
func (x *Status) GetUpdates() []*Status_Update
func (*Status) MarshalJSON ¶
MarshalJSON implements json.Marshaler for a Status by delegating to protojson.
func (*Status) ProtoMessage ¶
func (*Status) ProtoMessage()
func (*Status) ProtoReflect ¶
func (x *Status) ProtoReflect() protoreflect.Message
func (*Status) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler for a Status by delegating to jsonpb.
type Status_Update ¶
type Status_Update struct { // When this update was discovered. When *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=when,proto3" json:"when,omitempty"` // The digest at the time of this update. Digest []byte `protobuf:"bytes,2,opt,name=digest,proto3" json:"digest,omitempty"` // contains filtered or unexported fields }
func (*Status_Update) Descriptor
deprecated
func (*Status_Update) Descriptor() ([]byte, []int)
Deprecated: Use Status_Update.ProtoReflect.Descriptor instead.
func (*Status_Update) GetDigest ¶
func (x *Status_Update) GetDigest() []byte
func (*Status_Update) GetWhen ¶
func (x *Status_Update) GetWhen() *timestamppb.Timestamp
func (*Status_Update) ProtoMessage ¶
func (*Status_Update) ProtoMessage()
func (*Status_Update) ProtoReflect ¶
func (x *Status_Update) ProtoReflect() protoreflect.Message
func (*Status_Update) Reset ¶
func (x *Status_Update) Reset()
func (*Status_Update) String ¶
func (x *Status_Update) String() string