Documentation ¶
Index ¶
- func CheckPassword(pw, salt, hash []byte) bool
- func WrapOut(w io.Writer, s fmt.Stringer) io.Writer
- type FakeFile
- type LogSet
- type MemVolumeRecorder
- func (vr *MemVolumeRecorder) AddFile(vf *VFile, volume *Volume) error
- func (vr *MemVolumeRecorder) AddVolume(v *Volume) error
- func (vr *MemVolumeRecorder) DeleteFile(id, volumeID string) error
- func (vr *MemVolumeRecorder) GetFile(id string, vol *Volume) (*VFile, error)
- func (vr *MemVolumeRecorder) GetVolume(name, password, id string) (*Volume, error)
- type MyFilestoreServer
- func (mfs *MyFilestoreServer) CreateVolume(ctx context.Context, vd *pb.VolumeDef) (*pb.VolumeDef, error)
- func (mfs *MyFilestoreServer) Delete(ctx context.Context, fb *pb.FileBlob) (*pb.FileBlob, error)
- func (mfs *MyFilestoreServer) Get(fb *filestore.FileBlob, stream filestore.FileStore_GetServer) error
- func (mfs *MyFilestoreServer) GetVolume(ctx context.Context, vd *pb.VolumeDef) (*pb.VolumeDef, error)
- func (mfs *MyFilestoreServer) Put(stream pb.FileStore_PutServer) error
- func (mfs *MyFilestoreServer) RunServer() error
- type Out
- type PostgresVolumeRecorder
- func (pvr *PostgresVolumeRecorder) AddFile(vf *VFile, v *Volume) error
- func (pvr *PostgresVolumeRecorder) AddVolume(v *Volume) error
- func (pvr *PostgresVolumeRecorder) DeleteFile(id, volume_id string) error
- func (pvr *PostgresVolumeRecorder) GetFile(id string, vol *Volume) (*VFile, error)
- func (pvr *PostgresVolumeRecorder) GetVolume(name, password, id string) (*Volume, error)
- type TimeStruct
- type VFile
- type Volume
- func (v *Volume) CheckPassword(pw []byte) bool
- func (v *Volume) Create(fb *filestore.FileBlob, tags []string, attrs map[string]string) (*VFile, error)
- func (v *Volume) DeleteFile(id string) error
- func (v *Volume) GetPath() string
- func (v *Volume) Open(id string) (*VFile, error)
- func (v *Volume) SignedToken(skey []byte) (string, error)
- type VolumeClaims
- type VolumeManager
- func (vm *VolumeManager) AddFile(vf *VFile, v *Volume) error
- func (vm *VolumeManager) CreateVolume(name, password string, tags []string, attrs map[string]string) (*Volume, error)
- func (vm *VolumeManager) DeleteFile(id, volume_id string) error
- func (vm *VolumeManager) GetPath(pathname string) (string, error)
- func (vm *VolumeManager) GetVolume(name, password, id string) (*Volume, error)
- type VolumeRecorder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPassword ¶
CheckPassword - Check provided password against previously computed hash.
Types ¶
type LogSet ¶
type LogSet struct { Info *log.Logger Error *log.Logger // Error still just sends to Stdout TeeError *log.Logger // TeeError sends to both Stdout and Stderr Debug *log.Logger Warn *log.Logger }
LogSet - the control structure for the log server.
type MemVolumeRecorder ¶
type MemVolumeRecorder struct {
// contains filtered or unexported fields
}
MemVolumeRecorder - this structure is the controller for the set of active volumes In this case I'm doing it all in-memory, but for a production system this would actually talk to a database of some kind.
func (*MemVolumeRecorder) AddFile ¶
func (vr *MemVolumeRecorder) AddFile(vf *VFile, volume *Volume) error
AddFile - add the file to the record of files.
func (*MemVolumeRecorder) AddVolume ¶
func (vr *MemVolumeRecorder) AddVolume(v *Volume) error
AddVolume -
func (*MemVolumeRecorder) DeleteFile ¶
func (vr *MemVolumeRecorder) DeleteFile(id, volumeID string) error
DeleteFile - Remove any record of the file.
type MyFilestoreServer ¶
type MyFilestoreServer struct {
// contains filtered or unexported fields
}
MyFilestoreServer - this is the actual implementation of the filestore server. It may make sense later to have different types of these, if we start working with vastly different file storage technologies.
func NewMyFilestoreServer ¶
func NewMyFilestoreServer(logs *LogSet, config *viper.Viper, vm *VolumeManager) *MyFilestoreServer
NewMyFilestoreServer - allocate a new FilestoreServer object
func (*MyFilestoreServer) CreateVolume ¶
func (mfs *MyFilestoreServer) CreateVolume(ctx context.Context, vd *pb.VolumeDef) (*pb.VolumeDef, error)
CreateVolume - open a volume for reading or writing.
func (*MyFilestoreServer) Get ¶
func (mfs *MyFilestoreServer) Get(fb *filestore.FileBlob, stream filestore.FileStore_GetServer) error
Get - implement the GetFile command
func (*MyFilestoreServer) GetVolume ¶
func (mfs *MyFilestoreServer) GetVolume(ctx context.Context, vd *pb.VolumeDef) (*pb.VolumeDef, error)
GetVolume - Return a pre-existing volume
func (*MyFilestoreServer) Put ¶
func (mfs *MyFilestoreServer) Put(stream pb.FileStore_PutServer) error
Put - Transfer file to server This must be used whenever the file is more than 4mb, as that is the maximum default grpc message size.
func (*MyFilestoreServer) RunServer ¶
func (mfs *MyFilestoreServer) RunServer() error
RunServer - this is the entrypoint of the GRPC file storage service
type PostgresVolumeRecorder ¶
type PostgresVolumeRecorder struct {
// contains filtered or unexported fields
}
PostgresVolumeRecorder - This is the volume recorder which uses Postgres as the persistant store
func (*PostgresVolumeRecorder) AddFile ¶
func (pvr *PostgresVolumeRecorder) AddFile(vf *VFile, v *Volume) error
AddFile - Add a file record
func (*PostgresVolumeRecorder) AddVolume ¶
func (pvr *PostgresVolumeRecorder) AddVolume(v *Volume) error
AddVolume - Add volume to records
func (*PostgresVolumeRecorder) DeleteFile ¶
func (pvr *PostgresVolumeRecorder) DeleteFile(id, volume_id string) error
DeleteFile - Remove file from records
func (*PostgresVolumeRecorder) GetFile ¶
func (pvr *PostgresVolumeRecorder) GetFile(id string, vol *Volume) (*VFile, error)
GetFile - Return file data, specifically the path
func (*PostgresVolumeRecorder) GetVolume ¶
func (pvr *PostgresVolumeRecorder) GetVolume(name, password, id string) (*Volume, error)
GetVolume - return a volume from the records. The third argument "id" is there as an override. If this volume is being used as part of a 'put' or 'get' operation, then the password won't be provided, as it's not part of the token. The ID of the volume is however, and you can only get the volume ID if you open the volume with the password, so we have that level of security.
type TimeStruct ¶
type TimeStruct struct{}
TimeStruct - so we can override the time format
func (TimeStruct) String ¶
func (ts TimeStruct) String() string
type VFile ¶
type VFile struct { ID string Filename string // Original filename Path string // Path includes filename Type string // MIME file type Size int // Filesize // contains filtered or unexported fields }
VFile - control structure for a volume-backed file
type Volume ¶
type Volume struct { ID string `db:"id"` Created time.Time `db:"created"` Name string `db:"name"` Salt []byte `db:"salt"` PWHash []byte `db:"pwhash"` Path string `db:"path"` TestMode bool `db:"testmode"` Tags []string Attrs map[string]string // contains filtered or unexported fields }
Volume - represents a collection of file objects
func (*Volume) CheckPassword ¶
CheckPassword - compare a user provided password with the one stored with the volume.
func (*Volume) Create ¶
func (v *Volume) Create(fb *filestore.FileBlob, tags []string, attrs map[string]string) (*VFile, error)
Create - create a new file object within the volume
func (*Volume) DeleteFile ¶
DeleteFile - remove a file both from disk and from the database.
type VolumeClaims ¶
type VolumeClaims struct {
jwt.StandardClaims
}
VolumeClaims - this is where we store private volume specific data in the token.
func GetTokenClaims ¶
func GetTokenClaims(tokenstr string, skey []byte) (*VolumeClaims, error)
GetTokenClaims - parse the claims structure from thetoken
type VolumeManager ¶
type VolumeManager struct {
// contains filtered or unexported fields
}
VolumeManager - this structure is the controller for the set of active volumes In this case I'm doing it all in-memory, but for a production system this would actually talk to a database of some kind.
func NewVolumeManager ¶
func NewVolumeManager(vr VolumeRecorder, paths map[string]string) *VolumeManager
NewVolumeManager - allocate a new VolumeManager
func (*VolumeManager) AddFile ¶
func (vm *VolumeManager) AddFile(vf *VFile, v *Volume) error
AddFile - Add a file record
func (*VolumeManager) CreateVolume ¶
func (vm *VolumeManager) CreateVolume(name, password string, tags []string, attrs map[string]string) (*Volume, error)
CreateVolume - Create a new volume.
func (*VolumeManager) DeleteFile ¶
func (vm *VolumeManager) DeleteFile(id, volume_id string) error
DeleteFile - Remove file from record
type VolumeRecorder ¶
type VolumeRecorder interface { AddFile(vf *VFile, volume *Volume) error DeleteFile(id, volumeID string) error GetFile(id string, volume *Volume) (*VFile, error) AddVolume(v *Volume) error GetVolume(name, password, id string) (*Volume, error) }
VolumeRecorder - interface for the data backing store.
func NewMemVolumeRecorder ¶
func NewMemVolumeRecorder() VolumeRecorder
NewMemVolumeRecorder - allocate a new VolumeRecorder
func NewPostgresVolumeRecorder ¶
func NewPostgresVolumeRecorder(cfg map[string]interface{}) (VolumeRecorder, error)
NewPostgresVolumeRecorder - Allocate a new PG recorder
func NewRedisVolumeRecorder ¶
func NewRedisVolumeRecorder(host string, db int) (VolumeRecorder, error)
NewRedisVolumeRecorder - Allocate a new redis backend handler