loaders

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0, MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCacheMiss = errors.New("cache miss")

Functions

func NewDocumentLoader

func NewDocumentLoader(ipfsCli IPFSClient, ipfsGW string,
	opts ...DocumentLoaderOption) ld.DocumentLoader

NewDocumentLoader creates a new document loader with a cache for http. ipfs cache is not implemented yet.

Types

type CacheEngine

type CacheEngine interface {
	Get(key string) (doc *ld.RemoteDocument, expireTime time.Time, err error)
	Set(key string, doc *ld.RemoteDocument, expireTime time.Time) error
}

func NewMemoryCacheEngine

func NewMemoryCacheEngine(
	opts ...MemoryCacheEngineOption) (CacheEngine, error)

type DocumentLoaderOption

type DocumentLoaderOption func(*documentLoader)

func WithCacheEngine

func WithCacheEngine(cacheEngine CacheEngine) DocumentLoaderOption

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) DocumentLoaderOption

type IPFSClient

type IPFSClient interface {
	Cat(url string) (io.ReadCloser, error)
}

type MemoryCacheEngineOption

type MemoryCacheEngineOption func(*memoryCacheEngine) error

func WithEmbeddedDocumentBytes

func WithEmbeddedDocumentBytes(u string, doc []byte) MemoryCacheEngineOption

Jump to

Keyboard shortcuts

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