Refactor listing VMs (#399)

* Removed unnesesary ListOptions

* Refactor genericList to accept string prefixes instead of byte slices

* Optimize VM listing logic with singleflight to deduplicate concurrent request

* Refactor VM listing logic: rename variables for clarity and update error messages

* fix: address PR review feedback

- use singleflight DoChan with context cancellation for list VMs

🤖 Generated with [Codex](https://chatgpt.com/codex)

Co-Authored-By: Codex <codex@openai.com>

---------

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
Fedor Korotkov
2026-02-05 18:51:45 +01:00
committed by GitHub
co-authored by Codex
parent 230a83c740
commit be869f10d4
8 changed files with 55 additions and 56 deletions
+4
View File
@@ -29,6 +29,7 @@ import (
"golang.org/x/crypto/ssh"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
"golang.org/x/sync/singleflight"
"google.golang.org/grpc"
"google.golang.org/grpc/keepalive"
)
@@ -73,6 +74,8 @@ type Controller struct {
sshNoClientAuth bool
sshServer *sshserver.SSHServer
single singleflight.Group
rpc.UnimplementedControllerServer
}
@@ -83,6 +86,7 @@ func New(opts ...Option) (*Controller, error) {
workerOfflineTimeout: 3 * time.Minute,
maxWorkersPerLicense: maxWorkersPerDefaultLicense,
pingInterval: 30 * time.Second,
single: singleflight.Group{},
}
// Apply options