Documentation
¶
Overview ¶
Package fileconfig provides the durable file primitives shared by authored configuration catalogs.
Index ¶
- Variables
- func EnsurePrivateDirectory(ctx context.Context, path string) error
- func IsAtomicTemporaryName(name string) bool
- func TryWithExclusiveLock(ctx context.Context, path string, action func() error) error
- func WithExclusiveLock(ctx context.Context, path string, action func() error) error
- func WriteAtomically(ctx context.Context, path string, payload []byte) error
- type ExclusiveLock
- type ParsedCache
Constants ¶
This section is empty.
Variables ¶
var ErrLockBusy = errors.New("file_config_lock_busy")
Functions ¶
func EnsurePrivateDirectory ¶
EnsurePrivateDirectory creates an application-owned directory before callers persist credential intents. Existing ancestors keep their permissions.
func IsAtomicTemporaryName ¶
IsAtomicTemporaryName reports whether name has the exact decimal suffix produced by os.CreateTemp for atomicTemporaryPattern.
func TryWithExclusiveLock ¶
TryWithExclusiveLock uses the same cross-process lock and retained sidecar, returning ErrLockBusy immediately when another owner holds it.
func WithExclusiveLock ¶
WithExclusiveLock runs action while holding an operating-system advisory lock for path. The sidecar file is intentionally retained: deleting a lock file can let two callers lock different inodes. Closing the file releases the lock even when a process exits unexpectedly.
Types ¶
type ExclusiveLock ¶
type ExclusiveLock struct {
// contains filtered or unexported fields
}
ExclusiveLock keeps ownership until Close, including after acquisition's context ends. A canceled owner must finish its workers before releasing it.
func TryAcquireExclusiveLock ¶
func TryAcquireExclusiveLock(ctx context.Context, path string) (*ExclusiveLock, error)
TryAcquireExclusiveLock returns a lifetime-owned lock. Its sidecar remains on disk so later owners always acquire the same inode.
func (*ExclusiveLock) Close ¶
func (lock *ExclusiveLock) Close() error
type ParsedCache ¶
type ParsedCache[T any] struct { // contains filtered or unexported fields }
ParsedCache reuses validated authored documents by content, never by mtime. Reading the bytes still detects external edits, replacements and corruption. Callers own their returned copy; failed decodes are never cached.