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

Add support for DiscardPerSubject stream option #124

Merged
merged 2 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions controllers/jetstream/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,10 @@ func createStream(ctx context.Context, c jsmClient, spec apis.StreamSpec) (err e
opts = append(opts, jsm.DenyDelete())
}

if spec.DiscardPerSubject {
opts = append(opts, jsm.DiscardNewPerSubject())
}

_, err = c.NewStream(ctx, spec.Name, opts)
return err
}
Expand Down Expand Up @@ -447,10 +451,12 @@ func updateStream(ctx context.Context, c jsmClient, spec apis.StreamSpec) (err e
MaxConsumers: spec.MaxConsumers,
MaxMsgs: int64(spec.MaxMsgs),
MaxBytes: int64(spec.MaxBytes),
MaxMsgsPer: int64(spec.MaxMsgsPerSubject),
MaxAge: maxAge,
MaxMsgSize: int32(spec.MaxMsgSize),
Storage: storage,
Discard: discard,
DiscardNewPer: spec.DiscardPerSubject,
Replicas: spec.Replicas,
NoAck: spec.NoAck,
Duplicates: duplicates,
Expand Down
4 changes: 4 additions & 0 deletions deploy/crds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,10 @@ spec:
description: When true, restricts the ability to delete messages from a stream via the API. Cannot be changed once set to true.
type: boolean
default: false
discardPerSubject:
description: Allows to discard messages on a subject basis.
type: boolean
default: false
status:
type: object
properties:
Expand Down
1 change: 1 addition & 0 deletions pkg/jetstream/apis/jetstream/v1beta2/streamtypes.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type StreamSpec struct {
Creds string `json:"creds"`
DenyDelete bool `json:"denyDelete"`
Description string `json:"description"`
DiscardPerSubject bool `json:"discardPerSubject"`
PreventDelete bool `json:"preventDelete"`
PreventUpdate bool `json:"preventUpdate"`
Discard string `json:"discard"`
Expand Down