Renaming SwampfileService -> DataSwampService

master
Caj Larsson 3 years ago
parent 3c12794d9c
commit d25f03e80c

@ -11,28 +11,28 @@ import (
// "fmt" // "fmt"
) )
type SwampFileService struct { type DataSwampService struct {
ns_svc namespace.NamespaceService ns_svc namespace.NamespaceService
swamp_file_repo swampfile.Repository swamp_file_repo swampfile.Repository
logger util.Logger logger util.Logger
eventBus util.EventBus eventBus util.EventBus
} }
func NewSwampFileService( func NewDataSwampService(
ns_svc namespace.NamespaceService, ns_svc namespace.NamespaceService,
swamp_file_repo swampfile.Repository, swamp_file_repo swampfile.Repository,
logger util.Logger, logger util.Logger,
) *SwampFileService { ) *DataSwampService {
s := SwampFileService{ns_svc, swamp_file_repo, logger, *util.NewEventBus()} s := DataSwampService{ns_svc, swamp_file_repo, logger, *util.NewEventBus()}
ns_svc.Wire(s.eventBus.Register, s.eventBus.Handle) ns_svc.Wire(s.eventBus.Register, s.eventBus.Handle)
return &s return &s
} }
func (s SwampFileService) NamespaceStats() []namespace.Namespace { func (s DataSwampService) NamespaceStats() []namespace.Namespace {
return s.ns_svc.All() 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) ns := s.ns_svc.GetOrCreateNs(ref.UserAgent)
r, err := ref.Clean(true) r, err := ref.Clean(true)
@ -89,7 +89,7 @@ func (s SwampFileService) SaveFile(ref swampfile.FileReference, src io.Reader, s
return nil 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) ns := s.ns_svc.GetOrCreateNs(ref.UserAgent)
r, err := ref.Clean(true) r, err := ref.Clean(true)
@ -109,7 +109,7 @@ func (s SwampFileService) OpenOutFile(ref swampfile.FileReference) (swampfile.Sw
return f, nil return f, nil
} }
func (s SwampFileService) CleanUpExpiredFiles() error { func (s DataSwampService) CleanUpExpiredFiles() error {
s.logger.Info("Cleaning up expired files") s.logger.Info("Cleaning up expired files")
for _, ns := range s.ns_svc.All() { for _, ns := range s.ns_svc.All() {

@ -24,7 +24,7 @@ var file_ref1 = swampfile.FileReference{"/path1", "ns1"}
var file_ref2 = swampfile.FileReference{"/path1", "ns2"} var file_ref2 = swampfile.FileReference{"/path1", "ns2"}
var file_ref3 = swampfile.FileReference{"/path2", "ns1"} var file_ref3 = swampfile.FileReference{"/path2", "ns1"}
func NewTestSwampFileService() SwampFileService { func NewTestDataSwampService() DataSwampService {
file_repo := m_swampfile.NewRepository() file_repo := m_swampfile.NewRepository()
ns_repo := m_namespace.NewRepository() ns_repo := m_namespace.NewRepository()
@ -37,12 +37,12 @@ func NewTestSwampFileService() SwampFileService {
1024, 1024,
) )
return *NewSwampFileService(*ns_svc, file_repo, logger) return *NewDataSwampService(*ns_svc, file_repo, logger)
} }
func TestFileDontExist(t *testing.T) { func TestFileDontExist(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
outfile, err := s.OpenOutFile(file_ref1) outfile, err := s.OpenOutFile(file_ref1)
is.True(err == swampfile.ErrNotExists) is.True(err == swampfile.ErrNotExists)
@ -51,7 +51,7 @@ func TestFileDontExist(t *testing.T) {
func TestFileIsStored(t *testing.T) { func TestFileIsStored(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
fakefile := bytes.NewBufferString("My bog data") fakefile := bytes.NewBufferString("My bog data")
@ -72,7 +72,7 @@ func TestFileIsStored(t *testing.T) {
func TestFileIsReadBack(t *testing.T) { func TestFileIsReadBack(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
infile := bytes.NewBufferString("My bog data") infile := bytes.NewBufferString("My bog data")
@ -88,7 +88,7 @@ func TestFileIsReadBack(t *testing.T) {
func TestNSIsolation(t *testing.T) { func TestNSIsolation(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
ns1_file := bytes.NewBufferString("My bog data ns1") ns1_file := bytes.NewBufferString("My bog data ns1")
ns2_file := bytes.NewBufferString("My bog data ns2") ns2_file := bytes.NewBufferString("My bog data ns2")
@ -106,7 +106,7 @@ func TestNSIsolation(t *testing.T) {
func TestPathStrictMode(t *testing.T) { func TestPathStrictMode(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
ns_file := bytes.NewBufferString("My bog data ns1") ns_file := bytes.NewBufferString("My bog data ns1")
@ -126,7 +126,7 @@ func TestPathStrictMode(t *testing.T) {
func TestQuotaWithContenSizeLieOver(t *testing.T) { func TestQuotaWithContenSizeLieOver(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
largefakefile := bytes.NewBufferString("") largefakefile := bytes.NewBufferString("")
@ -141,7 +141,7 @@ func TestQuotaWithContenSizeLieOver(t *testing.T) {
func TestQuotaWithContenSizeLieUnder(t *testing.T) { func TestQuotaWithContenSizeLieUnder(t *testing.T) {
is := is.New(t) is := is.New(t)
s := NewTestSwampFileService() s := NewTestDataSwampService()
largefakefile := bytes.NewBufferString("small") largefakefile := bytes.NewBufferString("small")
@ -165,7 +165,7 @@ func TestCleanUpExpired(t *testing.T) {
1024, 1024,
) )
s := NewSwampFileService(*ns_svc, file_repo, logger) s := NewDataSwampService(*ns_svc, file_repo, logger)
fakefile := bytes.NewBufferString("My bog") fakefile := bytes.NewBufferString("My bog")
err := s.SaveFile(file_ref1, fakefile, int64(fakefile.Len())) err := s.SaveFile(file_ref1, fakefile, int64(fakefile.Len()))

@ -22,7 +22,7 @@ type Router interface {
type Bog struct { type Bog struct {
router Router router Router
adminRouter Router adminRouter Router
file_service dataswamp.SwampFileService file_service dataswamp.DataSwampService
address string address string
adminAddress string adminAddress string
logger util.Logger logger util.Logger
@ -143,7 +143,7 @@ func New(config *Configuration) *Bog {
config.Quota.ParsedSizeBytes(), config.Quota.ParsedSizeBytes(),
) )
b.file_service = *dataswamp.NewSwampFileService( b.file_service = *dataswamp.NewDataSwampService(
*ns_svc, *ns_svc,
fsSwampRepo, fsSwampRepo,
logger, logger,

@ -34,7 +34,7 @@ func TestApplication(t *testing.T) {
1000, 1000,
) )
file_service := dataswamp.NewSwampFileService( file_service := dataswamp.NewDataSwampService(
*ns_svc, *ns_svc,
swampfile.NewRepository(), swampfile.NewRepository(),
logger, logger,

Loading…
Cancel
Save