Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheStats ¶
CacheStats summarizes cache activity counters.
type RepoAccessCache ¶
type RepoAccessCache struct {
// contains filtered or unexported fields
}
RepoAccessCache caches repository metadata related to lockdown checks so that multiple tools can reuse the same access information safely across goroutines.
func GetInstance ¶
func GetInstance(client *githubv4.Client, opts ...RepoAccessOption) *RepoAccessCache
GetInstance returns the singleton instance of RepoAccessCache. It initializes the instance on first call with the provided client and options. Subsequent calls ignore the client and options parameters and return the existing instance. This is the preferred way to access the cache in production code.
func (*RepoAccessCache) IsSafeContent ¶
func (c *RepoAccessCache) IsSafeContent(ctx context.Context, username, owner, repo string) (bool, error)
IsSafeContent determines if the specified user can safely access the requested repository content. Safe access applies when any of the following is true: - the content was created by a trusted bot; - the author currently has push access to the repository; - the repository is private; - the content was created by the viewer.
func (*RepoAccessCache) SetLogger ¶
func (c *RepoAccessCache) SetLogger(logger *slog.Logger)
SetLogger updates the logger used for cache diagnostics.
type RepoAccessInfo ¶
RepoAccessInfo captures repository metadata needed for lockdown decisions.
type RepoAccessOption ¶
type RepoAccessOption func(*RepoAccessCache)
RepoAccessOption configures RepoAccessCache at construction time.
func WithCacheName ¶
func WithCacheName(name string) RepoAccessOption
WithCacheName overrides the cache table name used for storing entries. This option is intended for tests that need isolated cache instances.
func WithLogger ¶
func WithLogger(logger *slog.Logger) RepoAccessOption
WithLogger sets the logger used for cache diagnostics.
func WithTTL ¶
func WithTTL(ttl time.Duration) RepoAccessOption
WithTTL overrides the default TTL applied to cache entries. A non-positive duration disables expiration.