starting to play with goqite for queuing
This commit is contained in:
parent
fcf80ec5fe
commit
2afad5d761
25
internal/database/migrations/20240428201449_goqite.sql
Normal file
25
internal/database/migrations/20240428201449_goqite.sql
Normal 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
|
23
internal/services/queue.go
Normal file
23
internal/services/queue.go
Normal 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",
|
||||
}),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user