plugincache

package
v0.3.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package plugincache provides a shared, reference-counted plugin manager that survives config reloads without disrupting in-flight requests. It is extracted from the webserver package so other callers (MCP server, scheduler, CLI) can reuse the same borrower semantics without importing the full web layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache holds one shared *plugins.Manager for synchronous callers, reopened when config changes. Callers Borrow the manager and must call the returned release func when done; a manager retired by Reload stays open until its last borrower releases it, so an in-flight request never observes a closed manager. Async work opens its own manager and does not use this cache.

func New

func New(cfg *config.File) *Cache

New returns a Cache initialised with cfg. The first Borrow opens the manager lazily.

func (*Cache) Borrow

func (c *Cache) Borrow() (*plugins.Manager, func())

Borrow returns the current shared manager and a release func the caller MUST invoke (via defer) when finished. The manager is guaranteed open until the release func runs, even across a concurrent Reload. Returns (nil, no-op) if the manager cannot be opened; callers must tolerate nil.

func (*Cache) Close

func (c *Cache) Close()

Close shuts down all managers held by the cache. Safe to call multiple times.

func (*Cache) Reload

func (c *Cache) Reload(cfg *config.File)

Reload swaps in a freshly opened manager built from cfg. The previous manager is closed immediately if it has no active borrowers; otherwise the last release() closes it.

Jump to

Keyboard shortcuts

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