Skip to content

Commit

Permalink
fix: fix BatchAbleSink configure (#3515)
Browse files Browse the repository at this point in the history
Signed-off-by: Song Gao <[email protected]>
  • Loading branch information
Yisaer authored Jan 16, 2025
1 parent 85a31af commit f3cb876
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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 @@ package node
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 @@ func resendDataToSink(ctx api.StreamContext, sink api.Sink, outData interface{},
}
}

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 @@ func getSink(name string, action map[string]interface{}) (api.Sink, error) {
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)
}
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

0 comments on commit f3cb876

Please sign in to comment.