Documentation
¶
Index ¶
- Variables
- func CacheTypeStrings() []string
- func GenerateKey(elems ...string) string
- func TransferFiles(ctx context.Context, fs filesystem.FS, dst, src string) (destFile string, err error)
- type AbstractSharedCacheRepository
- func (c *AbstractSharedCacheRepository) EntriesCount(ctx context.Context) (count int64, err error)
- func (c *AbstractSharedCacheRepository) GenerateKey(elems ...string) string
- func (c *AbstractSharedCacheRepository) GetEntries(ctx context.Context) (entries []string, err error)
- func (c *AbstractSharedCacheRepository) RemoveEntry(ctx context.Context, key string) error
- type CacheType
- func (i CacheType) IsACacheType() bool
- func (i CacheType) MarshalJSON() ([]byte, error)
- func (i CacheType) MarshalText() ([]byte, error)
- func (i CacheType) MarshalYAML() (interface{}, error)
- func (i CacheType) String() string
- func (i *CacheType) UnmarshalJSON(data []byte) error
- func (i *CacheType) UnmarshalText(text []byte) error
- func (i *CacheType) UnmarshalYAML(unmarshal func(interface{}) error) error
- type Configuration
- type FileWithModTime
- type ISharedCacheRepository
- type SharedImmutableCacheRepository
- func (s *SharedImmutableCacheRepository) CleanEntry(ctx context.Context, key string) (err error)
- func (s *SharedImmutableCacheRepository) Fetch(ctx context.Context, key, dest string) (err error)
- func (s *SharedImmutableCacheRepository) GetEntryAge(ctx context.Context, key string) (age time.Duration, err error)
- func (s *SharedImmutableCacheRepository) SetEntryAge(ctx context.Context, key string, age time.Duration) error
- func (s *SharedImmutableCacheRepository) Store(ctx context.Context, key, src string) (err error)
- type SharedMutableCacheRepository
- func (s *SharedMutableCacheRepository) CleanEntry(ctx context.Context, key string) error
- func (s *SharedMutableCacheRepository) Fetch(ctx context.Context, key, dest string) (err error)
- func (s *SharedMutableCacheRepository) GetEntryAge(ctx context.Context, key string) (time.Duration, error)
- func (s *SharedMutableCacheRepository) SetEntryAge(ctx context.Context, key string, age time.Duration) error
- func (s *SharedMutableCacheRepository) Store(ctx context.Context, key, src string) (err error)
Constants ¶
This section is empty.
Variables ¶
var (
CacheTypes = []CacheType{CacheMutable, CacheImmutable}
)
Functions ¶
func CacheTypeStrings ¶ added in v1.90.0
func CacheTypeStrings() []string
CacheTypeStrings returns a slice of all String values of the enum
func GenerateKey ¶
GenerateKey generates a key based on a list of key elements `elems`.
func TransferFiles ¶
func TransferFiles(ctx context.Context, fs filesystem.FS, dst, src string) (destFile string, err error)
TransferFiles transfers a file from a location `src` to another `dest` and ensures the integrity (i.e. hash validation) of what was copied across. `dest` can be a file or a directory. If not existent, it will be created on the fly. non-existent directory path should be terminated by a path separator i.e. / or \
Types ¶
type AbstractSharedCacheRepository ¶
type AbstractSharedCacheRepository struct {
// contains filtered or unexported fields
}
AbstractSharedCacheRepository defines an abstract cache repository.
func NewAbstractSharedCacheRepository ¶
func NewAbstractSharedCacheRepository(cfg *Configuration, fs filesystem.FS) (cache *AbstractSharedCacheRepository, err error)
func (*AbstractSharedCacheRepository) EntriesCount ¶
func (c *AbstractSharedCacheRepository) EntriesCount(ctx context.Context) (count int64, err error)
func (*AbstractSharedCacheRepository) GenerateKey ¶
func (c *AbstractSharedCacheRepository) GenerateKey(elems ...string) string
func (*AbstractSharedCacheRepository) GetEntries ¶
func (c *AbstractSharedCacheRepository) GetEntries(ctx context.Context) (entries []string, err error)
func (*AbstractSharedCacheRepository) RemoveEntry ¶
func (c *AbstractSharedCacheRepository) RemoveEntry(ctx context.Context, key string) error
type CacheType ¶
type CacheType int
func CacheTypeString ¶ added in v1.90.0
CacheTypeString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.
func CacheTypeValues ¶ added in v1.90.0
func CacheTypeValues() []CacheType
CacheTypeValues returns all values of the enum
func (CacheType) IsACacheType ¶ added in v1.90.0
IsACacheType returns "true" if the value is listed in the enum definition. "false" otherwise
func (CacheType) MarshalJSON ¶ added in v1.90.0
MarshalJSON implements the json.Marshaler interface for CacheType
func (CacheType) MarshalText ¶ added in v1.90.0
MarshalText implements the encoding.TextMarshaler interface for CacheType
func (CacheType) MarshalYAML ¶ added in v1.90.0
MarshalYAML implements a YAML Marshaler for CacheType
func (*CacheType) UnmarshalJSON ¶ added in v1.90.0
UnmarshalJSON implements the json.Unmarshaler interface for CacheType
func (*CacheType) UnmarshalText ¶ added in v1.90.0
UnmarshalText implements the encoding.TextUnmarshaler interface for CacheType
func (*CacheType) UnmarshalYAML ¶ added in v1.90.0
UnmarshalYAML implements a YAML Unmarshaler for CacheType
type Configuration ¶
type Configuration struct { RemoteStoragePath string `mapstructure:"remote_storage_path"` // Path where the cache will be stored. Timeout time.Duration `mapstructure:"timeout"` // Cache timeout if need be FilesystemItemsToIgnore string `mapstructure:"ignore_fs_items"` // List of files/folders to ignore (pattern list separated by commas) }
func DefaultSharedCacheConfiguration ¶
func DefaultSharedCacheConfiguration() *Configuration
func (*Configuration) Validate ¶
func (cfg *Configuration) Validate() error
type FileWithModTime ¶
type FileWithModTime struct {
// contains filtered or unexported fields
}
type ISharedCacheRepository ¶
type ISharedCacheRepository interface { string) string Fetch(ctx context.Context, key, dest string) error Store(ctx context.Context, key, src string) error CleanEntry(ctx context.Context, key string) error RemoveEntry(ctx context.Context, key string) error GetEntryAge(ctx context.Context, key string) (age time.Duration, err error) SetEntryAge(ctx context.Context, key string, age time.Duration) error GetEntries(ctx context.Context) (entries []string, err error) EntriesCount(ctx context.Context) (int64, error) }GenerateKey(elems ...
ISharedCacheRepository defines a cache stored on a remote location and shared by separate processes.
func NewCache ¶
func NewCache(cacheType CacheType, fs filesystem.FS, cfg *Configuration) (ISharedCacheRepository, error)
func NewSharedMutableCacheRepository ¶
func NewSharedMutableCacheRepository(cfg *Configuration, fs filesystem.FS) (repository ISharedCacheRepository, err error)
type SharedImmutableCacheRepository ¶
type SharedImmutableCacheRepository struct {
}func NewSharedImmutableCacheRepository ¶
func NewSharedImmutableCacheRepository(cfg *Configuration, fs filesystem.FS) (repository *SharedImmutableCacheRepository, err error)
func (*SharedImmutableCacheRepository) CleanEntry ¶
func (s *SharedImmutableCacheRepository) CleanEntry(ctx context.Context, key string) (err error)
func (*SharedImmutableCacheRepository) Fetch ¶
func (s *SharedImmutableCacheRepository) Fetch(ctx context.Context, key, dest string) (err error)
func (*SharedImmutableCacheRepository) GetEntryAge ¶
func (*SharedImmutableCacheRepository) SetEntryAge ¶
type SharedMutableCacheRepository ¶
type SharedMutableCacheRepository struct { // contains filtered or unexported fields }
SharedMutableCacheRepository defines a shared cache using a distributed lock system solely based on lock files.
func (*SharedMutableCacheRepository) CleanEntry ¶
func (s *SharedMutableCacheRepository) CleanEntry(ctx context.Context, key string) error
func (*SharedMutableCacheRepository) Fetch ¶
func (s *SharedMutableCacheRepository) Fetch(ctx context.Context, key, dest string) (err error)