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

add location endpoint #2481

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

add location endpoint #2481

wants to merge 2 commits into from

Conversation

Omarabdul3ziz
Copy link
Contributor

Description

  • write node location info on a file while registering
  • add location endpoint to get this file info

Related Issues

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstring

- add location endpoint to get this file info
@@ -231,3 +237,13 @@ func ensureTwin(ctx context.Context, substrateGateway *stubs.SubstrateGatewayStu

return twinID, nil
}

func writeLocationOnFile(loc geoip.Location, filepath string) error {
file, err := os.OpenFile(filepath, os.O_RDWR|os.O_CREATE, 0644)
Copy link
Member

Choose a reason for hiding this comment

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

is it possible for the file to already exists?
If possible, what is the default behavior? Is truncate or append?

)

func (g *ZosAPI) locationGet(ctx context.Context, payload []byte) (interface{}, error) {
if _, err := os.Stat(geoip.LocationFile); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

is it needed?

Copy link
Collaborator

@xmonader xmonader left a comment

Choose a reason for hiding this comment

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

This should be addressed differently, I don't see a problem calling that function from the api and returning its result to the user

var loc geoip.Location
err = json.NewDecoder(f).Decode(&loc)
return loc, err
return geoip.Fetch()
Copy link
Collaborator

Choose a reason for hiding this comment

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

at this point you can add caching if needed

@Omarabdul3ziz Omarabdul3ziz marked this pull request as draft November 13, 2024 08:47
@Omarabdul3ziz
Copy link
Contributor Author

i will draft until we finish releasing today

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