-
Notifications
You must be signed in to change notification settings - Fork 6
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
added support for max_bytes when creating queues #122
base: main
Are you sure you want to change the base?
Changes from all commits
3ee4617
ae052c6
bd89dc2
db804a8
c4b8781
0a2f9bf
189f142
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -417,6 +417,9 @@ func (s *jetStreamStorage) createQueue(q *Queue, replicas int, memory bool) erro | |
} else { | ||
opts = append(opts, jsm.DiscardNew()) | ||
} | ||
if q.MaxBytes > -1 { | ||
opts = append(opts, jsm.MaxBytes(q.MaxBytes)) | ||
} | ||
|
||
var err error | ||
|
||
|
@@ -726,7 +729,7 @@ func (s *jetStreamStorage) SaveScheduledTask(st *ScheduledTask, update bool) err | |
return nil | ||
} | ||
|
||
func (s *jetStreamStorage) PrepareConfigurationStore(memory bool, replicas int) error { | ||
func (s *jetStreamStorage) PrepareConfigurationStore(memory bool, replicas int, maxBytes int64, maxBytesSet bool) error { | ||
var err error | ||
|
||
if replicas == 0 { | ||
|
@@ -745,12 +748,18 @@ func (s *jetStreamStorage) PrepareConfigurationStore(memory bool, replicas int) | |
|
||
kv, err := js.KeyValue(ConfigBucketName) | ||
if err == nats.ErrBucketNotFound { | ||
kv, err = js.CreateKeyValue(&nats.KeyValueConfig{ | ||
cfg := &nats.KeyValueConfig{ | ||
Bucket: ConfigBucketName, | ||
Description: "Choria Async Jobs Configuration", | ||
Storage: storage, | ||
Replicas: replicas, | ||
}) | ||
} | ||
|
||
if maxBytes > -1 { | ||
cfg.MaxBytes = maxBytes | ||
} | ||
|
||
kv, err = js.CreateKeyValue(cfg) | ||
} | ||
if err != nil { | ||
return err | ||
|
@@ -760,13 +769,19 @@ func (s *jetStreamStorage) PrepareConfigurationStore(memory bool, replicas int) | |
|
||
kv, err = js.KeyValue(LeaderElectionBucketName) | ||
if err == nats.ErrBucketNotFound { | ||
kv, err = js.CreateKeyValue(&nats.KeyValueConfig{ | ||
cfg := &nats.KeyValueConfig{ | ||
Bucket: LeaderElectionBucketName, | ||
Description: "Choria Async Jobs Leader Elections", | ||
Storage: storage, | ||
Replicas: replicas, | ||
TTL: 10 * time.Second, | ||
}) | ||
} | ||
|
||
if maxBytesSet { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there is a mix of approaches here, in one place you check for I think now that we never rely on default down here etc we can probably just act on |
||
cfg.MaxBytes = maxBytes | ||
} | ||
|
||
kv, err = js.CreateKeyValue(cfg) | ||
} | ||
if err != nil { | ||
return err | ||
|
@@ -778,7 +793,7 @@ func (s *jetStreamStorage) PrepareConfigurationStore(memory bool, replicas int) | |
|
||
} | ||
|
||
func (s *jetStreamStorage) PrepareTasks(memory bool, replicas int, retention time.Duration) error { | ||
func (s *jetStreamStorage) PrepareTasks(memory bool, replicas int, retention time.Duration, maxBytes int64, maxBytesSet bool) error { | ||
var err error | ||
|
||
if replicas == 0 { | ||
|
@@ -800,6 +815,10 @@ func (s *jetStreamStorage) PrepareTasks(memory bool, replicas int, retention tim | |
|
||
opts = append(opts, jsm.MaxAge(retention)) | ||
|
||
if maxBytesSet { | ||
opts = append(opts, jsm.MaxBytes(maxBytes)) | ||
} | ||
|
||
s.tasks = &taskStorage{mgr: s.mgr} | ||
s.tasks.stream, err = s.mgr.LoadOrNewStream(TasksStreamName, opts...) | ||
if err != nil { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should only set this when set by the user, not by default.