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:
3 files changed
+40
-23
No files matched your search
+5
-1
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user