Skip to content

Commit 3a72b2f

Browse files
authored
fix: Add backward compatibility for batch_size (#1018)
1 parent ff7a1e1 commit 3a72b2f

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

internal/servers/destination/v1/destinations.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ func (s *Server) Configure(ctx context.Context, req *pb.Configure_Request) (*pb.
3939
if err != nil {
4040
return nil, status.Errorf(codes.InvalidArgument, "failed to marshal spec: %v", err)
4141
}
42+
var pluginSpecMap map[string]any
43+
if err := json.Unmarshal(pluginSpec, &pluginSpecMap); err != nil {
44+
return nil, status.Errorf(codes.InvalidArgument, "failed to unmarshal plugin spec: %v", err)
45+
}
46+
// this is for backward compatibility
47+
if s.spec.BatchSize > 0 {
48+
pluginSpecMap["batch_size"] = s.spec.BatchSize
49+
}
50+
if s.spec.BatchSizeBytes > 0 {
51+
pluginSpecMap["batch_size_bytes"] = s.spec.BatchSizeBytes
52+
}
53+
pluginSpec, err = json.Marshal(pluginSpecMap)
54+
if err != nil {
55+
return nil, status.Errorf(codes.InvalidArgument, "failed to marshal spec: %v", err)
56+
}
4257
return &pb.Configure_Response{}, s.Plugin.Init(ctx, pluginSpec)
4358
}
4459

0 commit comments

Comments
 (0)