3
0

Renamed pkg/store to pkg/objstore (Object Store)

This commit is contained in:
Denis Arh 2020-09-15 20:14:34 +02:00
parent 52b8f44d6c
commit 5e55340759
20 changed files with 70 additions and 70 deletions

View File

@ -168,7 +168,7 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
// will most likely be merged in the future
err = sysService.Initialize(ctx, app.Log, app.Store, sysService.Config{
ActionLog: app.Opt.ActionLog,
Storage: app.Opt.Storage,
Storage: app.Opt.ObjStore,
})
if err != nil {
@ -181,7 +181,7 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
// will most likely be merged in the future
err = cmpService.Initialize(ctx, app.Log, app.Store, cmpService.Config{
ActionLog: app.Opt.ActionLog,
Storage: app.Opt.Storage,
Storage: app.Opt.ObjStore,
})
if err != nil {
@ -194,7 +194,7 @@ func (app *CortezaApp) InitServices(ctx context.Context) (err error) {
// will most likely be merged in the future
err = msgService.Initialize(ctx, app.Log, app.Store, msgService.Config{
ActionLog: app.Opt.ActionLog,
Storage: app.Opt.Storage,
Storage: app.Opt.ObjStore,
})
if err != nil {
@ -231,11 +231,11 @@ func (app *CortezaApp) Provision(ctx context.Context) (err error) {
return fmt.Errorf("could not provision system: %w", err)
}
if err = compose.Provision(ctx, app.Log); err != nil {
if err = compose.Provision(ctx, app.Log, app.Store); err != nil {
return fmt.Errorf("could not provision compose: %w", err)
}
if err = messaging.Provision(ctx, app.Log); err != nil {
if err = messaging.Provision(ctx, app.Log, app.Store); err != nil {
return fmt.Errorf("could not provision messaging: %w", err)
}

View File

@ -14,7 +14,7 @@ type (
Upgrade options.UpgradeOpt
Provision options.ProvisionOpt
Sentry options.SentryOpt
Storage options.StorageOpt
ObjStore options.ObjectStoreOpt
Corredor options.CorredorOpt
Monitor options.MonitorOpt
WaitFor options.WaitForOpt
@ -38,7 +38,7 @@ func NewOptions(prefix ...string) *Options {
Upgrade: *options.Upgrade(p),
Provision: *options.Provision(p),
Sentry: *options.Sentry(p),
Storage: *options.Storage(p),
ObjStore: *options.ObjectStore(p),
Corredor: *options.Corredor(),
Monitor: *options.Monitor(p),
WaitFor: *options.WaitFor(p),

View File

@ -7,7 +7,7 @@ import (
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
files "github.com/cortezaproject/corteza-server/pkg/store"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/store"
"github.com/disintegration/imaging"
"github.com/edwvee/exiffix"
@ -29,7 +29,7 @@ type (
attachment struct {
ctx context.Context
actionlog actionlog.Recorder
files files.Store
objects objstore.Store
ac attachmentAccessController
store store.Storer
}
@ -57,11 +57,11 @@ type (
}
)
func Attachment(store files.Store) AttachmentService {
func Attachment(store objstore.Store) AttachmentService {
return (&attachment{
files: store,
ac: DefaultAccessControl,
store: DefaultNgStore,
objects: store,
ac: DefaultAccessControl,
store: DefaultNgStore,
}).With(context.Background())
}
@ -70,7 +70,7 @@ func (svc attachment) With(ctx context.Context) AttachmentService {
ctx: ctx,
actionlog: DefaultActionlog,
ac: svc.ac,
files: svc.files,
objects: svc.objects,
store: svc.store,
}
}
@ -235,7 +235,7 @@ func (svc attachment) OpenOriginal(att *types.Attachment) (io.ReadSeeker, error)
return nil, nil
}
return svc.files.Open(att.Url)
return svc.objects.Open(att.Url)
}
func (svc attachment) OpenPreview(att *types.Attachment) (io.ReadSeeker, error) {
@ -243,7 +243,7 @@ func (svc attachment) OpenPreview(att *types.Attachment) (io.ReadSeeker, error)
return nil, nil
}
return svc.files.Open(att.PreviewUrl)
return svc.objects.Open(att.PreviewUrl)
}
func (svc attachment) CreatePageAttachment(namespaceID uint64, name string, size int64, fh io.ReadSeeker, pageID uint64) (att *types.Attachment, err error) {
@ -354,7 +354,7 @@ func (svc attachment) create(name string, size int64, fh io.ReadSeeker, att *typ
att.OwnerID = auth.GetIdentityFromContext(svc.ctx).Identity()
}
if svc.files == nil {
if svc.objects == nil {
return errors.New("can not create attachment: store handler not set")
}
@ -369,10 +369,10 @@ func (svc attachment) create(name string, size int64, fh io.ReadSeeker, att *typ
return AttachmentErrFailedToExtractMimeType(aProps).Wrap(err)
}
att.Url = svc.files.Original(att.ID, att.Meta.Original.Extension)
att.Url = svc.objects.Original(att.ID, att.Meta.Original.Extension)
aProps.setUrl(att.Url)
if err = svc.files.Save(att.Url, fh); err != nil {
if err = svc.objects.Save(att.Url, fh); err != nil {
return AttachmentErrFailedToStoreFile(aProps).Wrap(err)
}
@ -499,9 +499,9 @@ func (svc attachment) processImage(original io.ReadSeeker, att *types.Attachment
meta.Extension = f2e[previewFormat]
// Can and how we make a preview of this attachment?
att.PreviewUrl = svc.files.Preview(att.ID, meta.Extension)
att.PreviewUrl = svc.objects.Preview(att.ID, meta.Extension)
return svc.files.Save(att.PreviewUrl, buf)
return svc.objects.Save(att.PreviewUrl, buf)
}
var _ AttachmentService = &attachment{}

View File

@ -148,14 +148,14 @@ func (svc notification) procEmailRecipients(ctx context.Context, m *gomail.Messa
return nil
}
// procEmailAttachments treats given strings (URLs) as remote files, downloads and attaches them to
// procEmailAttachments treats given strings (URLs) as remote objects, downloads and attaches them to
// the message
//
// This could/should be easily extended to support data URLs as well
// see https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
func (svc notification) procEmailAttachments(ctx context.Context, message *gomail.Message, aa ...string) error {
var (
// threading safely (when multiple files are to be attached)
// threading safely (when multiple objects are to be attached)
l = &sync.Mutex{}
wg = &sync.WaitGroup{}

View File

@ -9,11 +9,11 @@ import (
"github.com/cortezaproject/corteza-server/pkg/corredor"
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/healthcheck"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/pkg/objstore/minio"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
"github.com/cortezaproject/corteza-server/pkg/options"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/store"
"github.com/cortezaproject/corteza-server/pkg/store/minio"
"github.com/cortezaproject/corteza-server/pkg/store/plain"
ngStore "github.com/cortezaproject/corteza-server/store"
systemService "github.com/cortezaproject/corteza-server/system/service"
"go.uber.org/zap"
@ -29,7 +29,7 @@ type (
Config struct {
ActionLog options.ActionLogOpt
Storage options.StorageOpt
Storage options.ObjectStoreOpt
}
eventDispatcher interface {
@ -39,7 +39,7 @@ type (
)
var (
DefaultStore store.Store
DefaultObjectStore objstore.Store
// DefaultNgStore is an interface to storage backend(s)
// ng (next-gen) is a temporary prefix
@ -106,7 +106,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
DefaultAccessControl = AccessControl(DefaultPermissions)
if DefaultStore == nil {
if DefaultObjectStore == nil {
const svcPath = "compose"
if c.Storage.MinioEndpoint != "" {
var bucket = svcPath
@ -114,7 +114,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
bucket = c.Storage.MinioBucket + "/" + svcPath
}
DefaultStore, err = minio.New(bucket, minio.Options{
DefaultObjectStore, err = minio.New(bucket, minio.Options{
Endpoint: c.Storage.MinioEndpoint,
Secure: c.Storage.MinioSecure,
Strict: c.Storage.MinioStrict,
@ -130,14 +130,14 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
zap.Error(err))
} else {
path := c.Storage.Path + "/" + svcPath
DefaultStore, err = plain.New(path)
DefaultObjectStore, err = plain.New(path)
log.Info("initializing store",
zap.String("path", path),
zap.Error(err))
}
hcd.Add(store.Healthcheck(DefaultStore), "Store/Compose")
hcd.Add(objstore.Healthcheck(DefaultObjectStore), "Store/Compose")
if err != nil {
return err
@ -154,7 +154,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
DefaultPage = Page()
DefaultChart = Chart()
DefaultNotification = Notification()
DefaultAttachment = Attachment(DefaultStore)
DefaultAttachment = Attachment(DefaultObjectStore)
RegisterIteratorProviders()

View File

@ -9,7 +9,7 @@ import (
"github.com/cortezaproject/corteza-server/pkg/actionlog"
intAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
files "github.com/cortezaproject/corteza-server/pkg/store"
files "github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/store"
"github.com/disintegration/imaging"
"github.com/edwvee/exiffix"

View File

@ -4,11 +4,11 @@ import (
"context"
"github.com/cortezaproject/corteza-server/pkg/actionlog"
"github.com/cortezaproject/corteza-server/pkg/healthcheck"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/pkg/objstore/minio"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
"github.com/cortezaproject/corteza-server/pkg/options"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/store"
"github.com/cortezaproject/corteza-server/pkg/store/minio"
"github.com/cortezaproject/corteza-server/pkg/store/plain"
ngStore "github.com/cortezaproject/corteza-server/store"
"go.uber.org/zap"
"time"
@ -26,12 +26,12 @@ type (
Config struct {
ActionLog options.ActionLogOpt
Storage options.StorageOpt
Storage options.ObjectStoreOpt
}
)
var (
DefaultStore store.Store
DefaultObjectStore objstore.Store
// DefaultNgStore is an interface to storage backend(s)
// ng (next-gen) is a temporary prefix
@ -86,7 +86,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
DefaultAccessControl = AccessControl(DefaultPermissions)
if DefaultStore == nil {
if DefaultObjectStore == nil {
const svcPath = "messaging"
if c.Storage.MinioEndpoint != "" {
var bucket = svcPath
@ -94,7 +94,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
bucket = c.Storage.MinioBucket + "/" + svcPath
}
DefaultStore, err = minio.New(bucket, minio.Options{
DefaultObjectStore, err = minio.New(bucket, minio.Options{
Endpoint: c.Storage.MinioEndpoint,
Secure: c.Storage.MinioSecure,
Strict: c.Storage.MinioStrict,
@ -110,7 +110,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
zap.Error(err))
} else {
path := c.Storage.Path + "/" + svcPath
DefaultStore, err = plain.New(path)
DefaultObjectStore, err = plain.New(path)
log.Info("initializing store",
zap.String("path", path),
@ -122,11 +122,11 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
}
}
hcd.Add(store.Healthcheck(DefaultStore), "Store/Messaging")
hcd.Add(objstore.Healthcheck(DefaultObjectStore), "ObjectStore/Messaging")
DefaultEvent = Event(ctx)
DefaultChannel = Channel(ctx)
DefaultAttachment = Attachment(ctx, DefaultStore)
DefaultAttachment = Attachment(ctx, DefaultObjectStore)
DefaultMessage = Message(ctx)
DefaultCommand = Command(ctx)

View File

@ -1254,7 +1254,7 @@ var _ClientScripts_serviceDesc = grpc.ServiceDesc{
Metadata: "service-corredor.proto",
}
// StorageClient is the client API for Storage service.
// StorageClient is the client API for ObjStore service.
//
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
type StorageClient interface {
@ -1268,7 +1268,7 @@ func NewStorageClient(cc *grpc.ClientConn) StorageClient {
return &storageClient{cc}
}
// StorageServer is the server API for Storage service.
// StorageServer is the server API for ObjStore service.
type StorageServer interface {
}
@ -1281,7 +1281,7 @@ func RegisterStorageServer(s *grpc.Server, srv StorageServer) {
}
var _Storage_serviceDesc = grpc.ServiceDesc{
ServiceName: "corredor.Storage",
ServiceName: "corredor.ObjStore",
HandlerType: (*StorageServer)(nil),
Methods: []grpc.MethodDesc{},
Streams: []grpc.StreamDesc{},

View File

@ -1,4 +1,4 @@
package store
package objstore
import (
"context"

View File

@ -1,4 +1,4 @@
package store
package objstore
import (
"context"

View File

@ -1,4 +1,4 @@
package store
package objstore
import (
"io"

View File

@ -1,7 +1,7 @@
package options
type (
StorageOpt struct {
ObjectStoreOpt struct {
Path string `env:"STORAGE_PATH"`
MinioEndpoint string `env:"MINIO_ENDPOINT"`
@ -14,8 +14,8 @@ type (
}
)
func Storage(pfix string) (o *StorageOpt) {
o = &StorageOpt{
func ObjectStore(pfix string) (o *ObjectStoreOpt) {
o = &ObjectStoreOpt{
Path: "var/store",
// Make minio secure by default

View File

@ -6,7 +6,7 @@ import (
"github.com/cortezaproject/corteza-server/pkg/actionlog"
intAuth "github.com/cortezaproject/corteza-server/pkg/auth"
"github.com/cortezaproject/corteza-server/pkg/id"
files "github.com/cortezaproject/corteza-server/pkg/store"
files "github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/types"
"github.com/disintegration/imaging"

View File

@ -8,11 +8,11 @@ import (
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/healthcheck"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/objstore"
"github.com/cortezaproject/corteza-server/pkg/objstore/minio"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
"github.com/cortezaproject/corteza-server/pkg/options"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/store"
"github.com/cortezaproject/corteza-server/pkg/store/minio"
"github.com/cortezaproject/corteza-server/pkg/store/plain"
ngStore "github.com/cortezaproject/corteza-server/store"
"github.com/cortezaproject/corteza-server/system/types"
"go.uber.org/zap"
@ -27,7 +27,7 @@ type (
Config struct {
ActionLog options.ActionLogOpt
Storage options.StorageOpt
Storage options.ObjectStoreOpt
}
permitChecker interface {
@ -43,7 +43,7 @@ type (
)
var (
DefaultStore store.Store
DefaultObjectStore objstore.Store
// DefaultNgStore is an interface to storage backend(s)
// ng (next-gen) is a temporary prefix
@ -142,7 +142,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
DefaultSettings = Settings(DefaultNgStore, DefaultLogger, DefaultAccessControl, CurrentSettings)
if DefaultStore == nil {
if DefaultObjectStore == nil {
const svcPath = "compose"
if c.Storage.MinioEndpoint != "" {
var bucket = svcPath
@ -150,7 +150,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
bucket = c.Storage.MinioBucket + "/" + svcPath
}
DefaultStore, err = minio.New(bucket, minio.Options{
DefaultObjectStore, err = minio.New(bucket, minio.Options{
Endpoint: c.Storage.MinioEndpoint,
Secure: c.Storage.MinioSecure,
Strict: c.Storage.MinioStrict,
@ -166,7 +166,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
zap.Error(err))
} else {
path := c.Storage.Path + "/" + svcPath
DefaultStore, err = plain.New(path)
DefaultObjectStore, err = plain.New(path)
log.Info("initializing store",
zap.String("path", path),
zap.Error(err))
@ -177,7 +177,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
}
}
hcd.Add(store.Healthcheck(DefaultStore), "Store/System")
hcd.Add(objstore.Healthcheck(DefaultObjectStore), "ObjectStore/System")
DefaultAuthNotification = AuthNotification(CurrentSettings)
DefaultAuth = Auth()
@ -187,7 +187,7 @@ func Initialize(ctx context.Context, log *zap.Logger, s ngStore.Storer, c Config
DefaultReminder = Reminder(ctx)
DefaultSink = Sink()
DefaultStatistics = Statistics()
DefaultAttachment = Attachment(DefaultStore)
DefaultAttachment = Attachment(DefaultObjectStore)
return
}

View File

@ -13,8 +13,8 @@ import (
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/logger"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/store/plain"
sysTypes "github.com/cortezaproject/corteza-server/system/types"
"github.com/cortezaproject/corteza-server/tests/helpers"
"github.com/go-chi/chi"
@ -55,7 +55,7 @@ func InitTestApp() {
testApp = helpers.NewIntegrationTestApp(ctx, func(app *app.CortezaApp) (err error) {
service.DefaultNgStore = app.Store
service.DefaultPermissions = permissions.NewTestService(ctx, zap.NewNop(), app.Store)
service.DefaultStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
service.DefaultObjectStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
if err != nil {
return err
}

View File

@ -12,8 +12,8 @@ import (
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/logger"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/store/plain"
sysTypes "github.com/cortezaproject/corteza-server/system/types"
"github.com/cortezaproject/corteza-server/tests/helpers"
"github.com/go-chi/chi"
@ -57,7 +57,7 @@ func InitTestApp() {
testApp = helpers.NewIntegrationTestApp(ctx, func(app *app.CortezaApp) (err error) {
service.DefaultPermissions = permissions.NewTestService(ctx, zap.NewNop(), app.Store)
service.DefaultStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
service.DefaultObjectStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
if err != nil {
return err
}

View File

@ -10,9 +10,9 @@ import (
"github.com/cortezaproject/corteza-server/pkg/eventbus"
"github.com/cortezaproject/corteza-server/pkg/id"
"github.com/cortezaproject/corteza-server/pkg/logger"
"github.com/cortezaproject/corteza-server/pkg/objstore/plain"
"github.com/cortezaproject/corteza-server/pkg/permissions"
"github.com/cortezaproject/corteza-server/pkg/rand"
"github.com/cortezaproject/corteza-server/pkg/store/plain"
"github.com/cortezaproject/corteza-server/store/sqlite3"
"github.com/cortezaproject/corteza-server/system/rest"
"github.com/cortezaproject/corteza-server/system/service"
@ -65,7 +65,7 @@ func InitTestApp() {
testApp = helpers.NewIntegrationTestApp(ctx, func(app *app.CortezaApp) (err error) {
service.DefaultPermissions = permissions.NewTestService(ctx, zap.NewNop(), app.Store)
service.DefaultStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
service.DefaultObjectStore, err = plain.NewWithAfero(afero.NewMemMapFs(), "test")
if err != nil {
return err
}