proxy

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheKey

func CacheKey(contributor, resourceType, resourceID string) string

CacheKey generates a cache key for a contributor's page or widget.

Types

type CacheEntry

type CacheEntry struct {
	Data      []byte
	FetchedAt time.Time
	ExpiresAt time.Time
}

CacheEntry holds a cached HTML fragment with expiry tracking.

func (*CacheEntry) Age

func (e *CacheEntry) Age() time.Duration

Age returns how old this cache entry is.

func (*CacheEntry) IsExpired

func (e *CacheEntry) IsExpired() bool

IsExpired returns true if the cache entry has expired.

type FragmentCache

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

FragmentCache is an LRU+TTL cache for HTML fragments from remote contributors.

func NewFragmentCache

func NewFragmentCache(maxSize int, ttl time.Duration) *FragmentCache

NewFragmentCache creates a new fragment cache.

func (*FragmentCache) Clear

func (c *FragmentCache) Clear()

Clear removes all cached entries.

func (*FragmentCache) Delete

func (c *FragmentCache) Delete(key string)

Delete removes a cached entry.

func (*FragmentCache) Get

func (c *FragmentCache) Get(key string) *CacheEntry

Get retrieves a cached fragment. Returns nil if not found or expired.

func (*FragmentCache) GetStale

func (c *FragmentCache) GetStale(key string) *CacheEntry

GetStale retrieves a cached fragment even if expired. This is used by the recovery system to serve stale content when remotes are down.

func (*FragmentCache) Set

func (c *FragmentCache) Set(key string, data []byte)

Set stores a fragment in the cache.

func (*FragmentCache) Size

func (c *FragmentCache) Size() int

Size returns the number of cached entries.

type FragmentProxy

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

FragmentProxy fetches HTML fragments from remote contributors with caching. It provides the primary integration between the dashboard shell and remote services.

func NewFragmentProxy

func NewFragmentProxy(
	registry *contributor.ContributorRegistry,
	cacheMaxSize int,
	cacheTTL time.Duration,
	timeout time.Duration,
	logger forge.Logger,
) *FragmentProxy

NewFragmentProxy creates a new fragment proxy.

func (*FragmentProxy) Cache

func (p *FragmentProxy) Cache() *FragmentCache

Cache returns the underlying fragment cache (for metrics/status reporting).

func (*FragmentProxy) FetchPage

func (p *FragmentProxy) FetchPage(ctx context.Context, name, route string) ([]byte, error)

FetchPage fetches a page fragment from a remote contributor, using cache when available.

func (*FragmentProxy) FetchWidget

func (p *FragmentProxy) FetchWidget(ctx context.Context, name, widgetID string) ([]byte, error)

FetchWidget fetches a widget fragment from a remote contributor, using cache when available.

func (*FragmentProxy) InvalidateContributor

func (p *FragmentProxy) InvalidateContributor(name string)

InvalidateContributor removes all cached fragments for a contributor.

Jump to

Keyboard shortcuts

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