batch: dont expose kvdb.RwTx in batch.SchedulerOptions

Currently, a few of the graph KVStore methods take the
`batch.SchedulerOptions` param. This is only used to set the LazyAdd
option. A SchedulerOption is a functional option that takes a
`batch.Request` which has bolt-specific fields in it. This commit
restructures things a bit such that the `batch.Request` type is no
longer part of the `batch.SchedulerOptions` - this will make it easier
to implement the graph store with a different DB backend.
This commit is contained in:
Elle Mouton committed 2025-05-22 14:14:40 +02:00
1 parent 5d7c6c4b60
commit 11b27f07da
3 files changed
+40 -23

No files matched your search

+5 -1
View File
@@ -43,6 +43,10 @@ func NewTimeScheduler(db kvdb.Backend, locker sync.Locker,
//
// NOTE: Part of the Scheduler interface.
func (s *TimeScheduler) Execute(r *Request) error {
if r.Opts == nil {
r.Opts = NewDefaultSchedulerOpts()
}
req := request{
Request: r,
errChan: make(chan error, 1),
@@ -62,7 +66,7 @@ func (s *TimeScheduler) Execute(r *Request) error {
s.b.reqs = append(s.b.reqs, &req)
// If this is a non-lazy request, we'll execute the batch immediately.
if !r.lazy {
if !r.Opts.lazy {
go s.b.trigger()
}