Documentation
¶
Overview ¶
Package format is the contract between the item service and the package formats (decision 0032): the hooks every format implements, the optional interfaces a format adds for what it needs, the environment they run in, and the errors with which a format refuses a request or takes a write without making it. The item service calls the hooks on every write, whichever API carried it, so a format's package index (decision 0018) and derived items stay consistent with the item tree, which remains the source of truth.
Role ¶
artifacts module, core layer: the format contract. Each package type's format is a package of its own, named after its ecosystem (docs/implementation/repo-layout.md), and the format registry, artifacts/ecosystem, picks one for a package type. Formats never import the HTTP layer, so they speak to clients only through RejectionError and AcceptedError (decision 0032). As artifacts core, the contract never imports the module's adapters or an ecosystem http package (decision 0044, dependency rule 8).
Inputs ¶
- Driving: the item service (internal/artifacts/core/item) calls the hooks and the optional interfaces on every deploy, checksum upload, folder create, copy, move, delete, restore, property change and download, with the Env it builds for the operation. The build and registry services pass their Registry on to it, remote retrieval classifies items with ClassOf, and the reindex API and configuration apply queue the reindex kinds with a WorkRequest.
- Driven: the format packages implement Handler and the optional interfaces they need: Inspector, Admitter, TransferSourceGuard, WriteGuard, FolderAdmitter, AnnotationAdmitter, Resolver, Annotator, Reindexer, PathReindexer, Worker, Classifier, SidecarOwner and SidecarKeeper. The persistent work queue runs a Worker's items.
- Env: Store, the part of the metadata store a format reads and writes (repositories, items, the package index and the remote cache, from artifacts/core/port, with platform/tx's Runner for transactions), its lease table and work queue (Leases and WorkQueue, platform/work), the signing key pairs (Keys, access/api), the read half of the blob store (Blobs), the clock, the repository layouts (artifacts/core/layout), and the item service's Derive, Underive, Remove, Move and Enqueue, with the inspection of the file being written and the reindex options (ReindexSource, CheckReindex and SkipProperties).
Outputs ¶
- Store, the store a format reads and writes through Env.Store. The item service's store and each composite store in app satisfy it, so each builder of Env passes the store it holds.
- Registry, the function from a package type to its Handler. The application builds one from the format registry's Settings.For (artifacts/ecosystem) and gives it to the item, build and registry services and the Docker registry; remote retrieval classifies with the item service's. A nil Registry means the generic handler, which indexes nothing. Core services take it as a value because importing the registry would import every ecosystem slice, and the slices import core.
- Hook errors. An error from a hook inside a write's transaction rolls the write back.
- *RejectionError, made by Rejectf: a format's refusal. The HTTP layer answers it with Status and Message in the envelope of the surface the request arrived on; a copy or move reports it and skips the item.
- *AcceptedError: a deploy or checksum upload that Admit takes without storing it. The HTTP layer answers Status with an empty body, and an exploded archive leaves the entry out.
- ErrStorageFault: a failure of the server's own storage while it keeps a file, such as a failed read of a remote file's copy a Validate hook checks, or a failed write of that copy. The remote source boundary passes it on as it is, and the HTTP layer answers it as any server fault, 500 "internal error" (https://github.com/weaveplatform/artifactweave/issues/1269).
- What Admit and Resolve decide: the Write as it should happen, and the path a download reads instead of the one requested.
- The work kinds of the JFrog reindex operations (KindReindex, KindReindexNoProps, KindReindexPath) and their payload, WorkRequest; WorkRef names the work a download waits for.
- Class and ClassOf: remote cache expiry reads them, and replication (P11) and federation (P13) will.
- MinUniqueSnapshots and UniqueSnapshots: how many unique builds a maxUniqueSnapshots cleanup keeps.
Invariants ¶
- The required hooks run inside the transaction that changes the item, so an error rolls the change back. Inspect runs before the write's transaction, so no parsing holds the database's write lock; Work runs outside any transaction, and a Reindexer manages its own.
- Derive and Underive call no hook, so a format's own output never re-enters it.
- The HTTP layer passes a RejectionError's Status and Message to the client, so message texts are part of each format's API and stay byte-identical.
- The package is named format and Rejectf keeps its name: the wrapcheck extra-ignore-sigs entry "format.Rejectf(" in .golangci.yml matches by name, so a rename would fail lint at every return of a rejection.
- Work kinds are code constants, unique across formats, and Work is idempotent, since an item can run again.
References ¶
- Decision 0032: docs/research/decisions/0032-package-format-handlers.md, lines 28 to 49 (the hooks and the hook environment) and 71 to 73 (RejectionError, and formats never import the HTTP layer), with its amendments on source transfer restrictions, writes taken without being made and sidecars a format keeps.
- Decision 0017: docs/research/decisions/0017-sealed-columns-and-master-key.md (Keys returns private keys unsealed).
- Decision 0018: docs/research/decisions/0018-package-index.md.
- Decision 0033: docs/research/decisions/0033-persistent-work-queue.md (Enqueue, Worker and the reindex kinds).
- Decision 0034: docs/research/decisions/0034-npm.md (Move, for the strict-layout conversion; npm ignores maxUniqueSnapshots).
- Decision 0039: docs/research/decisions/0039-helm.md (SidecarKeeper).
- Decision 0041: docs/research/decisions/0041-terraform-backend.md (AnnotationAdmitter).
- Decision 0044: docs/research/decisions/0044-modular-monolith-migration.md, "Artifacts and remote" (the injected registry) and "Dependency rules".
- Research 24: docs/research/24-package-format-handlers.md.
- Target layout: docs/research/architecture-options/5-modular-monolith.md, lines 195 to 197 (core/format), line 996 (the contract) and rule 2 at lines 35 to 36.
- The floor of two unique snapshots: https://jfrog.com/help/r/artifactory-how-does-the-max-unique-snapshots-parameter-work-in-artifactory/how-does-this-feature-work
- Plan: docs/implementation/plan.md#p3-repositories-generic-artifacts-cli-aql-shape, #p6-dockeroci, #p7-npm-go-maven-locals, #p8-pypi-nuget-helm-terraform-locals, #p9-remote-repositories, the P9c row of #build-status (https://github.com/weaveplatform/artifactweave/issues/753) and #p9d-modular-monolith-migration, epic ART (https://github.com/weaveplatform/artifactweave/issues/941).
- https://github.com/weaveplatform/artifactweave/issues/969, https://github.com/weaveplatform/artifactweave/issues/970 and https://github.com/weaveplatform/artifactweave/issues/1087
Status ¶
Implemented P3 to P9c. P3 added Handler with Deployed and Deleting, and P6 added Deleted for Docker's tag index. P7, format framework v2, added Env, the Inspector, Admitter, Resolver, Annotator, Reindexer and Classifier interfaces with the item classes, RejectionError, SidecarOwner and AcceptedError for Maven, Worker and WorkRef, and the snapshot limit. P8 added SidecarKeeper, PathReindexer, the reindex kinds and WorkRequest, FolderAdmitter, AnnotationAdmitter and WriteGuard; P9 the reindex source and caller checks for cached remote packages; P9c TransferSourceGuard, Opkg's reindex that leaves item properties alone (writeProps=0) and Write.By. Moved here in P9d, which added the injected Registry (https://github.com/weaveplatform/artifactweave/issues/970), Env.Keys (https://github.com/weaveplatform/artifactweave/issues/1004), Env's lease and work-queue stores (https://github.com/weaveplatform/artifactweave/issues/1029) and Store, the narrow store Env.Store holds (https://github.com/weaveplatform/artifactweave/issues/1087).
Testing ¶
- TestUnitClassOf: a Classifier's own class, and ClassUnique for a format without one.
- TestUnitRejectf and TestUnitAcceptedError: the error texts.
- TestUnitUniqueSnapshots: no limit, or one of 0 or less, keeps every build, and any other limit keeps at least MinUniqueSnapshots.
- formattest.Run (artifacts/core/formattest) is the contract suite: the format packages' tests run it through the item service on each store backend.
Index ¶
- Constants
- Variables
- func RemoteCopy(c repo.Config, w Write) bool
- func UniqueSnapshots(c repo.Config) int
- type AcceptedError
- type Admitter
- type Annotation
- type AnnotationAdmitter
- type Annotator
- type Blobs
- type Class
- type Classifier
- type Derived
- type Download
- type Env
- type FolderAdmitter
- type Handler
- type Inspector
- type Layouts
- type Op
- type PathReindexer
- type Registry
- type Reindexer
- type RejectionError
- type Resolver
- type SidecarKeeper
- type SidecarOwner
- type Store
- type TransferSourceGuard
- type WorkRef
- type WorkRequest
- type Worker
- type Write
- type WriteGuard
Constants ¶
const ( // KindReindex rebuilds a repository's index, keyed by the repository's // key: requests made before a run begins coalesce into it. KindReindex = "reindex" // KindReindexNoProps keeps Opkg's writeProps=0 request distinct from the // normal reindex queue item, so coalescing cannot change its semantics. KindReindexNoProps = "reindex.noprops" // KindReindexPath rebuilds the part of a repository's index that the // files under a path give, keyed by "<repository key>/<path>", since // repository keys hold no slash. A key of its own per path keeps one // path's request from taking the place of another's, as the payload of // a coalesced request would. KindReindexPath = "reindex.path" )
The kinds of work the persistent work queue runs for the JFrog reindex operations of every format (decision 0033), which 7.x schedules rather than runs before it answers. The item service runs them through the format of the repository's package type, so a Reindexer needs no kind of its own, and a repository that is gone, or whose format keeps no index, owes nothing.
const MinUniqueSnapshots = 2
MinUniqueSnapshots is the fewest unique builds a maxUniqueSnapshots cleanup keeps, whatever the limit: "Artifactory requires that you store a minimum of 2 unique snapshots" (JFrog KB, "How does the max unique snapshots parameter work", 2025-05-15). So a limit of 1 keeps two; whether 7.x refuses a limit of 1 instead is on #216.
Variables ¶
var ErrStorageFault = errors.New("format: storage fault")
ErrStorageFault marks a failure of the server's own storage while it keeps a file: a failed read of its copy while a check reads it, such as a remote file the remote cache checks with a format's Validate hook before it keeps or serves it, or a failed write of that copy or call of the store that publishes it. The fault is the server's storage, not the content or the upstream that sent it, so unlike a RejectionError or a hook's own refusal it answers as any other server fault, 500 "internal error". The store's own error is wrapped with it, for the log.
Functions ¶
func RemoteCopy ¶
RemoteCopy reports whether w keeps, in the cache of c, a remote repository, a file its upstream served. A format that refuses a deploy outside its layout admits such a copy as a plain file, which it indexes nothing from, and holds a copy inside its layout to every check of its content, as a deploy is held. 7.161.26 checks a package's layout only for a local repository's own deploys (PackageStorageInterceptorImpl.beforeCreate skips a cache), and its remote interceptors refuse no path, so a remote keeps whatever its download fetches (RemoteRepoBase.downloadAndSave). The per-type Pro interceptors are not in the OSS tree, so this is inferred for the types whose deploy checks the layout [I] (#1575).
func UniqueSnapshots ¶
UniqueSnapshots is how many unique builds of a snapshot c's cleanup keeps: 0 when c sets no maxUniqueSnapshots, which keeps every build, and otherwise never fewer than MinUniqueSnapshots. Maven's cleanup reads it when it runs, so a limit set back to 0 since the deploy that marked a package deletes nothing (RTDEV-93991, SaaS 7.164.0). npm ignores the limit, as JFrog intends (RTFACT-27078, decision 0034).
Types ¶
type AcceptedError ¶
type AcceptedError struct {
Status int
}
AcceptedError is a format's answer that a write succeeds without being made. Artifactory takes some uploads of what it computes itself, such as Maven's snapshot metadata and the checksums of any metadata, with a success status and stores nothing. Admit returns it, as an error, only for an OpDeploy or an OpChecksum; the HTTP layer answers Status with an empty body, and an exploded archive skips the entry.
func (*AcceptedError) Error ¶
func (a *AcceptedError) Error() string
Error names Status, for logs and wrapped errors. No client reads it: the HTTP layer answers Status with an empty body.
type Admitter ¶
type Admitter interface {
Admit(ctx context.Context, env Env, c repo.Config, w Write) (Write, error)
}
Admitter is a format that checks a file write before it is made: a deploy or a checksum upload inside the write's transaction, and the target of a copy or move while it is planned. It returns the write as it should happen, with the path rewritten or properties added, or refuses it with a *RejectionError. A refused copy or move target is reported and skipped, as other per-item failures are. The generic format, which every format embeds, checks blackedOut, includesPattern and excludesPattern here; a format that overrides Admit calls those checks itself.
type Annotation ¶
type Annotation struct {
// Set holds the keys set or replaced, with their new values.
Set model.Properties
Removed []string
// At is when the change was made. A hook that writes properties in
// turn writes them at At, so they read as part of the same change
// (model.Item.PropertiesModified) rather than a later one.
At time.Time
}
Annotation is a change to an item's properties.
type AnnotationAdmitter ¶
type AnnotationAdmitter interface {
AdmitAnnotation(ctx context.Context, env Env, c repo.Config, it model.Item, a Annotation) error
}
AnnotationAdmitter is a format that checks a change to an item's properties before it is made, such as the Terraform backend's, whose lock properties only its own API changes (decision 0041). The item service asks it of every change Service.Annotate makes: the properties API, AQL properties.update, a folder create's matrix parameters and a promotion's. A deploy's properties reach Admit with the write, and a restore brings back, or a copy or move carries, properties that were set already, so none of those asks.
type Annotator ¶
type Annotator interface {
Annotated(ctx context.Context, env Env, c repo.Config, it model.Item, a Annotation) error
}
Annotator is a format whose index follows item properties, as npm's dist-tags do. The item service calls Annotated inside the transaction of every property write: the properties API, matrix parameters on a deploy or a folder, AQL properties.update, a copy or move carrying properties over, a restore, and a promotion tagging what it promoted.
type Blobs ¶
type Blobs interface {
// Open returns the content stored under a SHA-256 for random access;
// the caller closes it.
Open(ctx context.Context, sha256 string) (io.ReadSeekCloser, blob.Info, error)
// Stat returns a blob's Info without opening it.
Stat(ctx context.Context, sha256 string) (blob.Info, error)
}
Blobs reads stored content: the read half of blob.Store.
type Class ¶
type Class int
Class says what kind of content an item is, for cache expiry (P9), replication (P11) and federation (P13).
const ( // ClassUnique is content only its deployer can supply again, such as a // jar or an image layer. ClassUnique Class = iota + 1 // ClassMetadata is deployed content that describes others and may // change under the same path, such as a Docker tag's manifest. ClassMetadata // ClassDerived is written by the format itself (Env.Derive), so // replication and federation skip it and each side recomputes it. ClassDerived )
type Classifier ¶
Classifier is a format that tells its classes of item apart.
type Derived ¶
type Derived struct {
Repo repo.Config
Cached bool
// Path is repository-relative, without a leading slash.
Path string
Body io.Reader
Properties model.Properties
// By is recorded as the item's creator and modifier.
By string
}
Derived is an item a format writes itself. Its content goes into the blob store and the item into the tree, replacing a file at Path; a folder in the way is an error.
type Download ¶
type Download struct {
// Path is the requested repository-relative path.
Path string
Cached bool
// Matrix holds the request's matrix parameters, which the file served
// must match.
Matrix model.Matrix
// Readable reports whether the caller may read a file of the
// repository; nil reads every file.
Readable func(fullPath string) bool
}
Download is a file a client asks for.
type Env ¶
type Env struct {
// Store is the metadata store, narrowed to what formats use.
Store Store
// Leases is the store's lease table. A format takes a write lock through
// it inside the operation's transaction: Acquire and Release join the
// transaction in ctx, so it must be the same store as Store.
Leases work.LeaseStore
// WorkQueue reads queued work, such as whether an index rebuild is
// pending. A format asks for new work only through Enqueue, which waits
// for the commit.
WorkQueue work.WorkQueue
// Keys reads the key pairs a format signs its metadata with, named by a
// repository's primaryKeyPairRef or keyPair. Their private keys come
// back unsealed, so a format never logs them (decision 0017). Like Store
// it joins the transaction ctx carries. It is nil when the item service
// has none, so a service that runs the derived work of a repository that
// names a key pair must set it.
Keys accessapi.Keys
// Blobs reads stored content, such as the file a hook indexes. Formats
// write content only through Derive and remove it only through
// Underive.
Blobs Blobs
// Now is the clock.
Now func() time.Time
// Layouts resolves repository layouts by name, compiling each at most
// once per operation.
Layouts Layouts
// Derive writes a derived item, such as maven-metadata.xml, inside the
// current transaction without calling any hook, so a format's own
// output never re-enters it. A format must not derive an item another
// format would need to index.
Derive func(ctx context.Context, d Derived) (model.Item, error)
// Underive removes the file at path, which the format derived, without
// any hook and past the trash can, releasing its content; nothing at
// path is no error. A restore would bring back data the format
// recomputes anyway.
Underive func(ctx context.Context, c repo.Config, cached bool, path string) error
// Remove deletes the files at paths, of c's own content, as a client's
// delete does: through every hook, the format's own included, and into
// the trash can when it is on, recorded as deleted by by. It then
// prunes the folders those deletes left empty, up to the repository
// root. A path with nothing at it is skipped. It is one transaction, so
// a failure removes none. Derived work removes deployed files with it,
// such as Maven's maxUniqueSnapshots cleanup.
Remove func(ctx context.Context, c repo.Config, paths []string, by string) error
// Enqueue asks the persistent work queue for kind's work on key
// (decision 0033). Called with a hook's ctx, the work is asked for
// exactly when the write commits, and not at all after a rollback.
Enqueue func(ctx context.Context, kind, key string, payload []byte) error
// Move moves the file at from to to, both in c, as a move by the REST
// API makes it, with every hook, by as its mover, and never over an
// item at to. It returns why the file did not move, or "" once it has.
// It is for a format's Work, such as npm's strict-layout conversion,
// which moves files a client stored where the format cannot index them.
Move func(ctx context.Context, c repo.Config, from, to, by string) (string, error)
// Inspection is what the format's Inspect returned for the file being
// written. It is nil when the format inspects nothing, and on a
// restore, which runs inside its caller's transaction: a hook that needs
// one then inspects the content itself.
Inspection any
// ReindexSource binds a remote rebuild to the source accepted when queued.
// The format must recheck it in its publication transaction.
ReindexSource *model.SourceIdentity
// CheckReindex revalidates the original caller before publication of queued
// remote maintenance. Trusted direct maintenance leaves it nil.
CheckReindex func(context.Context) error
// SkipProperties is set only by an explicit reindex operation that asks
// the format to rebuild metadata without rewriting item properties.
SkipProperties bool
}
Env is what a hook runs with. The item service builds one per operation; inside a hook, ctx carries the operation's transaction, which Store, Leases, WorkQueue, Keys, Derive and Enqueue join.
type FolderAdmitter ¶
type FolderAdmitter interface {
AdmitFolder(ctx context.Context, env Env, c repo.Config, path string) error
}
FolderAdmitter is a format that checks a folder create before it is made, as Admitter checks a file write: every folder the item service's MakeFolder makes, which is a client's folder create and the folder entries of an archive exploded without atomicity. The folders a file write creates above its file are not asked, since Admit was asked about the file.
type Handler ¶
type Handler interface {
// Deployed runs after a file was stored at it (new or overwritten), by a
// deploy, a copy, a move or a restore, once its properties are set.
Deployed(ctx context.Context, env Env, c repo.Config, it model.Item) error
// Deleting runs for each file before it is removed from the tree.
Deleting(ctx context.Context, env Env, c repo.Config, it model.Item) error
// Deleted runs once after a delete or a move removed items from the tree
// and the item service pruned the versions left without files. A format
// whose versions or packages depend on more than their own files (a
// Docker tag exists while its folder holds a manifest) corrects the
// index here.
Deleted(ctx context.Context, env Env, c repo.Config, removed []model.Item) error
}
Handler is one package type's required hooks. All run inside the transaction that changes the item, so an error rolls the change back.
type Inspector ¶
type Inspector interface {
Inspect(ctx context.Context, env Env, c repo.Config, w Write) (any, error)
}
Inspector is a format that reads deployed content before the write's transaction, so no decompression or parsing holds the database's write lock. The item service calls Inspect once the content is in the blob store and hands the result to Admit and Deployed as Env.Inspection. A write the transaction then refuses leaves the content for garbage collection.
type Layouts ¶
Layouts resolves a repository layout by name: one the descriptor stored, else a bundled one.
type Op ¶
type Op int
Op is the kind of write Admit is asked about.
const ( // OpDeploy stores content at a path: by upload, by checksum, or as an // entry of an exploded archive. OpDeploy Op = iota + 1 // OpChecksum records a client checksum for the file at the path, from a // sidecar upload ("a/b.jar.sha1" names the file "a/b.jar"). OpChecksum // OpCopy and OpMove land an existing file at the path. OpCopy OpMove )
Writes a format admits.
type PathReindexer ¶
type PathReindexer interface {
Reindexer
ReindexPath(ctx context.Context, env Env, c repo.Config, path string) error
}
PathReindexer is a Reindexer that can rebuild the part of its index that the files under one path give, for Helm's partial reindex. The item service rebuilds the whole repository for a Reindexer that is not one, which leaves the same index at a greater cost.
type Registry ¶
type Registry func(t repo.PackageType) Handler
Registry returns the format handler of a package type. The application builds it from the format registry's Settings.For; core services take it as a value because importing the registry would import every ecosystem slice, and the slices import core.
type Reindexer ¶
Reindexer is a format that can rebuild its index of a repository from the item tree, for a JFrog reindex operation and for maintenance. It manages its own transactions, so a large repository need not be rebuilt in one.
type RejectionError ¶
RejectionError is a format's refusal of a request. The HTTP layer answers it with Status and Message in the envelope of the surface the request arrived on.
func Rejectf ¶
func Rejectf(status int, format string, args ...any) *RejectionError
Rejectf returns a RejectionError with a formatted message.
func (*RejectionError) Error ¶
func (r *RejectionError) Error() string
Error returns Message alone, without Status, so a refusal that is wrapped or logged reads as the text the client is answered with. The HTTP layer takes Status from the struct.
type Resolver ¶
type Resolver interface {
Resolve(ctx context.Context, env Env, c repo.Config, d Download) (string, error)
}
Resolver is a format whose downloads may name a file other than the one requested, such as a Maven version token. Resolve runs before a GET or HEAD looks the path up and returns the path to look up instead.
type SidecarKeeper ¶
type SidecarKeeper interface {
// Sidecars returns the paths in c of the sidecars the file at path
// owns, whether or not any exists, and none for a file that owns none.
// The item service asks it of owners only, never of a sidecar it
// found, so a sidecar of a sidecar is not followed.
Sidecars(c repo.Config, path string) []string
}
SidecarKeeper is a format some of whose files own sidecars: files at paths named after theirs that are of use only beside them, such as a Helm chart's provenance file, which helm fetches at the chart's URL plus ".prov" (decision 0039). The item service keeps a sidecar with its owner:
- a delete of the owner deletes it in the same operation, into the trash can when that is on;
- a copy or move of the owner takes it to the sidecar's path beside the owner's target, under the same rules as the owner, and the owner does not go without it;
- a trash restore of the owner restores it when the same delete removed it.
On its own a sidecar is an ordinary file: deleting, copying or moving it touches nothing else, and a deploy over its owner leaves it as it is. It is never a version file, so the format's index links no sidecar, and it is no checksum file either: that is SidecarOwner.
type SidecarOwner ¶
type SidecarOwner interface {
OwnsSidecars()
}
SidecarOwner is a format whose repositories take every upload named as a checksum sidecar ("a/b.jar.sha1") as a checksum of its file, as Artifactory does: Admit sees each as an OpChecksum, whether or not the file exists, and one whose file is missing is refused. In the other formats such an upload without its file is stored as a file of its own.
type Store ¶
type Store interface {
tx.Runner
Repos() port.RepoStore
Items() port.ItemStore
Packages() port.PackageStore
RemoteCache() port.RemoteCacheStore
}
Store is what a format reads and writes through Env.Store, inside the operation's transaction: repositories, items, the package index and the remote cache. Every call joins the transaction ctx carries; inside a hook, Tx joins the operation's transaction rather than starting one of its own (tx.Runner). It has no blob index: a format reads content only through Env.Blobs (decision 0004). Each composite store in app is a Store, so every builder of Env keeps the value it passes.
type TransferSourceGuard ¶
type TransferSourceGuard interface {
GuardTransferSource(ctx context.Context, env Env, c repo.Config, it model.Item) error
}
TransferSourceGuard checks whether a stored file may leave its source format through a copy or move. It runs for each file, including folder descendants, before destination inspection. RejectionError reports and skips that file; other errors abort planning before any items change. Destination admission remains the target format's responsibility.
type WorkRef ¶
type WorkRef struct {
Kind, Key string
}
WorkRef names one item of the persistent work queue: a kind and a key.
type WorkRequest ¶
type WorkRequest struct {
// By is recorded as the mover of what npm's strict-layout conversion
// moves.
By string `json:"by,omitempty"`
SkipProperties bool `json:"-"`
// Source fences a queued remote reindex across edits and delete/recreate.
Source *model.SourceIdentity `json:"source,omitempty"`
// Credential is an internal reference to the original authenticated caller.
// It contains no password, bearer token or cached permissions.
Credential json.RawMessage `json:"credential,omitempty"`
}
WorkRequest is the payload of the work a JFrog operation queues: who asked for it.
type Worker ¶
type Worker interface {
// WorkKinds are the kinds the format enqueues: code constants, unique
// across formats.
WorkKinds() []string
// Work runs one item of one of the format's kinds, outside any
// transaction. It must be idempotent and read the state it derives from
// afresh, since an item can run again and coalesces every request made
// before the run began.
Work(ctx context.Context, env Env, item work.WorkItem) error
// Owed names the work a download of path from c must see done before
// it is read, so a client never reads derived data that lags a
// completed write.
Owed(c repo.Config, cached bool, path string) []WorkRef
}
Worker is a format that queues derived work with Env.Enqueue and runs it from the persistent work queue (decision 0033), such as Maven's metadata.
type Write ¶
type Write struct {
// By is the actor recorded for a deploy, empty for other write kinds.
// It binds staged publication to its creator without HTTP dependencies.
By string
Op Op
// Path is the repository-relative target. Admit may change it, and the
// write then lands there.
Path string
Cached bool
// Properties are set on the item with the write: a deploy's matrix
// parameters, or the properties a copy or move carries over. Admit may
// add or change them.
Properties model.Properties
// Size and Checksums describe the content. For OpChecksum, Checksums is
// empty and Size is the length of the sidecar's body as the client
// declared it, or -1.
Size int64
Checksums kernel.Checksums
// From is the source of a copy or move.
From model.Item
}
Write is a file write as a format sees it before it happens.
type WriteGuard ¶
type WriteGuard interface {
GuardWrite(ctx context.Context, env Env, c repo.Config, w Write) error
}
WriteGuard rechecks invariants that depend on concurrent writes inside the transaction, before a deploy, copy or move lands. Unlike Admit, which also plans transfers outside a transaction, this hook may acquire database locks that must survive until commit. A format RejectionError skips a transfer item, as planning refusals do; other errors roll back the operation. Restores bypass admission and this guard, preserving their existing semantics.