support parsing item page info
This commit is contained in:
@ -9,6 +9,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.loyso.art/frx/eway/internal/entity"
|
||||
|
||||
"github.com/dgraph-io/badger/v4"
|
||||
)
|
||||
|
||||
@ -70,10 +71,10 @@ func (c queueClient) Publish(ctx context.Context, params entity.PublishParams) (
|
||||
binary.BigEndian.PutUint64(keyData[:], task.ID)
|
||||
opts := make([]putOpt, 0, 1)
|
||||
if !params.ExpiresAt.IsZero() {
|
||||
duration := params.ExpiresAt.Sub(time.Now())
|
||||
duration := time.Until(params.ExpiresAt)
|
||||
opts = append(opts, withTTL(duration))
|
||||
}
|
||||
err = c.namedClient.Put(keyData[:], tdb.asBinary(), opts...)
|
||||
err = c.Put(keyData[:], tdb.asBinary(), opts...)
|
||||
if err != nil {
|
||||
return entity.Task{}, fmt.Errorf("saving data: %w", err)
|
||||
}
|
||||
@ -83,11 +84,13 @@ func (c queueClient) Publish(ctx context.Context, params entity.PublishParams) (
|
||||
|
||||
func (c queueClient) Consume(ctx context.Context) (task entity.Task, err error) {
|
||||
err = c.db.View(func(txn *badger.Txn) error {
|
||||
iterOpts := badger.DefaultIteratorOptions
|
||||
iterOpts.PrefetchSize = 1
|
||||
iterOpts.PrefetchValues = true
|
||||
iterOpts.Prefix = c.table
|
||||
iterOpts.Reverse = false
|
||||
iterOpts := badger.IteratorOptions{
|
||||
PrefetchSize: 1,
|
||||
PrefetchValues: true,
|
||||
Reverse: false,
|
||||
AllVersions: false,
|
||||
Prefix: c.table,
|
||||
}
|
||||
iter := txn.NewIterator(iterOpts)
|
||||
defer iter.Close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user