starting to play with goqite for queuing

This commit is contained in:
James Tombleson 2024-04-29 16:31:48 -07:00
parent fcf80ec5fe
commit 2afad5d761
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,25 @@
-- +goose Up
-- +goose StatementBegin
create table goqite (
id text primary key default ('m_' || lower(hex(randomblob(16)))),
created text not null default (strftime('%Y-%m-%dT%H:%M:%fZ')),
updated text not null default (strftime('%Y-%m-%dT%H:%M:%fZ')),
queue text not null,
body blob not null,
timeout text not null default (strftime('%Y-%m-%dT%H:%M:%fZ')),
received integer not null default 0
) strict;
create trigger goqite_updated_timestamp after update on goqite begin
update goqite set updated = strftime('%Y-%m-%dT%H:%M:%fZ') where id = old.id;
end;
create index goqite_queue_created_idx on goqite (queue, created);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE goqite
DROP INDEX goqite_queue_created_idx
DROP TRIGGER goqite_updated_timestamp
-- +goose StatementEnd

View File

@ -0,0 +1,23 @@
package services
import (
"database/sql"
"github.com/maragudk/goqite"
)
type queues struct {
repos RepositoryService
RssIndex goqite.Queue
}
func NewQueues(conn *sql.DB) queues {
return queues{
repos: NewRepositoryService(conn),
RssIndex: *goqite.New(goqite.NewOpts{
DB: conn,
Name: "rss",
}),
}
}