-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Builtin processors refactoring, housekeeping (#1402)
* refactor builtin processors, generate specs into separate files * move processors into folder impl * go mod tidy * add example summaries * add example summaries * fix name of avro.decode processor * add example summaries * regenerate specs * update default registry * update default registry: fix tests, linter, regenerate * dep upgrades * refactorings * move json encode processor to impl/json * rename field.subset.exclude to field.exclude * rename constructor for unwrap.debezium processor * regenerate specs * dep downgrades --------- Co-authored-by: Haris Osmanagic <[email protected]>
- Loading branch information
1 parent
95e1a55
commit d2c1b77
Showing
129 changed files
with
2,888 additions
and
2,307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
pkg/plugin/processor/builtin/impl/avro/decode_examples_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// Copyright © 2024 Meroxa, Inc. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:build !integration | ||
|
||
package avro | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/conduitio/conduit-commons/opencdc" | ||
sdk "github.com/conduitio/conduit-processor-sdk" | ||
"github.com/conduitio/conduit/pkg/foundation/log" | ||
"github.com/conduitio/conduit/pkg/plugin/processor/builtin/impl/avro/schemaregistry" | ||
"github.com/conduitio/conduit/pkg/plugin/processor/builtin/internal/exampleutil" | ||
"github.com/lovromazgon/franz-go/pkg/sr" | ||
) | ||
|
||
//nolint:govet // a more descriptive example description | ||
func ExampleDecodeProcessor() { | ||
url, cleanup := schemaregistry.ExampleSchemaRegistryURL("ExampleDecodeProcessor", 54322) | ||
defer cleanup() | ||
|
||
client, err := schemaregistry.NewClient(log.Nop(), sr.URLs(url)) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to create schema registry client: %v", err)) | ||
} | ||
|
||
_, err = client.CreateSchema(context.Background(), "example-decode", sr.Schema{ | ||
Type: sr.TypeAvro, | ||
Schema: ` | ||
{ | ||
"type":"record", | ||
"name":"record", | ||
"fields":[ | ||
{"name":"myString","type":"string"}, | ||
{"name":"myInt","type":"int"} | ||
] | ||
}`, | ||
}) | ||
if err != nil { | ||
panic(fmt.Sprintf("failed to create schema: %v", err)) | ||
} | ||
|
||
p := NewDecodeProcessor(log.Nop()) | ||
|
||
exampleutil.RunExample(p, exampleutil.Example{ | ||
Summary: "Decode a record field in Avro format", | ||
Description: `This example shows the usage of the ` + "`avro.decode`" + ` processor. | ||
The processor decodes the record's` + "`.Key`" + ` field using the schema that is | ||
downloaded from the schema registry and needs to exist under the subject` + "`example-decode`" + `. | ||
In this example we use the following schema: | ||
` + "```json" + ` | ||
{ | ||
"type":"record", | ||
"name":"record", | ||
"fields":[ | ||
{"name":"myString","type":"string"}, | ||
{"name":"myInt","type":"int"} | ||
] | ||
} | ||
` + "```", | ||
Config: map[string]string{ | ||
"url": url, | ||
"field": ".Key", | ||
}, | ||
Have: opencdc.Record{ | ||
Position: opencdc.Position("test-position"), | ||
Operation: opencdc.OperationCreate, | ||
Metadata: map[string]string{"key1": "val1"}, | ||
Key: opencdc.RawData([]byte{0, 0, 0, 0, 1, 6, 98, 97, 114, 2}), | ||
}, | ||
Want: sdk.SingleRecord{ | ||
Position: opencdc.Position("test-position"), | ||
Operation: opencdc.OperationCreate, | ||
Metadata: map[string]string{"key1": "val1"}, | ||
Key: opencdc.StructuredData{ | ||
"myString": "bar", | ||
"myInt": 1, | ||
}, | ||
}}) | ||
|
||
// Output: | ||
// processor transformed record: | ||
// --- before | ||
// +++ after | ||
// @@ -1,12 +1,15 @@ | ||
// { | ||
// "position": "dGVzdC1wb3NpdGlvbg==", | ||
// "operation": "create", | ||
// "metadata": { | ||
// "key1": "val1" | ||
// }, | ||
// - "key": "\u0000\u0000\u0000\u0000\u0001\u0006bar\u0002", | ||
// + "key": { | ||
// + "myInt": 1, | ||
// + "myString": "bar" | ||
// + }, | ||
// "payload": { | ||
// "before": null, | ||
// "after": null | ||
// } | ||
// } | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.