Skip to content
Open
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
42 changes: 42 additions & 0 deletions internal/impl/pure/processor_exit.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2025 Redpanda Data, Inc.

package pure

import (
"context"
"os"

"github.com/redpanda-data/benthos/v4/public/service"
)

func init() {
spec := service.NewConfigSpec().
Categories("Utility").
Beta().
Summary(`Exit the process with a code.`).
Field(service.NewIntField("").Default(0))
service.MustRegisterProcessor(
"exit", spec,
func(conf *service.ParsedConfig, res *service.Resources) (service.Processor, error) {
exitCode, err := conf.FieldInt()
if err != nil {
return nil, err
}

return &exitProcessor{exitCode}, nil
})
}

type exitProcessor struct {
exitCode int
}

func (l *exitProcessor) Process(ctx context.Context, msg *service.Message) (service.MessageBatch, error) {
os.Exit(l.exitCode)

return nil, nil
}

func (l *exitProcessor) Close(ctx context.Context) error {
return nil
}