store

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotExists = errors.New("not exists")
)
View Source
var (
	ErrStoreReleased = errors.New("store released")
)

Functions

This section is empty.

Types

type CacheStatus

type CacheStatus int
const (
	CacheStatusUnspecified CacheStatus = iota
	CacheStatusHit
	CacheStatusMiss
	CacheStatusExpired
	CacheStatusUpdating
	CacheStatusStale
	CacheStatusDynamic
)

func (CacheStatus) String

func (s CacheStatus) String() string

type Config

type Config struct {
	Logger            *logng.Logger
	Path              string
	TLSConfig         *tls.Config
	MaxIdleConns      int
	UserAgent         string
	MinContentAge     time.Duration
	DefaultHostConfig *HostConfig
	GetHostConfig     func(scheme, host string) *HostConfig
}

type ContentRange

type ContentRange struct {
	Start int64
	End   int64
}

type Data

type Data struct {
	Path string
	Info struct {
		BaseURL    string
		KeyURL     string
		StatusCode int
		Size       int64
		CreatedAt  time.Time
		ExpiresAt  time.Time
	}
	Header http.Header
	// contains filtered or unexported fields
}

func (*Data) Body

func (d *Data) Body() *os.File

func (*Data) Close

func (d *Data) Close() (err error)

func (*Data) Create

func (d *Data) Create() (err error)

func (*Data) Open

func (d *Data) Open() (err error)

type DynamicContentError

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

func (*DynamicContentError) Error

func (e *DynamicContentError) Error() string

type GetResult

type GetResult struct {
	io.ReadCloser
	BaseURL      *url.URL
	KeyURL       *url.URL
	CacheStatus  CacheStatus
	StatusCode   int
	Header       http.Header
	CreatedAt    time.Time
	ExpiresAt    time.Time
	Size         int64
	ContentRange *ContentRange
}

type HostConfig

type HostConfig struct {
	MaxSize        int64
	MaxAge         time.Duration
	MaxAge404      time.Duration
	MaxAgeOverride bool
	DownloadBurst  int64
	DownloadRate   int64
}

type RequestError

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

func (*RequestError) Error

func (e *RequestError) Error() string

func (*RequestError) Unwrap

func (e *RequestError) Unwrap() error

type SizeExceededError

type SizeExceededError struct {
	Size int64
}

func (*SizeExceededError) Error

func (e *SizeExceededError) Error() string

type Store

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

func New

func New(config Config) (result *Store, err error)

func (*Store) Get

func (s *Store) Get(ctx context.Context, rawURL string, host string, contentRange *ContentRange) (result GetResult, err error)

func (*Store) Purge

func (s *Store) Purge(ctx context.Context, rawURL string, host string) (err error)

func (*Store) PurgeAll added in v0.4.0

func (s *Store) PurgeAll(ctx context.Context) (err error)

func (*Store) PurgeHost

func (s *Store) PurgeHost(ctx context.Context, host string) (err error)

func (*Store) Release

func (s *Store) Release() (err error)

Jump to

Keyboard shortcuts

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