Documentation
¶
Index ¶
- Constants
- func NewProtoDirectory(dir *Directory) *proto.Directory
- func NewProtoPath(absolute string) *proto.Path
- func NewProtoSearchMatch(match SearchMatch) *proto.SearchMatch
- func NewProtoSearchResponse(matches []SearchMatch) *proto.SearchResponse
- type Directory
- func (dir *Directory) AddFile(file *file.File, fp string) string
- func (dir *Directory) AggregateFiles(p string) map[string]*file.File
- func (dir *Directory) FileByPath(p string) *file.File
- func (dir *Directory) FilesByPath(p string) map[string]*file.File
- func (dir *Directory) RemoveFile(file *file.File)
- func (dir *Directory) Search(search string) []SearchMatch
- type DirectoryApplication
- func (app *DirectoryApplication) Create(ctx context.Context, uid int32) (*Directory, error)
- func (app *DirectoryApplication) Delete(ctx context.Context, uid int32, p string) (*Directory, error)
- func (app *DirectoryApplication) Get(ctx context.Context, uid int32, p string) (*Directory, error)
- func (app *DirectoryApplication) Move(ctx context.Context, uid int32, paths []string, dest string) (*Directory, error)
- func (app *DirectoryApplication) RegisterFile(ctx context.Context, file *file.File, uid int32, fp string) (string, error)
- func (app *DirectoryApplication) Search(ctx context.Context, uid int32, regex string) ([]SearchMatch, error)
- func (app *DirectoryApplication) UnregisterFile(ctx context.Context, f *file.File, uid int32) error
- type DirectoryGrpcService
- func (server *DirectoryGrpcService) Delete(ctx context.Context, path *proto.Path) (*proto.Directory, error)
- func (server *DirectoryGrpcService) Get(ctx context.Context, path *proto.Path) (*proto.Directory, error)
- func (server *DirectoryGrpcService) Move(ctx context.Context, req *proto.MoveRequest) (*proto.Directory, error)
- func (server *DirectoryGrpcService) Search(ctx context.Context, req *proto.SearchRequest) (*proto.SearchResponse, error)
- type DirectoryRepository
- type MongoDirectoryRepository
- func (repo *MongoDirectoryRepository) Create(ctx context.Context, dir *Directory) error
- func (repo *MongoDirectoryRepository) Delete(ctx context.Context, dir *Directory) error
- func (repo *MongoDirectoryRepository) FindByUserId(ctx context.Context, userId int32, options *RepoOptions) (*Directory, error)
- func (repo *MongoDirectoryRepository) Save(ctx context.Context, dir *Directory) error
- type RepoOptions
- type SearchMatch
Constants ¶
const (
PathSeparator = "/"
)
Variables ¶
This section is empty.
Functions ¶
func NewProtoDirectory ¶
func NewProtoPath ¶
func NewProtoSearchMatch ¶
func NewProtoSearchMatch(match SearchMatch) *proto.SearchMatch
func NewProtoSearchResponse ¶
func NewProtoSearchResponse(matches []SearchMatch) *proto.SearchResponse
Types ¶
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
func NewDirectory ¶
func (*Directory) AggregateFiles ¶
func (*Directory) RemoveFile ¶
func (*Directory) Search ¶
func (dir *Directory) Search(search string) []SearchMatch
type DirectoryApplication ¶
type DirectoryApplication struct {
// contains filtered or unexported fields
}
func NewDirectoryApplication ¶
func NewDirectoryApplication(dirRepo DirectoryRepository, fileRepo file.FileRepository, logger *zap.Logger) *DirectoryApplication
func (*DirectoryApplication) Create ¶
Create creates a new directory if, and only if, there is no other for the given user uid. Otherwise returns an error.
func (*DirectoryApplication) Delete ¶
func (app *DirectoryApplication) Delete(ctx context.Context, uid int32, p string) (*Directory, error)
Delete removes from the directory all those files whose path matches the given one.
func (*DirectoryApplication) Get ¶
Get agregates into a list of files all those files matching the given path.
func (*DirectoryApplication) Move ¶
func (app *DirectoryApplication) Move(ctx context.Context, uid int32, paths []string, dest string) (*Directory, error)
Move replaces the destination path to all these file paths in the directory matching any of the given paths.
func (*DirectoryApplication) RegisterFile ¶
func (app *DirectoryApplication) RegisterFile(ctx context.Context, file *file.File, uid int32, fp string) (string, error)
RegisterFile registers the given file into the user uid directory. The given path may change if, and only if, another file with the same name exists in the same path.
func (*DirectoryApplication) Search ¶
func (app *DirectoryApplication) Search(ctx context.Context, uid int32, regex string) ([]SearchMatch, error)
Search returns alls these files whose path matches with the given regex
func (*DirectoryApplication) UnregisterFile ¶
UnregisterFile unregisters the given file from the directory. This action may trigger the file's deletion if it becomes with no owner once unregistered.
type DirectoryGrpcService ¶
type DirectoryGrpcService struct { proto.UnimplementedDirectoryServiceServer // contains filtered or unexported fields }
func NewDirectoryGrpcServer ¶
func NewDirectoryGrpcServer(app *DirectoryApplication, logger *zap.Logger, authHeader string) *DirectoryGrpcService
func (*DirectoryGrpcService) Move ¶
func (server *DirectoryGrpcService) Move(ctx context.Context, req *proto.MoveRequest) (*proto.Directory, error)
func (*DirectoryGrpcService) Search ¶
func (server *DirectoryGrpcService) Search(ctx context.Context, req *proto.SearchRequest) (*proto.SearchResponse, error)
type DirectoryRepository ¶
type MongoDirectoryRepository ¶
type MongoDirectoryRepository struct {
// contains filtered or unexported fields
}
func NewMongoDirectoryRepository ¶
func NewMongoDirectoryRepository(db *mongo.Database, fileRepo file.FileRepository, logger *zap.Logger) *MongoDirectoryRepository
func (*MongoDirectoryRepository) Create ¶
func (repo *MongoDirectoryRepository) Create(ctx context.Context, dir *Directory) error
func (*MongoDirectoryRepository) Delete ¶
func (repo *MongoDirectoryRepository) Delete(ctx context.Context, dir *Directory) error
func (*MongoDirectoryRepository) FindByUserId ¶
func (repo *MongoDirectoryRepository) FindByUserId(ctx context.Context, userId int32, options *RepoOptions) (*Directory, error)
type RepoOptions ¶
type RepoOptions struct {
LazyLoading bool
}
type SearchMatch ¶
type SearchMatch struct {
// contains filtered or unexported fields
}