Skip to content

Commit

Permalink
Merge pull request #124 from weka/main
Browse files Browse the repository at this point in the history
Add support for DiscardPerSubject stream option
  • Loading branch information
wallyqs authored Jul 14, 2023
2 parents 0eb9971 + d7272ba commit 24881bc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
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

0 comments on commit 24881bc

Please sign in to comment.