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

Pattern for checking API world wide #99

Closed
kaihendry opened this issue Jan 16, 2018 · 6 comments
Closed

Pattern for checking API world wide #99

kaihendry opened this issue Jan 16, 2018 · 6 comments
Labels
closed-for-staleness guidance Question that needs advice or information.

Comments

@kaihendry
Copy link

kaihendry commented Jan 16, 2018

~$ go version
go version go1.9.2 linux/amd64
~$ git --git-dir ~/go/src/github.com/aws/aws-sdk-go-v2/.git describe --all
tags/v2.0.0-preview.2

Hi, is there a better pattern to use to work out where a service (in my example, medialive) is active?

http://play.golang.org/p/O4MlKjZAP5O

Functions with region endpoints.Region and cfg.Region = region.ID() looks ugly to me.

@kaihendry
Copy link
Author

This API is very weird: https://godoc.org/github.com/aws/aws-sdk-go-v2/aws/endpoints#Partition.Regions

A map[string]Region for a return?! A list is far more idiomatic, no?

Also the second bool parameter in the return of https://godoc.org/github.com/aws/aws-sdk-go-v2/aws/endpoints#Partitions.ForPartition is really not idiomatic.

@xibz xibz added the guidance Question that needs advice or information. label Jan 16, 2018
@xibz
Copy link
Contributor

xibz commented Jan 16, 2018

@kaihendry - Second bool parameter being returned can be found in the standard library. See here. I believe this best indicates whether or not something has been found.

In addition, what data structure that is returned such as map versus [] doesn't really fit the definition of idiomatic. The map was chosen to let users easily grab the region they wanted without needing to iterate. We could type alias it like shown here in the standard library. How do you feel about it being type aliased instead of a map?

@kaihendry
Copy link
Author

Thanks for the link. TIL something new. Though I understand an ENV VAR="" being set as empty. However why would a partition be and why would you need to account for that?

I don't quite understand what you mean by aliased. You referenced map[string][]string ?

@xibz
Copy link
Contributor

xibz commented Jan 17, 2018

@kaihendry - I referenced the http.Header header object that type aliases it to a map[string][]string.

@jasdel
Copy link
Contributor

jasdel commented Jan 19, 2018

@kaihendry Thanks for the feedback. The endpoints#Partition.Regions returns a map to make it easy to determine if a partition includes a region. A partition is an idea like AWS global, AWS China, and AWS GovCloud. Each of these partitions have their own unique set of regions.

The reason Region returns a map instead a slice isn't very strong. But it was consistent with the method for services, which are also a map. In addition this is partly because the data is stored internally as maps. Converting the internal map to a list would add overhead for each method.

endpoints#Partitions could be updated to include a ForService to return a sub slice of partitions which include support for a service.

For your original linked code example. I'd suggest the following pattern to simplify iterating over the regions, https://play.golang.org/p/6M6Cd9dusm3

@github-actions
Copy link

We have noticed this issue has not received attention in 1 year. We will close this issue for now. If you think this is in error, please feel free to comment and reopen the issue.

@github-actions github-actions bot added closing-soon This issue will automatically close in 4 days unless further comments are made. closed-for-staleness and removed closing-soon This issue will automatically close in 4 days unless further comments are made. labels Sep 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-for-staleness guidance Question that needs advice or information.
Projects
None yet
Development

No branches or pull requests

3 participants