diff --git a/accounting/accounting.go b/accounting/accounting.go index c469612..63221ac 100644 --- a/accounting/accounting.go +++ b/accounting/accounting.go @@ -8,7 +8,7 @@ import ( "isp-gate-service/conf" "isp-gate-service/entity" "isp-gate-service/log_code" - "isp-gate-service/model" + "isp-gate-service/repository" "isp-gate-service/service/matcher" "sync" "time" @@ -110,7 +110,7 @@ func (w *accountingWorker) recoveryAccounting(appId int32, limitStates map[strin importNotComplete = true ) - dbSnapshot, err := model.SnapshotRep.GetByApplication(appId) + dbSnapshot, err := repository.SnapshotRep.GetByApplication(appId) if err != nil { log.Warn(log_code.ErrorSnapshotAccounting, err) } diff --git a/accounting/accounting_test.go b/accounting/accounting_test.go index 39da593..f23de56 100644 --- a/accounting/accounting_test.go +++ b/accounting/accounting_test.go @@ -5,7 +5,7 @@ import ( "github.com/stretchr/testify/assert" "isp-gate-service/conf" "isp-gate-service/entity" - "isp-gate-service/model" + "isp-gate-service/repository" "sync" "testing" "time" @@ -65,7 +65,7 @@ var ( func TestAccounting(t *testing.T) { a := assert.New(t) snapshotRep := newSnapshotRepository(false) - model.SnapshotRep = snapshotRep + repository.SnapshotRep = snapshotRep worker = &accountingWorker{ accountingStorage: make(map[int32]Accounting), requestsStoring: make(map[int32]bool), @@ -115,7 +115,7 @@ func TestAccounting(t *testing.T) { func TestWorker_recoveryAccounting(t *testing.T) { a := assert.New(t) snapshotRep := newSnapshotRepository(true) - model.SnapshotRep = snapshotRep + repository.SnapshotRep = snapshotRep worker = &accountingWorker{ accountingStorage: make(map[int32]Accounting), @@ -138,7 +138,7 @@ func TestWorker_recoveryAccounting(t *testing.T) { time.Sleep(time.Millisecond * 300) a.True(snapshotRep.Wait()) - snapshot, err := model.SnapshotRep.GetByApplication(appId) + snapshot, err := repository.SnapshotRep.GetByApplication(appId) a.NoError(err) a.NotNil(snapshot) a.Equal(len(request), int(snapshot.Version)) diff --git a/accounting/snapshot.go b/accounting/snapshot.go index 439389d..ef10a72 100644 --- a/accounting/snapshot.go +++ b/accounting/snapshot.go @@ -5,7 +5,7 @@ import ( "github.com/integration-system/isp-log/stdcodes" "isp-gate-service/entity" "isp-gate-service/log_code" - "isp-gate-service/model" + "isp-gate-service/repository" "sync" "time" ) @@ -66,7 +66,7 @@ func (t *snapshotTask) run(timeout time.Duration) { } func (t *snapshotTask) unload(list []entity.Snapshot) { - if err := model.SnapshotRep.Update(list); err != nil { + if err := repository.SnapshotRep.Update(list); err != nil { log.Error(log_code.ErrorSnapshotAccounting, err) } t.wg.Done() diff --git a/accounting/storing.go b/accounting/storing.go index 9243d31..b6de27e 100644 --- a/accounting/storing.go +++ b/accounting/storing.go @@ -6,7 +6,7 @@ import ( "isp-gate-service/conf" "isp-gate-service/entity" "isp-gate-service/log_code" - "isp-gate-service/model" + "isp-gate-service/repository" "sync" "time" ) @@ -100,7 +100,7 @@ func (t *storingTask) run(timeout time.Duration) { } func (t *storingTask) unload(cache []entity.Request) { - if err := model.RequestsRep.Insert(cache); err != nil { + if err := repository.RequestsRep.Insert(cache); err != nil { log.Error(log_code.ErrorUnloadAccounting, err) } t.wg.Done() diff --git a/accounting/storing_test.go b/accounting/storing_test.go index 978626c..954eec9 100644 --- a/accounting/storing_test.go +++ b/accounting/storing_test.go @@ -1,13 +1,14 @@ package accounting import ( - "github.com/stretchr/testify/assert" - "isp-gate-service/conf" - "isp-gate-service/entity" - "isp-gate-service/model" "sync" "testing" "time" + + "github.com/stretchr/testify/assert" + "isp-gate-service/conf" + "isp-gate-service/entity" + "isp-gate-service/repository" ) var ( @@ -28,10 +29,10 @@ var ( ) func initStoring(setting conf.StoringSetting) *requestsRepository { - repository := &requestsRepository{cache: make([]entity.Request, 0), wg: &sync.WaitGroup{}} - model.RequestsRep = repository + rep := &requestsRepository{cache: make([]entity.Request, 0), wg: &sync.WaitGroup{}} + repository.RequestsRep = rep InitStoringTask(setting) - return repository + return rep } func wait(wg *sync.WaitGroup) bool { diff --git a/main.go b/main.go index 51a6e90..8655d28 100644 --- a/main.go +++ b/main.go @@ -15,9 +15,9 @@ import ( "isp-gate-service/authenticate" "isp-gate-service/conf" "isp-gate-service/invoker" - "isp-gate-service/model" "isp-gate-service/proxy" "isp-gate-service/redis" + "isp-gate-service/repository" "isp-gate-service/routing" "isp-gate-service/server" "isp-gate-service/service" @@ -61,7 +61,7 @@ func onLocalConfigLoad(_ *conf.Configuration) { func onRemoteConfigReceive(remoteConfig, oldRemoteConfig *conf.RemoteConfig) { localCfg := config.Get().(*conf.Configuration) - model.DbClient.ReceiveConfiguration(remoteConfig.Database) + repository.DbClient.ReceiveConfiguration(remoteConfig.Database) invoker.Journal.ReceiveConfiguration(remoteConfig.JournalSetting.Journal, localCfg.ModuleName) matcher.JournalMethods = matcher.NewAtLeastOneMatcher(remoteConfig.JournalSetting.MethodsPatterns) diff --git a/model/client.go b/repository/client.go similarity index 96% rename from model/client.go rename to repository/client.go index f6c2771..e623894 100644 --- a/model/client.go +++ b/repository/client.go @@ -1,4 +1,4 @@ -package model +package repository import ( "github.com/integration-system/isp-lib/v2/database" diff --git a/model/requests.go b/repository/requests.go similarity index 96% rename from model/requests.go rename to repository/requests.go index 3039914..f8e16c1 100644 --- a/model/requests.go +++ b/repository/requests.go @@ -1,4 +1,4 @@ -package model +package repository import ( "github.com/go-pg/pg/v9/orm" diff --git a/model/snapshot.go b/repository/snapshot.go similarity index 98% rename from model/snapshot.go rename to repository/snapshot.go index e8568f5..a08f7fb 100644 --- a/model/snapshot.go +++ b/repository/snapshot.go @@ -1,4 +1,4 @@ -package model +package repository import ( "github.com/go-pg/pg/v9"