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 iterators to unified resource cache #52103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rosstimothy
Copy link
Contributor

This updates the UnifiedResourceCache with IterateResources as an alternative to IterateUnifiedResources. The new function returns an iterator instead of collecting and returning a page of results. While this API may not entirely replace the current one, it offers a better way for users that just want to iterate resources without collecting them. Additionally, a few helper methods were included for callers that might wish to only iterate one specific resource type. Internally the UnifiedResourceCache was refactored to use the same logic for all exposed iteration methods.

@rosstimothy rosstimothy added the no-changelog Indicates that a PR does not require a changelog entry label Feb 12, 2025
@rosstimothy rosstimothy force-pushed the tross/urc_iteration branch 4 times, most recently from 124228e to ff4cc96 Compare February 13, 2025 21:11
@rosstimothy rosstimothy force-pushed the tross/urc_iteration branch 7 times, most recently from e2ce7c1 to b43230f Compare February 14, 2025 22:49
This updates the UnifiedResourceCache with IterateResources as an
alternative to IterateUnifiedResources. The new function returns
an iterator instead of collecting and returning a page of results.
While this API may not entirely replace the current one, it offers
a better way for users that just want to iterate resources without
collecting them. Additionally, a few helper methods were included
for callers that might wish to only iterate one specific resource
type. Internally the UnifiedResourceCache was refactored to use the
same logic for all exposed iteration methods.
@rosstimothy rosstimothy marked this pull request as ready for review February 18, 2025 14:51
@github-actions github-actions bot requested review from ravicious and Tener February 18, 2025 14:52
)
// IterateWindowsDesktops iterates over all cached windows desktops starting from the provided key.
func (c *UnifiedResourceCache) IterateWindowsDesktops(ctx context.Context, start string, order IterationOrder) iter.Seq2[types.WindowsDesktop, error] {
return iterateUnifiedResourceCache(ctx, c, start, order, types.KindWindowsDesktop, func(desktop types.WindowsDesktop) types.WindowsDesktop { return desktop.Copy() })
Copy link
Contributor

Choose a reason for hiding this comment

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

why cant this copy func just be types.WindowsDesktop.Copy like the other types?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The compiler won't allow that because of the return type

	// Copy returns a copy of this dynamic Windows desktop
	Copy() *DynamicWindowsDesktopV1

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, guess i could have just tried myself :)

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Indicates that a PR does not require a changelog entry size/lg
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants