Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions internal/topo/node/sink_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import (
"fmt"
"sync"
"time"

"github.com/lf-edge/ekuiper/internal/binder/io"
"github.com/lf-edge/ekuiper/internal/conf"
Expand Down Expand Up @@ -554,6 +555,11 @@
}
}

type batchConf struct {
BatchSize int `json:"batchSize"`
LingerInterval time.Duration `json:"lingerInterval"`
}

func getSink(name string, action map[string]interface{}) (api.Sink, error) {
var (
s api.Sink
Expand All @@ -566,6 +572,11 @@
if err != nil {
return nil, err
}
if bas, ok := s.(api.BatchAbleSink); ok {
bc := batchConf{}
cast.MapToStruct(newAction, &bc)
bas.ConfigureBatch(bc.BatchSize, bc.LingerInterval)
}

Check warning on line 579 in internal/topo/node/sink_node.go

View check run for this annotation

Codecov / codecov/patch

internal/topo/node/sink_node.go#L576-L579

Added lines #L576 - L579 were not covered by tests
return s, nil
} else {
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions internal/topo/planner/sink_planner.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package planner

import (
"fmt"
"time"

"github.com/lf-edge/ekuiper/internal/binder/io"
"github.com/lf-edge/ekuiper/internal/conf"
Expand Down Expand Up @@ -67,8 +66,7 @@ func fulfillProps(rule *api.Rule, props map[string]any) map[string]any {

// Split sink node according to the sink configuration. Return the new input emitters.
func splitSink(sink api.Sink, tp *topo.Topo, inputs []api.Emitter, sinkName string, options *api.RuleOption, sc *node.SinkConf) ([]api.Emitter, error) {
if bas, ok := sink.(api.BatchAbleSink); ok {
bas.ConfigureBatch(sc.BatchSize, time.Duration(sc.LingerInterval))
if _, ok := sink.(api.BatchAbleSink); ok {
return inputs, nil
}
index := 0
Expand Down
Loading