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

added support for max_bytes when creating queues #122

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

calmera
Copy link

@calmera calmera commented Jun 21, 2024

When working against Synadia Cloud, creating a stream requires max_bytes to be provided. This PR adds that to the CLI.

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Copy link
Member

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly good, lets fix the spacing and also render the value in

func showQueue(q *asyncjobs.QueueInfo) {

"github.com/dustin/go-humanize"
"github.com/choria-io/asyncjobs"
"github.com/choria-io/fisk"
"github.com/dustin/go-humanize"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad things happened with formatting :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, seems my indenting was wrong, sorry about that. Should be fixed in the next commit

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
storage.go Outdated

opts = append(opts, jsm.MaxAge(retention))
opts = append(opts, jsm.MaxAge(retention))
opts = append(opts, jsm.MaxBytes(DefaultMaxBytes))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I am comfortable adding this maximum always, wrap it in a check for either being set specifically or if its required, check for required using this. To detrmine if its set you can use the IsSetByUser() support when adding the flag

https://github.com/nats-io/jsm.go/blob/78b71b6a1d19e714732a57a7d130bb697b7ce522/manager.go#L94

Copy link
Member

@ripienaar ripienaar Jun 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example use here:

f.Flag("subscriptions", "Maximum allowed subscriptions").Default("-1").IsSetByUser(&c.maxSubIsSet).Int64Var(&c.maxSubs)

this will set the boolean true if the user set it

also fixed the formatting of the code and introduced a new MaxBytes
option to the client

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
@ripienaar
Copy link
Member

Best way to avoid indent issues is to use tabs (not spaces for go) and to run go fmt over the files you edit, go fmt takes out all the guess work :)

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
@calmera
Copy link
Author

calmera commented Jun 24, 2024

Best way to avoid indent issues is to use tabs (not spaces for go) and to run go fmt over the files you edit, go fmt takes out all the guess work :)

Good point. Should be ok now

@ripienaar
Copy link
Member

Still several files with unwanted whitespace changes in the PR

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
@calmera
Copy link
Author

calmera commented Jun 26, 2024

Ok, that should do it. Sorry man. I owe you a beer at some point ;)

@ripienaar
Copy link
Member

looking better, I'll take a look in a week or so as I am OOO atm.

@ripienaar
Copy link
Member

Meanwhile I see one test is failing to compile:

Error: vet: ./storage_test.go:45:52: not enough arguments in call to storage.PrepareConfigurationStore
	have (bool, number)
	want (bool, int, int64, bool)
Error: Process completed with exit code 1.

Signed-off-by: Daan Gerits <daan.gerits@gmail.com>
Copy link
Member

@ripienaar ripienaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some small comments, looking good so far though

@@ -62,6 +64,7 @@ func newDefaultQueue() *Queue {
MaxRunTime: time.Minute,
MaxTries: 100,
MaxConcurrent: DefaultQueueMaxConcurrent,
MaxBytes: DefaultMaxBytes,
Copy link
Member

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.

})
}

if maxBytesSet {
Copy link
Member

Choose a reason for hiding this comment

The 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 > -1 (line 758) and here you check if its set. I dont think the isSet here really add value

I think now that we never rely on default down here etc we can probably just act on > -1 as you did above. Eitherway we should be consistent whichever we pick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants