mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-17 11:24:44 -07:00
[FIXED] JetStream: return error on negative replicas count
If a stream is created or updated with a negative replicas count, and error is now returned. Same for consumers. Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
@@ -245,6 +245,9 @@ const (
|
||||
// JSRaftGeneralErrF General RAFT error string ({err})
|
||||
JSRaftGeneralErrF ErrorIdentifier = 10041
|
||||
|
||||
// JSReplicasCountCannotBeNegative replicas count cannot be negative
|
||||
JSReplicasCountCannotBeNegative ErrorIdentifier = 10133
|
||||
|
||||
// JSRestoreSubscribeFailedErrF JetStream unable to subscribe to restore snapshot {subject}: {err}
|
||||
JSRestoreSubscribeFailedErrF ErrorIdentifier = 10042
|
||||
|
||||
@@ -481,6 +484,7 @@ var (
|
||||
JSNotEnabledForAccountErr: {Code: 503, ErrCode: 10039, Description: "JetStream not enabled for account"},
|
||||
JSPeerRemapErr: {Code: 503, ErrCode: 10075, Description: "peer remap failed"},
|
||||
JSRaftGeneralErrF: {Code: 500, ErrCode: 10041, Description: "{err}"},
|
||||
JSReplicasCountCannotBeNegative: {Code: 400, ErrCode: 10133, Description: "replicas count cannot be negative"},
|
||||
JSRestoreSubscribeFailedErrF: {Code: 500, ErrCode: 10042, Description: "JetStream unable to subscribe to restore snapshot {subject}: {err}"},
|
||||
JSSequenceNotFoundErrF: {Code: 400, ErrCode: 10043, Description: "sequence {seq} not found"},
|
||||
JSSnapshotDeliverSubjectInvalidErr: {Code: 400, ErrCode: 10015, Description: "deliver subject not valid"},
|
||||
@@ -1423,6 +1427,16 @@ func NewJSRaftGeneralError(err error, opts ...ErrorOption) *ApiError {
|
||||
}
|
||||
}
|
||||
|
||||
// NewJSReplicasCountCannotBeNegativeError creates a new JSReplicasCountCannotBeNegative error: "replicas count cannot be negative"
|
||||
func NewJSReplicasCountCannotBeNegativeError(opts ...ErrorOption) *ApiError {
|
||||
eopts := parseOpts(opts)
|
||||
if ae, ok := eopts.err.(*ApiError); ok {
|
||||
return ae
|
||||
}
|
||||
|
||||
return ApiErrors[JSReplicasCountCannotBeNegative]
|
||||
}
|
||||
|
||||
// NewJSRestoreSubscribeFailedError creates a new JSRestoreSubscribeFailedErrF error: "JetStream unable to subscribe to restore snapshot {subject}: {err}"
|
||||
func NewJSRestoreSubscribeFailedError(err error, subject interface{}, opts ...ErrorOption) *ApiError {
|
||||
eopts := parseOpts(opts)
|
||||
|
||||
Reference in New Issue
Block a user