Documentation
¶
Index ¶
- func Initialize(db *sql.DB, schema string) error
- type Option
- type SQLiteStorage
- func (s *SQLiteStorage) DeleteState(id string) error
- func (s *SQLiteStorage) GenerateSchema() string
- func (s *SQLiteStorage) LoadState(id string) ([]workflow.Place, map[string]interface{}, error)
- func (s *SQLiteStorage) SaveState(id string, places []workflow.Place, context map[string]interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(*SQLiteStorage)
Option is a function that configures a SQLiteStorage.
func WithCustomFields ¶
WithCustomFields defines the schema for additional application-specific data to be stored. The map key is the key used in the workflow's context map. The map value is the full SQL column definition (e.g., "title TEXT", "amount INTEGER NOT NULL").
func WithIDColumn ¶
WithIDColumn sets the name of the column used to store the workflow ID. Default: "id".
func WithStateColumn ¶
WithStateColumn sets the name of the column used to store the workflow's current places (state). Default: "state".
type SQLiteStorage ¶
type SQLiteStorage struct {
// contains filtered or unexported fields
}
SQLiteStorage provides a persistent storage implementation using SQLite. It is highly configurable to allow for custom table and column names, as well as storing arbitrary application-specific data alongside the workflow state.
func NewSQLiteStorage ¶
func NewSQLiteStorage(db *sql.DB, opts ...Option) (*SQLiteStorage, error)
NewSQLiteStorage creates a new SQLiteStorage with the given options.
func (*SQLiteStorage) DeleteState ¶
func (s *SQLiteStorage) DeleteState(id string) error
DeleteState removes a workflow's state from the database.
func (*SQLiteStorage) GenerateSchema ¶
func (s *SQLiteStorage) GenerateSchema() string
GenerateSchema returns the `CREATE TABLE` SQL statement based on the storage configuration. This allows the user to see, modify, or use the schema with a separate migration tool.