mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-19 06:59:50 +02:00
refactor: add context handling in various functions
- Modified functions to accept context.Context as a parameter for better context management. - Updated Init methods in Proxmox and Config to use the provided context. - Adjusted UpdatePorts and NewProxmoxProvider to utilize the context for operations.
This commit is contained in:
@@ -25,14 +25,14 @@ const proxmoxStateCheckInterval = 1 * time.Second
|
||||
|
||||
var ErrNodeNotFound = gperr.New("node not found in pool")
|
||||
|
||||
func NewProxmoxProvider(nodeName string, vmid int) (idlewatcher.Provider, error) {
|
||||
func NewProxmoxProvider(ctx context.Context, nodeName string, vmid int) (idlewatcher.Provider, error) {
|
||||
node, ok := proxmox.Nodes.Get(nodeName)
|
||||
if !ok {
|
||||
return nil, ErrNodeNotFound.Subject(nodeName).
|
||||
Withf("available nodes: %s", proxmox.AvailableNodeNames())
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
|
||||
ctx, cancel := context.WithTimeout(ctx, 3*time.Second)
|
||||
defer cancel()
|
||||
|
||||
lxcName, err := node.LXCName(ctx, vmid)
|
||||
|
||||
Reference in New Issue
Block a user