2018-02-21 19:01:43 +00:00
|
|
|
package solver
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"time"
|
|
|
|
|
2020-10-27 06:13:39 +00:00
|
|
|
"github.com/moby/buildkit/session"
|
2018-02-21 19:01:43 +00:00
|
|
|
digest "github.com/opencontainers/go-digest"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
)
|
|
|
|
|
|
|
|
var ErrNotFound = errors.Errorf("not found")
|
|
|
|
|
|
|
|
// CacheKeyStorage is interface for persisting cache metadata
|
|
|
|
type CacheKeyStorage interface {
|
2018-03-17 04:07:18 +00:00
|
|
|
Exists(id string) bool
|
2018-02-27 01:39:18 +00:00
|
|
|
Walk(fn func(id string) error) error
|
2018-02-21 19:01:43 +00:00
|
|
|
|
|
|
|
WalkResults(id string, fn func(CacheResult) error) error
|
|
|
|
Load(id string, resultID string) (CacheResult, error)
|
|
|
|
AddResult(id string, res CacheResult) error
|
|
|
|
Release(resultID string) error
|
2018-04-24 19:01:50 +00:00
|
|
|
WalkIDsByResult(resultID string, fn func(string) error) error
|
2018-02-21 19:01:43 +00:00
|
|
|
|
|
|
|
AddLink(id string, link CacheInfoLink, target string) error
|
|
|
|
WalkLinks(id string, link CacheInfoLink, fn func(id string) error) error
|
2018-04-13 20:52:27 +00:00
|
|
|
HasLink(id string, link CacheInfoLink, target string) bool
|
|
|
|
WalkBacklinks(id string, fn func(id string, link CacheInfoLink) error) error
|
2018-02-21 19:01:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CacheResult is a record for a single solve result
|
|
|
|
type CacheResult struct {
|
|
|
|
CreatedAt time.Time
|
|
|
|
ID string
|
|
|
|
}
|
|
|
|
|
|
|
|
// CacheInfoLink is a link between two cache keys
|
|
|
|
type CacheInfoLink struct {
|
2018-02-26 18:51:38 +00:00
|
|
|
Input Index `json:"Input,omitempty"`
|
|
|
|
Output Index `json:"Output,omitempty"`
|
|
|
|
Digest digest.Digest `json:"Digest,omitempty"`
|
|
|
|
Selector digest.Digest `json:"Selector,omitempty"`
|
2018-02-21 19:01:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// CacheResultStorage is interface for converting cache metadata result to
|
|
|
|
// actual solve result
|
|
|
|
type CacheResultStorage interface {
|
2019-01-10 16:43:27 +00:00
|
|
|
Save(Result, time.Time) (CacheResult, error)
|
2018-02-21 19:01:43 +00:00
|
|
|
Load(ctx context.Context, res CacheResult) (Result, error)
|
2021-10-05 06:43:22 +00:00
|
|
|
LoadRemotes(ctx context.Context, res CacheResult, compression *CompressionOpt, s session.Group) ([]*Remote, error)
|
2018-02-27 01:39:18 +00:00
|
|
|
Exists(id string) bool
|
2018-02-21 19:01:43 +00:00
|
|
|
}
|