-
Notifications
You must be signed in to change notification settings - Fork 853
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
Integration with web architecture #1727
Comments
Hey @gaoshenga, I'm not sure I have enough information to answer your question. Which web framework are you referring to? I'm guessing you might be interested in building a custom |
Hello @mihaitodor, thank you for your help. I'm ready to integrate the benthos plug-in with the GIN framework. I want to start the benthos instance by calling the bentho method to read the local configuration file. Instead of running a command like the benthos command "benthos -c./config.yaml" to start. |
OK, have a look at the |
Thank you. I tried the case you provided just now. This case is the result of just one run. I want to execute a local file through benthos, and then launch a benthos instance. Is there any other way to do it? |
Not sure I follow... I think that example does exactly what you're asking for, assuming the input that you configure for Benthos terminates (basically |
Thank you very much. Your answer has given me a deeper understanding. It seems impossible to monitor the state of the stream with StreamBuilderConfig. It would be nice if we could monitor the state of streams like the streams rest api. |
Not sure what issue you bumped into, but here's a slightly modified version of that example I linked above: 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"
_ "github.com/benthosdev/benthos/v4/public/components/prometheus"
)
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(`
http:
address: 0.0.0.0:4195
enabled: true
input:
generate:
count: 0
interval: 1s
mapping: 'root = "hello world"'
processors:
- mapping: 'root = content().uppercase()'
output:
stdout: {}
logger:
level: none
metrics:
prometheus: {}
`)
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)
} If I run this, I'm able to do |
I see. I want to create a web project that can configure multiple processing data streams through the front page, each stream being a separate configuration file. You can start, stop, and monitor the status of each stream dynamically via benthos. This is my first experience with benthos. Thank you for your wonderful answer. |
Hello, how do you integrate benthos with the web framework?
The text was updated successfully, but these errors were encountered: