Documentation ¶
Index ¶
- Variables
- func Log(logger Logger, message string)
- func SetLogger(thread *starlark.Thread, log Logger)
- type Counter
- type EnvironmentInterface
- func (eif *EnvironmentInterface) Cache(key string, version int, expire time.Duration, miss func(w io.Writer) error) (*os.File, error)
- func (eif *EnvironmentInterface) CacheObjects(key string, version int, expire time.Duration, ...) error
- func (eif *EnvironmentInterface) GetCachePath(key string) (string, error)
- func (eif *EnvironmentInterface) HttpGetReader(url string, options HttpOptions) (*os.File, error)
- type HttpOptions
- type Logger
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 ¶
Types ¶
type Counter ¶
func NewCounter ¶
func NewCounter() Counter
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 ¶
Click to show internal directories.
Click to hide internal directories.