core

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 13 Imported by: 18

Documentation

Index

Constants

View Source
const MappingKeyPrefix = "IDX_"

Variables

View Source
var File_storage_proto protoreflect.FileDescriptor

Functions

func MappingElection

func MappingElection(provider Storer, item []byte, req *http.Request, validator *Revalidator, logger Logger) (resultFresh *http.Response, resultStale *http.Response, e error)

func MappingUpdater

func MappingUpdater(key string, item []byte, logger Logger, now, freshTime, staleTime time.Time, variedHeaders http.Header, etag, realKey string) (val []byte, e error)

func RegisterStorage

func RegisterStorage(s Storer)

func ResetRegisteredStorages added in v0.0.2

func ResetRegisteredStorages()

func ValidateETagFromHeader

func ValidateETagFromHeader(etag string, validator *Revalidator)

Types

type CacheProvider

type CacheProvider struct {
	// URL to connect to the storage system.
	URL string `json:"url" yaml:"url"`
	// Path to the configuration file.
	Path string `json:"path" yaml:"path"`
	// Declare the cache provider directly in the Souin configuration.
	Configuration interface{} `json:"configuration" yaml:"configuration"`
}

CacheProvider config.

type Configuration

type Configuration struct {
	Provider CacheProvider `json:"provider"`
	Stale    time.Duration `json:"stale"`
}

type KeyIndex added in v0.0.6

type KeyIndex struct {
	StoredAt      *timestamppb.Timestamp         `protobuf:"bytes,1,opt,name=stored_at,json=storedAt,proto3" json:"stored_at,omitempty"`
	FreshTime     *timestamppb.Timestamp         `protobuf:"bytes,2,opt,name=fresh_time,json=freshTime,proto3" json:"fresh_time,omitempty"`
	StaleTime     *timestamppb.Timestamp         `protobuf:"bytes,3,opt,name=stale_time,json=staleTime,proto3" json:"stale_time,omitempty"`
	VariedHeaders map[string]*KeyIndexStringList `` /* 188-byte string literal not displayed */
	Etag          string                         `protobuf:"bytes,5,opt,name=etag,proto3" json:"etag,omitempty"`
	RealKey       string                         `protobuf:"bytes,6,opt,name=real_key,json=realKey,proto3" json:"real_key,omitempty"`
	// contains filtered or unexported fields
}

func (*KeyIndex) Descriptor deprecated added in v0.0.6

func (*KeyIndex) Descriptor() ([]byte, []int)

Deprecated: Use KeyIndex.ProtoReflect.Descriptor instead.

func (*KeyIndex) GetEtag added in v0.0.6

func (x *KeyIndex) GetEtag() string

func (*KeyIndex) GetFreshTime added in v0.0.6

func (x *KeyIndex) GetFreshTime() *timestamppb.Timestamp

func (*KeyIndex) GetRealKey added in v0.0.6

func (x *KeyIndex) GetRealKey() string

func (*KeyIndex) GetStaleTime added in v0.0.6

func (x *KeyIndex) GetStaleTime() *timestamppb.Timestamp

func (*KeyIndex) GetStoredAt added in v0.0.6

func (x *KeyIndex) GetStoredAt() *timestamppb.Timestamp

func (*KeyIndex) GetVariedHeaders added in v0.0.6

func (x *KeyIndex) GetVariedHeaders() map[string]*KeyIndexStringList

func (*KeyIndex) ProtoMessage added in v0.0.6

func (*KeyIndex) ProtoMessage()

func (*KeyIndex) ProtoReflect added in v0.0.6

func (x *KeyIndex) ProtoReflect() protoreflect.Message

func (*KeyIndex) Reset added in v0.0.6

func (x *KeyIndex) Reset()

func (*KeyIndex) String added in v0.0.6

func (x *KeyIndex) String() string

type KeyIndexStringList added in v0.0.6

