ExecuteOnProfile executes an operation on a specific profile by name. Returns the operation data and error.
( ctx context.Context, profileName string, operation ProfileOperation, )
| 81 | // ExecuteOnProfile executes an operation on a specific profile by name. |
| 82 | // Returns the operation data and error. |
| 83 | func (m *GroupClientManager) ExecuteOnProfile( |
| 84 | ctx context.Context, |
| 85 | profileName string, |
| 86 | operation ProfileOperation, |
| 87 | ) (interface{}, error) { |
| 88 | pc, exists := m.GetClient(profileName) |
| 89 | if !exists { |
| 90 | return nil, fmt.Errorf("profile '%s' not found in group '%s'", profileName, m.groupName) |
| 91 | } |
| 92 | |
| 93 | status, _ := pc.GetStatus() |
| 94 | if status != ProfileStatusConnected { |
| 95 | return nil, fmt.Errorf("profile '%s' is not connected (status: %s)", profileName, status.String()) |
| 96 | } |
| 97 | |
| 98 | // Check context cancellation |
| 99 | select { |
| 100 | case <-ctx.Done(): |
| 101 | return nil, ctx.Err() |
| 102 | default: |
| 103 | } |
| 104 | |
| 105 | return operation(profileName, pc.Client) |
| 106 | } |
| 107 | |
| 108 | // RefreshProfileConnection attempts to reconnect a failed profile. |
| 109 | // This is useful for recovering from transient network errors. |
no test coverage detected