Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap builtin processors in middleware in examples #1748

Merged
merged 4 commits into from
Aug 6, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package avro

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/avro/z_examples_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package base64

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/base64/z_examples_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package custom

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/custom/z_examples_test.go

This file was deleted.

15 changes: 15 additions & 0 deletions pkg/plugin/processor/builtin/impl/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/Masterminds/sprig/v3"
"github.com/conduitio/conduit-commons/config"
"github.com/conduitio/conduit-commons/lang"
"github.com/conduitio/conduit-commons/opencdc"
sdk "github.com/conduitio/conduit-processor-sdk"
"github.com/conduitio/conduit/pkg/foundation/cerrors"
Expand Down Expand Up @@ -100,3 +101,17 @@ func (p *errorProcessor) errorMessage(record opencdc.Record) string {
}
return buf.String()
}

func (*errorProcessor) MiddlewareOptions() []sdk.ProcessorMiddlewareOption {
// disable schema middleware by default
return []sdk.ProcessorMiddlewareOption{
sdk.ProcessorWithSchemaEncodeConfig{
PayloadEnabled: lang.Ptr(false),
KeyEnabled: lang.Ptr(false),
},
sdk.ProcessorWithSchemaDecodeConfig{
PayloadEnabled: lang.Ptr(false),
KeyEnabled: lang.Ptr(false),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package field

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/field/z_examples_test.go

This file was deleted.

15 changes: 15 additions & 0 deletions pkg/plugin/processor/builtin/impl/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"context"

"github.com/conduitio/conduit-commons/config"
"github.com/conduitio/conduit-commons/lang"
"github.com/conduitio/conduit-commons/opencdc"
sdk "github.com/conduitio/conduit-processor-sdk"
"github.com/conduitio/conduit/pkg/foundation/log"
Expand Down Expand Up @@ -54,3 +55,17 @@ func (p *filterProcessor) Process(_ context.Context, records []opencdc.Record) [
}
return out
}

func (*filterProcessor) MiddlewareOptions() []sdk.ProcessorMiddlewareOption {
// disable schema middleware by default
return []sdk.ProcessorMiddlewareOption{
sdk.ProcessorWithSchemaEncodeConfig{
PayloadEnabled: lang.Ptr(false),
KeyEnabled: lang.Ptr(false),
},
sdk.ProcessorWithSchemaDecodeConfig{
PayloadEnabled: lang.Ptr(false),
KeyEnabled: lang.Ptr(false),
},
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package json

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/json/z_examples_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package unwrap

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/unwrap/z_examples_test.go

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package webhook

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
20 changes: 0 additions & 20 deletions pkg/plugin/processor/builtin/impl/webhook/z_examples_test.go

This file was deleted.

11 changes: 8 additions & 3 deletions pkg/plugin/processor/builtin/impl/z_examples_exporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build export_processors
// This file is here to export processor specifications. It's named with a "z_"
// prefix to ensure it's processed last by go generate.

//go:generate env EXPORT_PROCESSORS=true go test -count=1 -tags export_processors .

package impl

Expand All @@ -29,6 +32,8 @@ func TestMain(m *testing.M) {
os.Exit(code)
}

// tests passed, export the processors
exampleutil.ExportProcessors()
if os.Getenv("EXPORT_PROCESSORS") == "true" {
// tests passed and env var is included, export the processors
exampleutil.ExportProcessors()
}
}
Loading