type KeyIndexStringList struct {
	HeaderValue []string `protobuf:"bytes,1,rep,name=header_value,json=headerValue,proto3" json:"header_value,omitempty"`
	// contains filtered or unexported fields
}

func (*KeyIndexStringList) Descriptor deprecated added in v0.0.6

func (*KeyIndexStringList) Descriptor() ([]byte, []int)

Deprecated: Use KeyIndexStringList.ProtoReflect.Descriptor instead.

func (*KeyIndexStringList) GetHeaderValue added in v0.0.6

func (x *KeyIndexStringList) GetHeaderValue() []string

func (*KeyIndexStringList) ProtoMessage added in v0.0.6

func (*KeyIndexStringList) ProtoMessage()

func (*KeyIndexStringList) ProtoReflect added in v0.0.6

func (x *KeyIndexStringList) ProtoReflect() protoreflect.Message

func (*KeyIndexStringList) Reset added in v0.0.6

func (x *KeyIndexStringList) Reset()

func (*KeyIndexStringList) String added in v0.0.6

func (x *KeyIndexStringList) String() string

type Logger added in v0.0.6

type Logger interface {
	Debug(args ...interface{})
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	DPanic(args ...interface{})
	Panic(args ...interface{})
	Fatal(args ...interface{})
	Debugf(template string, args ...interface{})
	Infof(template string, args ...interface{})
	Warnf(template string, args ...interface{})
	Errorf(template string, args ...interface{})
	DPanicf(template string, args ...interface{})
	Panicf(template string, args ...interface{})
	Fatalf(template string, args ...interface{})
}

type Revalidator

type Revalidator struct {
	Matched                     bool
	IfNoneMatchPresent          bool
	IfMatchPresent              bool
	IfModifiedSincePresent      bool
	IfUnmodifiedSincePresent    bool
	IfUnmotModifiedSincePresent bool
	NeedRevalidation            bool
	NotModified                 bool
	IfModifiedSince             time.Time
	IfUnmodifiedSince           time.Time
	IfNoneMatch                 []string
	IfMatch                     []string
	RequestETags                []string
	ResponseETag                string
}

type StorageMapper

type StorageMapper struct {
	Mapping map[string]*KeyIndex `` /* 155-byte string literal not displayed */
	// contains filtered or unexported fields
}

func DecodeMapping

func DecodeMapping(item []byte) (*StorageMapper, error)

func (*StorageMapper) Descriptor deprecated added in v0.0.6

func (*StorageMapper) Descriptor() ([]byte, []int)

Deprecated: Use StorageMapper.ProtoReflect.Descriptor instead.

func (*StorageMapper) GetMapping added in v0.0.6

func (x *StorageMapper) GetMapping() map[string]*KeyIndex

func (*StorageMapper) ProtoMessage added in v0.0.6

func (*StorageMapper) ProtoMessage()

func (*StorageMapper) ProtoReflect added in v0.0.6

func (x *StorageMapper) ProtoReflect() protoreflect.Message

func (*StorageMapper) Reset added in v0.0.6

func (x *StorageMapper) Reset()

func (*StorageMapper) String added in v0.0.6

func (x *StorageMapper) String() string

type Storer

type Storer interface {
	MapKeys(prefix string) map[string]string
	ListKeys() []string
	Get(key string) []byte
	Set(key string, value []byte, duration time.Duration) error
	Delete(key string)
	DeleteMany(key string)
	Init() error
	Name() string
	Uuid() string
	Reset() error

	// Multi level storer to handle fresh/stale at once
	GetMultiLevel(key string, req *http.Request, validator *Revalidator) (fresh *http.Response, stale *http.Response)
	SetMultiLevel(baseKey, variedKey string, value []byte, variedHeaders http.Header, etag string, duration time.Duration, realKey string) error
}

func GetRegisteredStorer

func GetRegisteredStorer(name string) Storer

func GetRegisteredStorers

func GetRegisteredStorers() []Storer

Jump to

Keyboard shortcuts

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