{"modulePath":"github.com/GoCodeAlone/workflow","version":"v0.87.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package state\n\nPackage state provides persistent StateStore implementations for the platform abstraction layer. It includes SQLite for single-node/local development and PostgreSQL for production multi-node deployments.\n\n## Types\n\n```go\ntype DriftReport struct {\n\t// ID is the database identifier (set after save).\n\tID int64 `json:\"id\"`\n\n\t// ContextPath is the hierarchical context path of the resource.\n\tContextPath string `json:\"contextPath\"`\n\n\t// ResourceName is the name of the resource that drifted.\n\tResourceName string `json:\"resourceName\"`\n\n\t// ResourceType is the provider-specific resource type.\n\tResourceType string `json:\"resourceType\"`\n\n\t// Tier is the infrastructure tier the resource belongs to.\n\tTier platform.Tier `json:\"tier\"`\n\n\t// DriftType classifies the drift: \"changed\", \"added\", \"removed\".\n\tDriftType string `json:\"driftType\"`\n\n\t// Expected is the desired state properties from the state store.\n\tExpected map[string]any `json:\"expected\"`\n\n\t// Actual is the live state properties read from the provider.\n\tActual map[string]any `json:\"actual\"`\n\n\t// Diffs contains the individual field differences.\n\tDiffs []platform.DiffEntry `json:\"diffs\"`\n\n\t// DetectedAt is when the drift was detected.\n\tDetectedAt time.Time `json:\"detectedAt\"`\n\n\t// ResolvedAt is when the drift was remediated (nil if unresolved).\n\tResolvedAt *time.Time `json:\"resolvedAt,omitempty\"`\n\n\t// ResolvedBy identifies who or what resolved the drift.\n\tResolvedBy string `json:\"resolvedBy,omitempty\"`\n}\n```\nDriftReport represents the result of a drift detection check for a single resource.\n\n```go\ntype SQLiteStore struct {\n\t// contains filtered or unexported fields\n}\n```\nSQLiteStore implements platform.StateStore using an SQLite database. It is suitable for single-node deployments and local development.\n\n```go\nfunc NewSQLiteStore(dsn string) (*SQLiteStore, error)\n```\nNewSQLiteStore creates a new SQLite-backed state store. The dsn parameter is the path to the SQLite database file. Use \":memory:\" for an in-memory database (useful for testing).\n\n```go\nfunc (s *SQLiteStore) AddDependency(ctx context.Context, dep platform.DependencyRef) error\n```\nAddDependency records a cross-resource or cross-tier dependency.\n\n```go\nfunc (s *SQLiteStore) Close() error\n```\nClose closes the underlying database connection.\n\n```go\nfunc (s *SQLiteStore) DeleteResource(ctx context.Context, contextPath, resourceName string) error\n```\nDeleteResource removes a resource from state.\n\n```go\nfunc (s *SQLiteStore) Dependencies(ctx context.Context, contextPath, resourceName string) ([]platform.DependencyRef, error)\n```\nDependencies returns dependency references for resources that depend on the given resource.\n\n```go\nfunc (s *SQLiteStore) GetPlan(ctx context.Context, planID string) (*platform.Plan, error)\n```\nGetPlan retrieves an execution plan by its ID.\n\n```go\nfunc (s *SQLiteStore) GetResource(ctx context.Context, contextPath, resourceName string) (*platform.ResourceOutput, error)\n```\nGetResource retrieves a resource's state by context path and resource name.\n\n```go\nfunc (s *SQLiteStore) ListDriftReports(ctx context.Context, contextPath string, limit int) ([]*DriftReport, error)\n```\nListDriftReports returns drift reports for a context path, ordered by detection time descending.\n\n```go\nfunc (s *SQLiteStore) ListPlans(ctx context.Context, contextPath string, limit int) ([]*platform.Plan, error)\n```\nListPlans lists plans for a context path, ordered by creation time descending.\n\n```go\nfunc (s *SQLiteStore) ListResources(ctx context.Context, contextPath string) ([]*platform.ResourceOutput, error)\n```\nListResources returns all resources in a context path.\n\n```go\nfunc (s *SQLiteStore) Lock(ctx context.Context, contextPath string, ttl time.Duration) (platform.LockHandle, error)\n```\nLock acquires an advisory lock for a context path. SQLite advisory locks are emulated using a database row and a process-level mutex.\n\n```go\nfunc (s *SQLiteStore) SaveDriftReport(ctx context.Context, report *DriftReport) error\n```\nSaveDriftReport persists a drift detection report.\n\n```go\nfunc (s *SQLiteStore) SavePlan(ctx context.Context, plan *platform.Plan) error\n```\nSavePlan persists an execution plan.\n\n```go\nfunc (s *SQLiteStore) SaveResource(ctx context.Context, contextPath string, output *platform.ResourceOutput) error\n```\nSaveResource persists the state of a resource within a context path.\n\n","path":"github.com/GoCodeAlone/workflow/platform/state","name":"state","synopsis":"Package state provides persistent StateStore implementations for the platform abstraction layer.","isRedistributable":true}
