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

strict_mode top-level config option #166

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

strict_mode top-level config option #166

wants to merge 5 commits into from

Conversation

jem-davies
Copy link
Collaborator

No description provided.

@jem-davies jem-davies changed the title draft strictMode on streamBuilder strict_mode top-level config option Nov 17, 2024
@jem-davies jem-davies marked this pull request as ready for review November 17, 2024 19:14
Copy link
Collaborator

@gregfurman gregfurman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice man. Left some comments

@@ -89,6 +90,7 @@ func NewStreamBuilder() *StreamBuilder {
configSpec: tmpSpec,
env: globalEnvironment,
envVarLookupFn: os.LookupEnv,
strictMode: false,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this'll be false by default so unsure this is necessary. See how lintingDisabled is never set.

public/service/stream_builder.go Show resolved Hide resolved

Introduced in v1.4.0.

The default behavior of Bento is to attempt to send messages that have errored to the configured sink. The `strict_mode` option can be set to `true` to override this default behavior of Bento, and instead will reject any message batches with messages that have errors in them. Ultimately this will propagate a Nack to the input layer, which then depending on the component configured will either be handled or the message will be reprocessed from scratch.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The default behavior of Bento is to attempt to send messages that have errored to the configured sink. The `strict_mode` option can be set to `true` to override this default behavior of Bento, and instead will reject any message batches with messages that have errors in them. Ultimately this will propagate a Nack to the input layer, which then depending on the component configured will either be handled or the message will be reprocessed from scratch.
When `strict_mode` is set to `true`, Bento will reject all batches containing messages with errors, propagating a `nack` to the input layer. The input component's `nack` behaviour will then determine how these rejected messages are handled, otherwise re-processing them from scratch.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great explanation. Think we simplify a bit though

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated - think that we should keep the first sentence for context - rewrote the other sentences - with the suggestion in mind.

Comment on lines 270 to 286
func (w *AsyncWriter) getStrictMode() bool {
v := reflect.ValueOf(w.mgr)

if v.Kind() == reflect.Pointer && !v.IsNil() {
v = v.Elem()
}

if v.Kind() == reflect.Struct {
field := v.FieldByName("StrictMode")
if field.IsValid() && field.Kind() == reflect.Bool {
return field.Bool()
}
}

return false
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come we are using reflect here?

return nil
})
if hasErrors {
w.log.Error("Failed to send message to %v: message batch contains errors\n", w.typeStr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the \n is necessary

Suggested change
w.log.Error("Failed to send message to %v: message batch contains errors\n", w.typeStr)
w.log.Error("Failed to send message to %v: message batch contains errors", w.typeStr)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other calls in this func to w.log.Error - do have a \n.

@@ -59,6 +61,7 @@ func observabilityFields() docs.FieldSpecs {
}),
docs.FieldString(fieldSystemCloseDelay, "A period of time to wait for metrics and traces to be pulled or pushed from the process.").HasDefault("0s"),
docs.FieldString(fieldSystemCloseTimeout, "The maximum period of time to wait for a clean shutdown. If this time is exceeded Bento will forcefully close.").HasDefault("20s"),
docs.FieldBool(fieldStrictMode, "Set strict_mode to true to override the default behavior of sending messages batches that have errored messages to the configured sink, and instead propagate a nack back to the source.").HasDefault(false).Advanced().AtVersion("1.4.0"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
docs.FieldBool(fieldStrictMode, "Set strict_mode to true to override the default behavior of sending messages batches that have errored messages to the configured sink, and instead propagate a nack back to the source.").HasDefault(false).Advanced().AtVersion("1.4.0"),
docs.FieldBool(fieldStrictMode, "Set `strict_mode` to `true` to override the default behavior of sending messages batches containing errored messages to the `output` layer, instead rejecting the batch and propagating a `nack` back to the source.").HasDefault(false).Advanced().AtVersion("1.4.0"),

Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
Signed-off-by: Jem Davies <[email protected]>
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

Successfully merging this pull request may close these issues.

2 participants