Skip to content

Commit

Permalink
CreateRemoteSource, CreateLocalSource -> Create
Browse files Browse the repository at this point in the history
  • Loading branch information
borovskyav committed Jan 17, 2019
1 parent a940c4c commit a7c4b6f
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 21 deletions.
8 changes: 4 additions & 4 deletions checker/check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ func TestCheckErrors(t *testing.T) {
triggerChecker := TriggerChecker{
TriggerID: "SuperId",
Database: dataBase,
Source: local.CreateLocalSource(dataBase),
Source: local.Create(dataBase),
Logger: logger,
Config: &Config{
MetricsTTLSeconds: 10,
Expand Down Expand Up @@ -585,7 +585,7 @@ func TestIgnoreNodataToOk(t *testing.T) {
triggerChecker := TriggerChecker{
TriggerID: "SuperId",
Database: dataBase,
Source: local.CreateLocalSource(dataBase),
Source: local.Create(dataBase),
Logger: logger,
Config: &Config{
MetricsTTLSeconds: 3600,
Expand Down Expand Up @@ -680,7 +680,7 @@ func TestHandleTrigger(t *testing.T) {
triggerChecker := TriggerChecker{
TriggerID: "SuperId",
Database: dataBase,
Source: local.CreateLocalSource(dataBase),
Source: local.Create(dataBase),
Logger: logger,
Config: &Config{
MetricsTTLSeconds: 3600,
Expand Down Expand Up @@ -832,7 +832,7 @@ func TestHandleTrigger(t *testing.T) {
triggerChecker1 := TriggerChecker{
TriggerID: "SuperId",
Database: dataBase,
Source: local.CreateLocalSource(dataBase),
Source: local.Create(dataBase),
Logger: logger,
Config: &Config{
MetricsTTLSeconds: 3600,
Expand Down
2 changes: 1 addition & 1 deletion checker/trigger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestInitTriggerChecker(t *testing.T) {
logger, _ := logging.GetLogger("Test")
config := &Config{}
dataBase := mock_moira_alert.NewMockDatabase(mockCtrl)
localSource := local.CreateLocalSource(dataBase)
localSource := local.Create(dataBase)
triggerID := "superId"
defer mockCtrl.Finish()

Expand Down
4 changes: 2 additions & 2 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,9 @@ func main() {

logger.Infof("Start listening by address: [%s]", apiConfig.Listen)

localSource := local.CreateLocalSource(database)
localSource := local.Create(database)
remoteConfig := config.Remote.GetRemoteSourceSettings()
remoteSource := remote.CreateRemoteSource(remoteConfig)
remoteSource := remote.Create(remoteConfig)
metricSourceProvider := metricSource.CreateMetricSourceProvider(localSource, remoteSource)

httpHandler := handler.NewHandler(database, logger, searchIndex, apiConfig, metricSourceProvider, configFile)
Expand Down
4 changes: 2 additions & 2 deletions cmd/checker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ func main() {
database := redis.NewDatabase(logger, databaseSettings, redis.Checker)

remoteConfig := config.Remote.GetRemoteSourceSettings()
localSource := local.CreateLocalSource(database)
remoteSource := remote.CreateRemoteSource(remoteConfig)
localSource := local.Create(database)
remoteSource := remote.Create(remoteConfig)
metricSourceProvider := metricSource.CreateMetricSourceProvider(localSource, remoteSource)

isConfigured, _ := remoteSource.IsConfigured()
Expand Down
4 changes: 2 additions & 2 deletions cmd/notifier/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func main() {
databaseSettings := config.Redis.GetSettings()
database := redis.NewDatabase(logger, databaseSettings, redis.Notifier)

localSource := local.CreateLocalSource(database)
localSource := local.Create(database)
remoteConfig := config.Remote.GetRemoteSourceSettings()
remoteSource := remote.CreateRemoteSource(remoteConfig)
remoteSource := remote.Create(remoteConfig)
metricSourceProvider := metricSource.CreateMetricSourceProvider(localSource, remoteSource)

notifierConfig := config.Notifier.getSettings(logger)
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/notifier/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestNotifier(t *testing.T) {
mockCtrl = gomock.NewController(t)
defer mockCtrl.Finish()
database := redis.NewDatabase(logger, redis.Config{Port: "6379", Host: "localhost"}, redis.Notifier)
metricsSourceProvider := metricSource.CreateMetricSourceProvider(local.CreateLocalSource(database), nil)
metricsSourceProvider := metricSource.CreateMetricSourceProvider(local.Create(database), nil)
database.SaveContact(&contact)
database.SaveSubscription(&subscription)
database.SaveTrigger(trigger.ID, &trigger)
Expand Down
4 changes: 2 additions & 2 deletions metric_source/local/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ type Local struct {
dataBase moira.Database
}

// CreateLocalSource configures local metric source
func CreateLocalSource(dataBase moira.Database) metricSource.MetricSource {
// Create configures local metric source
func Create(dataBase moira.Database) metricSource.MetricSource {
// configure carbon-api functions
functions.New(make(map[string]string))

Expand Down
4 changes: 2 additions & 2 deletions metric_source/local/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func init() {
func TestEvaluateTarget(t *testing.T) {
mockCtrl := gomock.NewController(t)
dataBase := mock_moira_alert.NewMockDatabase(mockCtrl)
localSource := CreateLocalSource(dataBase)
localSource := Create(dataBase)
defer mockCtrl.Finish()

pattern := "super.puper.pattern"
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestEvaluateTarget(t *testing.T) {
func TestLocal_IsConfigured(t *testing.T) {
mockCtrl := gomock.NewController(t)
dataBase := mock_moira_alert.NewMockDatabase(mockCtrl)
localSource := CreateLocalSource(dataBase)
localSource := Create(dataBase)

Convey("Always true", t, func() {
actual, err := localSource.IsConfigured()
Expand Down
4 changes: 2 additions & 2 deletions metric_source/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ type Remote struct {
client *http.Client
}

// CreateRemoteSource configures remote metric source
func CreateRemoteSource(config *Config) metricSource.MetricSource {
// Create configures remote metric source
func Create(config *Config) metricSource.MetricSource {
return &Remote{
config: config,
client: &http.Client{Timeout: config.Timeout},
Expand Down
4 changes: 2 additions & 2 deletions metric_source/remote/remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import (

func TestIsConfigured(t *testing.T) {
Convey("Remote is not configured", t, func() {
remote := CreateRemoteSource(&Config{URL: "", Enabled: true})
remote := Create(&Config{URL: "", Enabled: true})
isConfigured, err := remote.IsConfigured()
So(isConfigured, ShouldBeFalse)
So(err, ShouldResemble, ErrRemoteStorageDisabled)
})

Convey("Remote is configured", t, func() {
remote := CreateRemoteSource(&Config{URL: "http://host", Enabled: true})
remote := Create(&Config{URL: "http://host", Enabled: true})
isConfigured, err := remote.IsConfigured()
So(isConfigured, ShouldBeTrue)
So(err, ShouldBeEmpty)
Expand Down
2 changes: 1 addition & 1 deletion notifier/notifier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func configureNotifier(t *testing.T) {
logger, _ = logging.GetLogger("Scheduler")
scheduler = mock_scheduler.NewMockScheduler(mockCtrl)
sender = mock_moira_alert.NewMockSender(mockCtrl)
metricsSourceProvider := metricSource.CreateMetricSourceProvider(local.CreateLocalSource(dataBase), nil)
metricsSourceProvider := metricSource.CreateMetricSourceProvider(local.Create(dataBase), nil)

notif = NewNotifier(dataBase, logger, config, notifierMetrics, metricsSourceProvider)
notif.scheduler = scheduler
Expand Down

0 comments on commit a7c4b6f

Please sign in to comment.