Documentation
¶
Overview ¶
Package localstate stores runner identity, registrations, and workspace locks outside source repositories.
Index ¶
- func CanonicalWorkspace(path string) (string, error)
- type HostIdentity
- type LockHeldError
- type LockMetadata
- type Registration
- type Store
- func (s *Store) AcquireWorkspaceLock(workspace string, metadata LockMetadata) (*WorkspaceLock, error)
- func (s *Store) DeleteRegistration(server, workspace, expectedRunnerID string) (bool, error)
- func (s *Store) LoadOrCreateHostIdentity() (HostIdentity, error)
- func (s *Store) LoadRegistration(server, workspace string) (Registration, bool, error)
- func (s *Store) ReadWorkspaceLockMetadata(workspace string) (LockMetadata, bool, error)
- func (s *Store) Registrations() ([]Registration, error)
- func (s *Store) Root() string
- func (s *Store) SaveRegistration(registration Registration) error
- func (s *Store) WorkspaceLockHeld(workspace string) (bool, error)
- func (s *Store) WorkspaceLockPath(workspace string) string
- type WorkspaceLock
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanonicalWorkspace ¶
CanonicalWorkspace resolves an existing workspace to a stable absolute path.
Types ¶
type HostIdentity ¶
type HostIdentity struct {
Version int `json:"version"`
InstanceID string `json:"instanceId"`
CreatedAt time.Time `json:"createdAt"`
}
HostIdentity is the stable, non-secret identifier for one local Kodelet installation.
type LockHeldError ¶
type LockHeldError struct {
Path string
Metadata LockMetadata
}
LockHeldError reports diagnostics from an already-running workspace runner.
func (*LockHeldError) Error ¶
func (e *LockHeldError) Error() string
type LockMetadata ¶
type LockMetadata struct {
Version int `json:"version"`
PID int `json:"pid"`
Hostname string `json:"hostname"`
Workspace string `json:"workspace"`
Server string `json:"server"`
RunnerID string `json:"runnerId,omitempty"`
DisplayName string `json:"displayName,omitempty"`
StartedAt time.Time `json:"startedAt"`
StoppedAt *time.Time `json:"stoppedAt,omitempty"`
}
LockMetadata is diagnostic process information stored in the advisory lock file.
type Registration ¶
type Registration struct {
Version int `json:"version"`
Server string `json:"server"`
Workspace string `json:"workspace"`
RunnerID string `json:"runnerId"`
DisplayName string `json:"displayName,omitempty"`
UpdatedAt time.Time `json:"updatedAt"`
}
Registration caches one control-plane-assigned runner identity for a host workspace.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store owns runner-local state rooted below the Kodelet user-state directory.
func NewStoreAt ¶
NewStoreAt opens a runner-local state directory at an explicit path.
func (*Store) AcquireWorkspaceLock ¶
func (s *Store) AcquireWorkspaceLock(workspace string, metadata LockMetadata) (*WorkspaceLock, error)
AcquireWorkspaceLock acquires the non-blocking advisory lock for a canonical workspace.
func (*Store) DeleteRegistration ¶
DeleteRegistration removes a cached registration only when it still contains the expected runner ID.
func (*Store) LoadOrCreateHostIdentity ¶
func (s *Store) LoadOrCreateHostIdentity() (HostIdentity, error)
LoadOrCreateHostIdentity returns the stable host instance ID, creating it atomically when absent.
func (*Store) LoadRegistration ¶
func (s *Store) LoadRegistration(server, workspace string) (Registration, bool, error)
LoadRegistration returns a cached stable runner ID for a server and canonical workspace.
func (*Store) ReadWorkspaceLockMetadata ¶
func (s *Store) ReadWorkspaceLockMetadata(workspace string) (LockMetadata, bool, error)
ReadWorkspaceLockMetadata reads the latest diagnostic lock metadata without acquiring the lock.
func (*Store) Registrations ¶
func (s *Store) Registrations() ([]Registration, error)
Registrations lists every locally cached control-plane registration.
func (*Store) SaveRegistration ¶
func (s *Store) SaveRegistration(registration Registration) error
SaveRegistration atomically updates a cached stable runner ID.
func (*Store) WorkspaceLockHeld ¶
WorkspaceLockHeld reports whether another open file description currently owns the advisory lock for a workspace. A stale diagnostic file without a live lock returns false.
func (*Store) WorkspaceLockPath ¶
WorkspaceLockPath returns the diagnostic lock-file path for a canonical workspace.
type WorkspaceLock ¶
type WorkspaceLock struct {
// contains filtered or unexported fields
}
WorkspaceLock holds the OS-level advisory lock for one canonical workspace.
func (*WorkspaceLock) Close ¶
func (l *WorkspaceLock) Close() error
Close records a stop time and releases the advisory lock.
func (*WorkspaceLock) Metadata ¶
func (l *WorkspaceLock) Metadata() LockMetadata
Metadata returns the latest metadata written by this process.
func (*WorkspaceLock) Path ¶
func (l *WorkspaceLock) Path() string
Path returns the diagnostic lock-file path.
func (*WorkspaceLock) WriteMetadata ¶
func (l *WorkspaceLock) WriteMetadata(metadata LockMetadata) error
WriteMetadata updates the diagnostic JSON while retaining the advisory lock.