Documentation
¶
Index ¶
- Constants
- func Debounce(ctx context.Context, in <-chan WatchEvent, delay time.Duration) <-chan []WatchEvent
- func IgnoreRuntimePath(path string) bool
- func PIDAlive(pid int) bool
- func SafeEventPath(path string) string
- type Backoff
- type DaemonState
- type DetectionMode
- type EventSink
- type Lock
- type Loop
- type RemotePoller
- type Repository
- func (r Repository) AppendEvent(event SyncDaemonEvent) error
- func (r Repository) ClearStopRequest()
- func (r Repository) Dir() string
- func (r Repository) EventsPath() string
- func (r Repository) ReadEvents(limit int) ([]SyncDaemonEvent, error)
- func (r Repository) ReadState() (DaemonState, error)
- func (r Repository) RequestStop() error
- func (r Repository) StatePath() string
- func (r Repository) StopPath() string
- func (r Repository) StopRequested() bool
- func (r Repository) WriteState(state DaemonState) error
- type RunRequest
- type SyncDaemonEvent
- type SyncExecutor
- type WatchEvent
- type Watcher
Constants ¶
View Source
const ( StateSchemaVersion = "pinax.sync_daemon.state.v1" EventSchemaVersion = "pinax.sync_daemon.event.v1" StatusStopped = "stopped" StatusRunning = "running" StatusDegraded = "degraded" StatusStopping = "stopping" StatusConflict = "conflict_required" )
Variables ¶
This section is empty.
Functions ¶
func Debounce ¶
func Debounce(ctx context.Context, in <-chan WatchEvent, delay time.Duration) <-chan []WatchEvent
func IgnoreRuntimePath ¶
func SafeEventPath ¶
Types ¶
type DaemonState ¶
type DaemonState struct {
SchemaVersion string `json:"schema_version"`
Status string `json:"status"`
Target string `json:"target"`
PID int `json:"pid,omitempty"`
DetectionMode string `json:"detection_mode"`
LocalDirty bool `json:"local_dirty"`
LocalHash string `json:"local_hash,omitempty"`
RemoteRevision string `json:"remote_revision,omitempty"`
LastPollAt string `json:"last_poll_at,omitempty"`
LastSyncAt string `json:"last_sync_at,omitempty"`
LastErrorCode string `json:"last_error_code,omitempty"`
NextRetryAt string `json:"next_retry_at,omitempty"`
Message string `json:"message,omitempty"`
StartedAt string `json:"started_at,omitempty"`
UpdatedAt string `json:"updated_at"`
}
func NewState ¶
func NewState(target string, pid int, mode DetectionMode, status string) DaemonState
type DetectionMode ¶
type DetectionMode string
const ( DetectionWatch DetectionMode = "watch" DetectionScan DetectionMode = "scan" )
type EventSink ¶
type EventSink func(SyncDaemonEvent)
EventSink receives the same redacted daemon events that are persisted locally.
type Loop ¶
type Loop struct {
Repo Repository
Target string
Poller RemotePoller
Executor SyncExecutor
PollInterval time.Duration
SyncTimeout time.Duration
Backoff Backoff
EventSink EventSink
}
func (*Loop) RunOnceWithTrigger ¶
type Repository ¶
type Repository struct{ Root string }
func NewRepository ¶
func NewRepository(root string) Repository
func (Repository) AppendEvent ¶
func (r Repository) AppendEvent(event SyncDaemonEvent) error
func (Repository) ClearStopRequest ¶
func (r Repository) ClearStopRequest()
func (Repository) Dir ¶
func (r Repository) Dir() string
func (Repository) EventsPath ¶
func (r Repository) EventsPath() string
func (Repository) ReadEvents ¶
func (r Repository) ReadEvents(limit int) ([]SyncDaemonEvent, error)
func (Repository) ReadState ¶
func (r Repository) ReadState() (DaemonState, error)
func (Repository) RequestStop ¶
func (r Repository) RequestStop() error
func (Repository) StatePath ¶
func (r Repository) StatePath() string
func (Repository) StopPath ¶
func (r Repository) StopPath() string
func (Repository) StopRequested ¶
func (r Repository) StopRequested() bool
func (Repository) WriteState ¶
func (r Repository) WriteState(state DaemonState) error
type RunRequest ¶
type SyncDaemonEvent ¶
type SyncDaemonEvent struct {
SchemaVersion string `json:"schema_version"`
Seq int `json:"seq,omitempty"`
Type string `json:"type"`
Status string `json:"status,omitempty"`
Target string `json:"target,omitempty"`
Path string `json:"path,omitempty"`
ErrorCode string `json:"error_code,omitempty"`
Message string `json:"message,omitempty"`
Facts map[string]any `json:"facts,omitempty"`
CycleID string `json:"cycle_id,omitempty"`
Trigger string `json:"trigger,omitempty"`
Direction string `json:"direction,omitempty"`
DurationMS int64 `json:"duration_ms,omitempty"`
LocalDirty bool `json:"local_dirty,omitempty"`
RemoteRevision string `json:"remote_revision,omitempty"`
RevisionID string `json:"revision_id,omitempty"`
SyncRunID string `json:"sync_run_id,omitempty"`
RemoteWrite bool `json:"remote_write,omitempty"`
LocalWrite bool `json:"local_write,omitempty"`
CreatedAt string `json:"created_at"`
}
func NewEvent ¶
func NewEvent(eventType, status, target string) SyncDaemonEvent
func PrepareEvent ¶
func PrepareEvent(event SyncDaemonEvent) SyncDaemonEvent
type SyncExecutor ¶
type WatchEvent ¶
type WatchEvent struct{ Path string }
type Watcher ¶
type Watcher interface {
Events() <-chan WatchEvent
Errors() <-chan error
Close() error
}
func NewFSNotifyWatcher ¶
Click to show internal directories.
Click to hide internal directories.