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

Concurrent access issues with plugins #90

Open
hlsgaosheng opened this issue Sep 11, 2024 · 0 comments
Open

Concurrent access issues with plugins #90

hlsgaosheng opened this issue Sep 11, 2024 · 0 comments

Comments

@hlsgaosheng
Copy link

hlsgaosheng commented Sep 11, 2024

Using go routine to frequently call this method causes the service to crash.

package main
import (
"context"

"github.com/benthosdev/benthos/v4/public/service"

// Import only required Benthos components, switch with `components/all` for
// all standard components.
_ "github.com/benthosdev/benthos/v4/public/components/io"
_ "github.com/benthosdev/benthos/v4/public/components/pure"

)

func main() {
panicOnErr := func(err error) {
if err != nil {
panic(err)
}
}

builder := service.NewStreamBuilder()

// Set the full Benthos configuration of the stream.
err := builder.SetYAML(`

input:
generate:
count: 1
interval: 1ms
mapping: 'root = "hello world"'

processors:
- mapping: 'root = content().uppercase()'

output:
stdout: {}

logger:
level: none
`)
panicOnErr(err)

// Build a stream with our configured components.
stream, err := builder.Build()
panicOnErr(err)

// And run it, blocking until it gracefully terminates once the generate
// input has generated a message and it has flushed through the stream.
err = stream.Run(context.Background())
panicOnErr(err)

}

How to solve this problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant