Enhance NATS configuration and error handling. Introduce stream limits and consumer rules in configuration files. Refactor message processing to handle permanent errors. Update README and development configuration to reflect changes. Add tests for new error handling mechanisms.

This commit is contained in:
windyboy
2025-11-14 21:42:04 +08:00
parent a574cfcf27
commit 9cce4610b6
13 changed files with 510 additions and 57 deletions
+39
View File
@@ -0,0 +1,39 @@
package app
import "errors"
// PermanentError indicates a failure that should not be retried.
type PermanentError struct {
err error
}
// Error implements the error interface.
func (e *PermanentError) Error() string {
if e == nil || e.err == nil {
return ""
}
return e.err.Error()
}
// Unwrap allows errors.Unwrap/Is/As to inspect the underlying error.
func (e *PermanentError) Unwrap() error {
if e == nil {
return nil
}
return e.err
}
// Permanent wraps err to mark it as non-retriable.
func Permanent(err error) error {
if err == nil {
return nil
}
return &PermanentError{err: err}
}
// IsPermanent reports whether the error or any wrapped error is permanent.
func IsPermanent(err error) bool {
var target *PermanentError
return errors.As(err, &target)
}