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

client: generic list #59

Merged
merged 7 commits into from
Mar 27, 2018
Merged

client: generic list #59

merged 7 commits into from
Mar 27, 2018

Conversation

greut
Copy link
Contributor

@greut greut commented Mar 20, 2018

In a nutshell

vm := &egoscale.VirtualMachine{ZoneID: ...}
vms, err := client.List(vm)
if err != nil {
    panic(err)
}
for _, i := range vms {
    vm := i.(egoscale.VirtualMachine)
    ...
}

other calls:

  • ListWithContext(ctx, vm) ([]interface{}, error)
  • AsyncList(vm) (<-chan interface{}, <-chan error)
  • AsyncListWithContext(ctx, vm) (<-chan interface{}, <-chan error)

TODO:

  • replace ListNics
  • replace GetRootVolumeForVirtualMachine

zones.go Outdated
}

if count >= zones.Count {
break
Copy link
Contributor

Choose a reason for hiding this comment

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

Risky! Between pagination call the count can increase or decrease. You're best bet is to stop paginating when the page result is empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

don't trust Count and paginate until a failure occurs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the result size is smaller than the page size we abort.

Yoan Blanc added 6 commits March 26, 2018 15:22
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
Signed-off-by: Yoan Blanc <yoan.blanc@exoscale.ch>
@greut greut changed the title client: generic list (wip) client: generic list Mar 27, 2018
@greut greut merged commit 54b92bd into master Mar 27, 2018
@greut greut deleted the generic-list branch March 27, 2018 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants