-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: isolate nacos-sdk-go into pkg/nacos/client/impl (#9)
限制nacos sdk引用在pkg/nacos/client/impl包下
- Loading branch information
Showing
8 changed files
with
257 additions
and
231 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package client | ||
|
||
import ( | ||
nacosv1 "github.com/nacos-group/nacos-controller/api/v1" | ||
"sync" | ||
) | ||
|
||
var _defaultClient NacosConfigClient | ||
var _lock = sync.Mutex{} | ||
|
||
func RegisterNacosClientIfAbsent(c NacosConfigClient) { | ||
_lock.Lock() | ||
defer _lock.Unlock() | ||
if _defaultClient == nil { | ||
_defaultClient = c | ||
} | ||
} | ||
|
||
func RegisterNacosClient(c NacosConfigClient) { | ||
_lock.Lock() | ||
defer _lock.Unlock() | ||
_defaultClient = c | ||
} | ||
|
||
func GetDefaultNacosClient() NacosConfigClient { | ||
if _defaultClient == nil { | ||
panic("No default NacosConfigClient registered") | ||
} | ||
return _defaultClient | ||
} | ||
|
||
type NacosConfigClient interface { | ||
GetConfig(param NacosConfigParam) (string, error) | ||
PublishConfig(param NacosConfigParam) (bool, error) | ||
DeleteConfig(param NacosConfigParam) (bool, error) | ||
ListenConfig(param NacosConfigParam) error | ||
CancelListenConfig(param NacosConfigParam) error | ||
} | ||
|
||
type NacosConfigParam struct { | ||
DynamicConfiguration *nacosv1.DynamicConfiguration | ||
DataId string | ||
Group string | ||
Content string | ||
OnChange func(namespace, group, dataId, data string) | ||
} |
Oops, something went wrong.