e50cabac4b
- Updated all references from v6 to v7 for `github.com/router-for-me/CLIProxyAPI`. - Ensured consistency in imports within core libraries, tests, and integration tests. - Added missing tests for new features in Redis Protocol integration.
26 lines
529 B
Go
26 lines
529 B
Go
package home
|
|
|
|
import "sync/atomic"
|
|
|
|
var currentClient atomic.Value // *Client
|
|
|
|
// SetCurrent sets the active home client used by runtime integrations.
|
|
func SetCurrent(client *Client) {
|
|
currentClient.Store(client)
|
|
}
|
|
|
|
// Current returns the active home client instance, if any.
|
|
func Current() *Client {
|
|
if v := currentClient.Load(); v != nil {
|
|
if client, ok := v.(*Client); ok {
|
|
return client
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// ClearCurrent removes the active home client.
|
|
func ClearCurrent() {
|
|
currentClient.Store((*Client)(nil))
|
|
}
|