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

Support streaming list results #341

Closed
japborst opened this issue Jun 20, 2022 · 3 comments
Closed

Support streaming list results #341

japborst opened this issue Jun 20, 2022 · 3 comments
Assignees

Comments

@japborst
Copy link

Created upon request from turbot/steampipe-plugin-github#167.

Next to d.streamListItem it would be great to have a d.streamList functionality when multiple items need to be streamed.

A naive implementation could look something like:

func (d *QueryData) streamList(ctx context.Context, item interface{}) {
	  for _, item := range item {
		  if item != "" {
			  d.StreamListItem(ctx, item)
		  }
	  
		  // Context can be cancelled due to manual cancellation or the limit has been hit
		  if d.QueryStatus.RowsRemaining(ctx) == 0 {
			  break
		  }
	  }
}
@kaidaguerre
Copy link
Contributor

Hi @japborst . Sorry for taking a while to respond to this one.

So as I understand it, this would just be a shortcut function to stream multiple items with once sdk call?

@japborst
Copy link
Author

japborst commented Aug 2, 2022

@kaidaguerre thanks for taking a look.

That's indeed correct.

@kaidaguerre
Copy link
Contributor

@japborst got an even simpler solution for this - StreamListItem will be updated to being a variadic function:

func (d *QueryData) streamListItem(ctx context.Context, items ...interface{}) 

so to pass an array of items you just need to expand it:

d.StreamListItem(ctx, rows...)

This will be in the upcoming v4.0.0 sdk release

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

No branches or pull requests

2 participants