-
Notifications
You must be signed in to change notification settings - Fork 2
/
managed_cluster_client.go
49 lines (39 loc) · 1.33 KB
/
managed_cluster_client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package redis
import (
"context"
"github.com/go-redis/redis/v7"
)
// ManagedClusterClient represents a redis cluster managed client.
type ManagedClusterClient struct {
Client *redis.ClusterClient
Plugins []ClusterPlugin
Options *Options
}
// NewManagedClusterClientWithConfigPath returns a new managed client with options from config path.
func NewManagedClusterClientWithConfigPath(ctx context.Context, path string, plugins ...ClusterPlugin) (*ManagedClusterClient, error) {
opts, err := NewOptionsWithPath(path)
if err != nil {
return nil, err
}
return NewManagedClusterClientWithOptions(ctx, opts, plugins...)
}
// NewManagedClusterClient returns a new managed client with default options.
func NewManagedClusterClient(ctx context.Context, plugins ...ClusterPlugin) (*ManagedClusterClient, error) {
opts, err := NewOptions()
if err != nil {
return nil, err
}
return NewManagedClusterClientWithOptions(ctx, opts, plugins...)
}
// NewManagedClusterClientWithOptions returns a new managed client with options.
func NewManagedClusterClientWithOptions(ctx context.Context, opts *Options, plugins ...ClusterPlugin) (*ManagedClusterClient, error) {
s, err := NewClusterClientWithOptions(ctx, opts, plugins...)
if err != nil {
return nil, err
}
return &ManagedClusterClient{
Client: s,
Plugins: plugins,
Options: opts,
}, nil
}