core

package
v0.0.0-...-f589a4c Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CACHE_EXPIRE_RULES = []struct {
	re     *regexp.Regexp
	maxAge time.Duration
}{

	{regexp.MustCompile(".*/APKINDEX.tar.gz"), REFRESH_TIME},

	{regexp.MustCompile(".*/Packages.gz"), REFRESH_TIME},

	{regexp.MustCompile(".*.db.tar.gz"), REFRESH_TIME},
	{regexp.MustCompile(".*/packages-meta-ext-v1.json.gz"), REFRESH_TIME},

	{regexp.MustCompile(".*/repodata/repomd.xml"), REFRESH_TIME},

	{regexp.MustCompile(".*/repodata.json"), REFRESH_TIME},

	{regexp.MustCompile(".*/.*-repodata"), REFRESH_TIME},
}
View Source
var (
	ErrNotFound = fmt.Errorf("http not found")
)
View Source
var REFRESH_TIME = 1 * time.Hour

Functions

func Log

func Log(logger Logger, message string)

func SetLogger

func SetLogger(thread *starlark.Thread, log Logger)

Types

type Counter

type Counter map[string]int

func NewCounter

func NewCounter() Counter

func (Counter) Add

func (c Counter) Add(s string)

func (Counter) String

func (c Counter) String() string

type EnvironmentInterface

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

func NewEif

func NewEif(cachePath string) *EnvironmentInterface

func (*EnvironmentInterface) Cache

func (eif *EnvironmentInterface) Cache(
	key string,
	version int,
	expire time.Duration,
	miss func(w io.Writer) error,
) (*os.File, error)

A generic interface to caching arbitrary data. Right now this saves to the filesystem but that should not be assumed long term. The filename it writes to is considered a internal implementation detail. This method is not currently thread-safe.

func (*EnvironmentInterface) CacheObjects

func (eif *EnvironmentInterface) CacheObjects(
	key string,
	version int,
	expire time.Duration,

	miss func(write func(obj any) error) error,

	decode func(read func(obj any) error) error,
) error

A higher level interface for caching arbitrary objects.

func (*EnvironmentInterface) GetCachePath

func (eif *EnvironmentInterface) GetCachePath(key string) (string, error)

func (*EnvironmentInterface) HttpGetReader

func (eif *EnvironmentInterface) HttpGetReader(url string, options HttpOptions) (*os.File, error)

type HttpOptions

type HttpOptions struct {
	ExpectedSize int64
	Accept       string
	UseETag      bool
	FastDownload bool
	ExpireTime   time.Duration
	Logger       Logger
	Params       map[string]string
	WaitTime     time.Duration
}

type Logger

type Logger interface {
	Log(message string)
	Count(message string)
}

func GetLogger

func GetLogger(thread *starlark.Thread) Logger

Jump to

Keyboard shortcuts

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