Skip to content

Commit

Permalink
feat: discov support standalone etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudskywalker committed Apr 20, 2022
1 parent fd33765 commit 9bf4ed8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions core/discov/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ func extractId(etcdKey string) (string, bool) {
func makeEtcdKey(key string, id int64) string {
return fmt.Sprintf("%s%c%d", key, internal.Delimiter, id)
}

func MarkEtcdClientStandalone() {
internal.NewClient = internal.DialClientStandalone
}
12 changes: 12 additions & 0 deletions core/discov/internal/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,18 @@ func DialClient(endpoints []string) (EtcdClient, error) {
})
}

// DialClientStandalone dials an standalone etcd with given endpoionts.
func DialClientStandalone(endpoints []string) (EtcdClient, error) {
return clientv3.New(clientv3.Config{
Endpoints: endpoints,
//AutoSyncInterval: autoSyncInterval,
DialTimeout: DialTimeout,
DialKeepAliveTime: dialKeepAliveTime,
DialKeepAliveTimeout: DialTimeout,
//RejectOldCluster: true,
})
}

func getClusterKey(endpoints []string) string {
sort.Strings(endpoints)
return strings.Join(endpoints, endpointsSeparator)
Expand Down

0 comments on commit 9bf4ed8

Please sign in to comment.