api

package
v0.0.0-...-91de801 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_CACHE_SIZE_MB = 10

Do not store over this amount of MBs in the cache

Variables

This section is empty.

Functions

func NewCustomError

func NewCustomError(code int, message string) *customError

Types

type API

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

func New

func New(
	serv service.Service, logger *slog.Logger, settings *settings.AppSettings,
) *API

func (*API) Start

func (a *API) Start(
	e *gin.Engine, address string, cache *Cache,
) (*gin.Engine, error)

type Cache

type Cache interface {
	Get(name string) (EndpointCache, error)
	Store(name string, buffer []byte) error
	Size() uint64
}

func MakeCache

func MakeCache(n_shards int, expiry_duration time.Duration) Cache

type CacheValidator

type CacheValidator interface {
	IsValid(cache *EndpointCache) bool
}

type EndpointCache

type EndpointCache struct {
	Name       string
	Contents   []byte
	ValidUntil time.Time
}

type TimeValidator

type TimeValidator struct{}

func (*TimeValidator) IsValid

func (v *TimeValidator) IsValid(cache *EndpointCache) bool

type TimedCache

type TimedCache struct {
	CacheMap      shardedmap.ShardMap
	CacheTimeout  time.Duration
	EstimatedSize atomic.Uint64 // in bytes
	Validator     CacheValidator
}

func (*TimedCache) Get

func (cache *TimedCache) Get(name string) (EndpointCache, error)

func (*TimedCache) Size

func (cache *TimedCache) Size() uint64

func (*TimedCache) Store

func (cache *TimedCache) Store(name string, buffer []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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