From d25f03e80c92fe895f50dfd6421cd45ee6de20e4 Mon Sep 17 00:00:00 2001 From: Caj Larsson Date: Mon, 16 May 2022 16:05:33 +0800 Subject: [PATCH] Renaming SwampfileService -> DataSwampService --- dataswamp/swamp_service.go | 16 ++++++++-------- dataswamp/swamp_service_test.go | 20 ++++++++++---------- server/bog.go | 4 ++-- server/bog_test.go | 2 +- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/dataswamp/swamp_service.go b/dataswamp/swamp_service.go index 56d37c6..b1e5175 100644 --- a/dataswamp/swamp_service.go +++ b/dataswamp/swamp_service.go @@ -11,28 +11,28 @@ import ( // "fmt" ) -type SwampFileService struct { +type DataSwampService struct { ns_svc namespace.NamespaceService swamp_file_repo swampfile.Repository logger util.Logger eventBus util.EventBus } -func NewSwampFileService( +func NewDataSwampService( ns_svc namespace.NamespaceService, swamp_file_repo swampfile.Repository, logger util.Logger, -) *SwampFileService { - s := SwampFileService{ns_svc, swamp_file_repo, logger, *util.NewEventBus()} +) *DataSwampService { + s := DataSwampService{ns_svc, swamp_file_repo, logger, *util.NewEventBus()} ns_svc.Wire(s.eventBus.Register, s.eventBus.Handle) return &s } -func (s SwampFileService) NamespaceStats() []namespace.Namespace { +func (s DataSwampService) NamespaceStats() []namespace.Namespace { return s.ns_svc.All() } -func (s SwampFileService) SaveFile(ref swampfile.FileReference, src io.Reader, size int64) error { +func (s DataSwampService) SaveFile(ref swampfile.FileReference, src io.Reader, size int64) error { ns := s.ns_svc.GetOrCreateNs(ref.UserAgent) r, err := ref.Clean(true) @@ -89,7 +89,7 @@ func (s SwampFileService) SaveFile(ref swampfile.FileReference, src io.Reader, s return nil } -func (s SwampFileService) OpenOutFile(ref swampfile.FileReference) (swampfile.SwampOutFile, error) { +func (s DataSwampService) OpenOutFile(ref swampfile.FileReference) (swampfile.SwampOutFile, error) { ns := s.ns_svc.GetOrCreateNs(ref.UserAgent) r, err := ref.Clean(true) @@ -109,7 +109,7 @@ func (s SwampFileService) OpenOutFile(ref swampfile.FileReference) (swampfile.Sw return f, nil } -func (s SwampFileService) CleanUpExpiredFiles() error { +func (s DataSwampService) CleanUpExpiredFiles() error { s.logger.Info("Cleaning up expired files") for _, ns := range s.ns_svc.All() { diff --git a/dataswamp/swamp_service_test.go b/dataswamp/swamp_service_test.go index a1c81ca..f56f3e4 100644 --- a/dataswamp/swamp_service_test.go +++ b/dataswamp/swamp_service_test.go @@ -24,7 +24,7 @@ var file_ref1 = swampfile.FileReference{"/path1", "ns1"} var file_ref2 = swampfile.FileReference{"/path1", "ns2"} var file_ref3 = swampfile.FileReference{"/path2", "ns1"} -func NewTestSwampFileService() SwampFileService { +func NewTestDataSwampService() DataSwampService { file_repo := m_swampfile.NewRepository() ns_repo := m_namespace.NewRepository() @@ -37,12 +37,12 @@ func NewTestSwampFileService() SwampFileService { 1024, ) - return *NewSwampFileService(*ns_svc, file_repo, logger) + return *NewDataSwampService(*ns_svc, file_repo, logger) } func TestFileDontExist(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() outfile, err := s.OpenOutFile(file_ref1) is.True(err == swampfile.ErrNotExists) @@ -51,7 +51,7 @@ func TestFileDontExist(t *testing.T) { func TestFileIsStored(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() fakefile := bytes.NewBufferString("My bog data") @@ -72,7 +72,7 @@ func TestFileIsStored(t *testing.T) { func TestFileIsReadBack(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() infile := bytes.NewBufferString("My bog data") @@ -88,7 +88,7 @@ func TestFileIsReadBack(t *testing.T) { func TestNSIsolation(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() ns1_file := bytes.NewBufferString("My bog data ns1") ns2_file := bytes.NewBufferString("My bog data ns2") @@ -106,7 +106,7 @@ func TestNSIsolation(t *testing.T) { func TestPathStrictMode(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() ns_file := bytes.NewBufferString("My bog data ns1") @@ -126,7 +126,7 @@ func TestPathStrictMode(t *testing.T) { func TestQuotaWithContenSizeLieOver(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() largefakefile := bytes.NewBufferString("") @@ -141,7 +141,7 @@ func TestQuotaWithContenSizeLieOver(t *testing.T) { func TestQuotaWithContenSizeLieUnder(t *testing.T) { is := is.New(t) - s := NewTestSwampFileService() + s := NewTestDataSwampService() largefakefile := bytes.NewBufferString("small") @@ -165,7 +165,7 @@ func TestCleanUpExpired(t *testing.T) { 1024, ) - s := NewSwampFileService(*ns_svc, file_repo, logger) + s := NewDataSwampService(*ns_svc, file_repo, logger) fakefile := bytes.NewBufferString("My bog") err := s.SaveFile(file_ref1, fakefile, int64(fakefile.Len())) diff --git a/server/bog.go b/server/bog.go index e3d290e..81abdf0 100644 --- a/server/bog.go +++ b/server/bog.go @@ -22,7 +22,7 @@ type Router interface { type Bog struct { router Router adminRouter Router - file_service dataswamp.SwampFileService + file_service dataswamp.DataSwampService address string adminAddress string logger util.Logger @@ -143,7 +143,7 @@ func New(config *Configuration) *Bog { config.Quota.ParsedSizeBytes(), ) - b.file_service = *dataswamp.NewSwampFileService( + b.file_service = *dataswamp.NewDataSwampService( *ns_svc, fsSwampRepo, logger, diff --git a/server/bog_test.go b/server/bog_test.go index 0a99d1d..35902a8 100644 --- a/server/bog_test.go +++ b/server/bog_test.go @@ -34,7 +34,7 @@ func TestApplication(t *testing.T) { 1000, ) - file_service := dataswamp.NewSwampFileService( + file_service := dataswamp.NewDataSwampService( *ns_svc, swampfile.NewRepository(), logger,