Skip to content
Snippets Groups Projects
Commit 083aaf1f authored by Pavel Antonov's avatar Pavel Antonov :asterisk:
Browse files

fix(sync): Исправлена ошибка синхронизации "received message larger than max"....

fix(sync): Исправлена ошибка синхронизации "received message larger than max". Процесс синхронизации значительно ускорен

Close #PRXS-2026
parents 9a3936be 2408d53a
No related branches found
No related tags found
No related merge requests found
package items
import "context"
type FindResultDummy struct {
Items []*Item
Total int
Error error
}
type Dummy struct {
Items
FindResult *FindResultDummy
}
func (d *Dummy) Find(_ context.Context, _, _, _ string, _ *Filter, _ ...*FindOptions) ([]*Item, int, error) {
return d.FindResult.Items, d.FindResult.Total, d.FindResult.Error
}
......@@ -128,6 +128,11 @@ func (b *BatchProcessor) Do(ctx context.Context, f func(batch []*Item) error) (i
return 0, err
}
// на случай, когда первый запрос вернул 0 элементов
if len(batch) == 0 {
break
}
if err = f(batch); err != nil {
return 0, err
}
......
package items
import (
"context"
"testing"
"git.perx.ru/perxis/perxis-go/pkg/environments"
"git.perx.ru/perxis/perxis-go/pkg/options"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestBatchProcessor(t *testing.T) {
itemssvc := &Dummy{FindResult: &FindResultDummy{Items: nil, Total: 0, Error: nil}}
b := &BatchProcessor{
Items: itemssvc,
SpaceID: "sp",
EnvID: environments.DefaultEnvironment,
CollectionID: "col",
FindOptions: &FindOptions{
Regular: true,
Hidden: true,
Templates: true,
FindOptions: *options.NewFindOptions(0, 10),
},
Filter: NewFilter("a > 5"),
}
var counter int
_, err := b.Do(context.Background(), func(batch []*Item) error { counter++; return nil })
require.NoError(t, err)
assert.Equal(t, 0, counter)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment