actionscache

package module
v0.0.0-...-58651d5 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 20 Imported by: 5

Documentation

Index

Constants

View Source
const (
	PermissionRead = 1 << iota
	PermissionWrite
)

Variables

View Source
var Log = func(string, ...interface{}) {}
View Source
var UploadChunkSize = 32 * 1024 * 1024
View Source
var UploadConcurrency = 4

Functions

This section is empty.

Types

type BackoffPool

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

func (*BackoffPool) Delay

func (b *BackoffPool) Delay()

func (*BackoffPool) Reset

func (b *BackoffPool) Reset()

func (*BackoffPool) Wait

func (b *BackoffPool) Wait(ctx context.Context, timeout time.Duration) error

type Blob

type Blob interface {
	io.ReaderAt
	io.Closer
	Size() int64
}

func NewBlob

func NewBlob(dt []byte) Blob

type Cache

type Cache struct {
	URL       string
	Token     *jwt.Token
	IssuedAt  time.Time
	ExpiresAt time.Time
	// contains filtered or unexported fields
}

func New

func New(token, url string, opt Opt) (*Cache, error)

func TryEnv

func TryEnv(opt Opt) (*Cache, error)

func (*Cache) AllKeys

func (c *Cache) AllKeys(ctx context.Context, api *RestAPI, prefix string) (map[string]struct{}, error)

func (*Cache) Load

func (c *Cache) Load(ctx context.Context, keys ...string) (*Entry, error)

func (*Cache) Save

func (c *Cache) Save(ctx context.Context, key string, b Blob) error

func (*Cache) SaveMutable

func (c *Cache) SaveMutable(ctx context.Context, key string, forceTimeout time.Duration, f func(old *Entry) (Blob, error)) error

SaveMutable stores a blob over a possibly existing key. Previous value is passed to callback that needs to return new blob. Callback may be called multiple times if two saves happen during same time window. In case of a crash a key may remain locked, preventing previous changes. Timeout can be set to force changes in this case without guaranteeing that previous value was up to date.

func (*Cache) Scopes

func (c *Cache) Scopes() []Scope

type CacheKey

type CacheKey struct {
	ID           int    `json:"id"`
	Ref          string `json:"ref"`
	Key          string `json:"key"`
	Version      string `json:"version"`
	LastAccessed string `json:"last_accessed_at"`
	CreatedAt    string `json:"created_at"`
	SizeInBytes  int    `json:"size_in_bytes"`
}

type CommitCacheReq

type CommitCacheReq struct {
	Size int64 `json:"size"`
}

type Entry

type Entry struct {
	Key   string `json:"cacheKey"`
	Scope string `json:"scope"`
	URL   string `json:"archiveLocation"`
	// contains filtered or unexported fields
}

func (*Entry) Download

func (ce *Entry) Download(ctx context.Context) ReaderAtCloser

Download returns a ReaderAtCloser for pulling the data. Concurrent reads are not allowed

func (*Entry) WriteTo

func (ce *Entry) WriteTo(ctx context.Context, w io.Writer) error

type GithubAPIError

type GithubAPIError struct {
	Message   string `json:"message"`
	TypeName  string `json:"typeName"`
	TypeKey   string `json:"typeKey"`
	ErrorCode int    `json:"errorCode"`
}

func (GithubAPIError) Error

func (e GithubAPIError) Error() string

func (GithubAPIError) Is

func (e GithubAPIError) Is(err error) bool

type HTTPError

type HTTPError struct {
	StatusCode int
	Err        error
}

func (HTTPError) Error

func (e HTTPError) Error() string

func (HTTPError) Unwrap

func (e HTTPError) Unwrap() error

type Opt

type Opt struct {
	Client      *http.Client
	Timeout     time.Duration
	BackoffPool *BackoffPool
}

type Permission

type Permission int

func (Permission) String

func (p Permission) String() string

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.Closer
}

type ReserveCacheReq

type ReserveCacheReq struct {
	Key     string `json:"key"`
	Version string `json:"version"`
}

type ReserveCacheResp

type ReserveCacheResp struct {
	CacheID int `json:"cacheID"`
}

type RestAPI

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

func NewRestAPI

func NewRestAPI(repo, token string, opt Opt) (*RestAPI, error)

func (*RestAPI) ListKeys

func (r *RestAPI) ListKeys(ctx context.Context, prefix, ref string) ([]CacheKey, error)

type Scope

type Scope struct {
	Scope      string
	Permission Permission
}

Jump to

Keyboard shortcuts

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