Documentation
¶
Overview ¶
SQLiteService persists batches in SQLite: one header row in message_batches plus ordered child rows in message_batch_entries and message_batch_results. Entry params and result payloads stay verbatim JSON. Every write runs inside one transaction; child rows carry the request order in their position column.
Index ¶
- Constants
- type SQLiteService
- func (s *SQLiteService) Create(ctx context.Context, batch *models.BatchRecord) error
- func (s *SQLiteService) Delete(ctx context.Context, id string) error
- func (s *SQLiteService) Get(ctx context.Context, id string) (*models.BatchRecord, error)
- func (s *SQLiteService) List(ctx context.Context) ([]*models.BatchRecord, error)
- func (s *SQLiteService) SetLogger(l *slog.Logger)
- func (s *SQLiteService) Update(ctx context.Context, batch *models.BatchRecord) error
Constants ¶
const ( StatusInProgress = "in_progress" StatusEnded = "ended" StatusCanceled = "canceled" )
Terminal batch states: no further transitions leave them.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SQLiteService ¶ added in v0.4.0
type SQLiteService struct {
// contains filtered or unexported fields
}
SQLiteService owns MessageBatch rows and their ordered children.
func NewSQLiteService ¶ added in v0.4.0
func NewSQLiteService(database *db.Database) *SQLiteService
NewSQLiteService constructs a batches SQLiteService. Construction performs no I/O.
func (*SQLiteService) Create ¶ added in v0.4.0
func (s *SQLiteService) Create(ctx context.Context, batch *models.BatchRecord) error
Create persists a new batch: header plus ordered children in one transaction.
func (*SQLiteService) Delete ¶ added in v0.4.0
func (s *SQLiteService) Delete(ctx context.Context, id string) error
Delete removes a batch row; the foreign key cascade removes its children. Missing rows are not errors.
func (*SQLiteService) Get ¶ added in v0.4.0
func (s *SQLiteService) Get(ctx context.Context, id string) (*models.BatchRecord, error)
Get returns the batch by ID with children in position order.
func (*SQLiteService) List ¶ added in v0.4.0
func (s *SQLiteService) List(ctx context.Context) ([]*models.BatchRecord, error)
List returns all batches with children, oldest first (ID tiebreaks clock ties).
func (*SQLiteService) SetLogger ¶ added in v0.4.0
func (s *SQLiteService) SetLogger(l *slog.Logger)
SetLogger wires structured logging (called once from server.New).
func (*SQLiteService) Update ¶ added in v0.4.0
func (s *SQLiteService) Update(ctx context.Context, batch *models.BatchRecord) error
Update rewrites a batch: header plus replaced children in one transaction. Missing rows return not found.