-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The patch adds a possibility of dependency injection of integrity collectors and publishers into the cluster module and commands. The global variables are now used instead of a command context. These places are marked with `TODO` label and should be refactored later.
- Loading branch information
1 parent
8676f41
commit 19eefb1
Showing
18 changed files
with
419 additions
and
114 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 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 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,54 @@ | ||
package cluster | ||
|
||
import ( | ||
"time" | ||
|
||
clientv3 "go.etcd.io/etcd/client/v3" | ||
|
||
"github.com/tarantool/tt/cli/connector" | ||
) | ||
|
||
// CollectorFactory creates new data collectors. | ||
type CollectorFactory interface { | ||
// NewFile creates a new data collector to collect configuration from a file. | ||
NewFile(path string) (Collector, error) | ||
// NewEtcd creates a new data collector to collect configuration from etcd. | ||
NewEtcd(etcdcli *clientv3.Client, | ||
prefix, key string, timeout time.Duration) (Collector, error) | ||
// NewTarantool creates a new data collector to collect configuration from | ||
// tarantool config storage. | ||
NewTarantool(conn connector.Connector, | ||
prefix, key string, timeout time.Duration) (Collector, error) | ||
} | ||
|
||
// collectorsFactory is a type that implements a default CollectorFactory. | ||
type collectorsFactory struct{} | ||
|
||
// NewCollectorFactory creates a new CollectorFactory. | ||
func NewCollectorFactory() CollectorFactory { | ||
return collectorsFactory{} | ||
} | ||
|
||
// NewFiler creates a new file configuration collector. | ||
func (factory collectorsFactory) NewFile(path string) (Collector, error) { | ||
return NewFileCollector(path), nil | ||
} | ||
|
||
// NewEtcd creates a new etcd configuration collector. | ||
func (factory collectorsFactory) NewEtcd(etcdcli *clientv3.Client, | ||
prefix, key string, timeout time.Duration) (Collector, error) { | ||
if key == "" { | ||
return NewEtcdAllCollector(etcdcli, prefix, timeout), nil | ||
} | ||
return NewEtcdKeyCollector(etcdcli, prefix, key, timeout), nil | ||
} | ||
|
||
// NewTarantool creates creates a new tarantool config storage configuration | ||
// collector. | ||
func (factory collectorsFactory) NewTarantool(conn connector.Connector, | ||
prefix, key string, timeout time.Duration) (Collector, error) { | ||
if key == "" { | ||
return NewTarantoolAllCollector(conn, prefix, timeout), nil | ||
} | ||
return NewTarantoolKeyCollector(conn, prefix, key, timeout), nil | ||
} |
Oops, something went wrong.