Skip to content

Conversation

rylev
Copy link
Contributor

@rylev rylev commented Jan 8, 2021

This is a suggested way of addressing #129.

This particular builder is the builder in Cosmos with the most required fields. Even then, I think it's still a very reasonable API.

Docs

Screenshot 2021-01-08 at 20 02 13

API Usage

Screenshot 2021-01-08 at 20 02 29

Thoughts?

If we like this, I can update the rest of the builders.

@thomastaylor312
Copy link

Would it make more sense to swap the parameters of create_collection and execute? Maybe it is just me, but it seems like it makes more sense to have the required params be part of the operation name (e.g. create_collection) and the thing you are actually doing something with be the parameter to execute. Either way, I think this is much cleaner

@MindFlavor
Copy link
Contributor

I agree with @thomastaylor312. I would go further: why separate the parameters in two places? I'd put them all in the create_collection call. Having to specify the mandatory fields in two different places (with no clear understanding of which goes where) is confusing.

Also, from a documentation point of view, I think it would be best to have all the required fields in one place.

@thomastaylor312
Copy link

@MindFlavor I disagree with you on that count. That conflates configuration with data. With a builder, you are building up a client that can act on something. That "something" is the document/blob/VM/etc. So it makes sense for it to be separate from my view

@rylev
Copy link
Contributor Author

rylev commented Jan 14, 2021

@MindFlavor @thomastaylor312 I pushed another commit which switches where the required and the optional arguments are passed.

I also made Offer and IndexingPolicy optional as according to this they are optional. I tried with one of the e2e tests and it seems to work without them.
The only downside of this is that indexing_policy is now an Option on Collection and thus must be unwrapped even tough on response it's never not set.

I needed to make a new type for the the creation collection request body, but this actually cleaned things up.

let _create_user_response = user2_client.create_user().execute().await.unwrap();

// create a temp collection
let create_collection_response = {

Choose a reason for hiding this comment

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

Nit: I don't think this needs to be in a separate {} block anymore

@MindFlavor
Copy link
Contributor

count. That conflates configuration with data. With a builder, you are building up a client that can act on something. That "something" is the document/blob/VM/etc. So it makes sense

Yes, you make a valid point 👍 ! I agree

(sorry for taking so long to answer)

@rylev rylev merged commit 536da42 into Azure:master Jan 15, 2021
@rylev rylev deleted the builders-refactor branch January 15, 2021 09:52
@rylev rylev mentioned this pull request Jan 15, 2021
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.

3 participants