Documentation
¶
Index ¶
- Variables
- type ClaimMode
- type ClaimRequest
- type ColabDatabase
- type FileClaim
- type FileInfo
- func (fi *FileInfo) CheckOwner(userId string) bool
- func (fi *FileInfo) Claim(userId string, fileHash string, claimMode ClaimMode) error
- func (fi *FileInfo) GetBranchName() string
- func (fi *FileInfo) GetClaimMode() ClaimMode
- func (fi *FileInfo) GetFileHash() string
- func (fi *FileInfo) GetFileId() string
- func (fi *FileInfo) GetRejectReason() RejectReason
- func (fi *FileInfo) GetUserIds() []string
- func (fi *FileInfo) Release(userId string) error
- func (fi *FileInfo) Update(userId string, branchName string, oldHash string, fileHash string) error
- func (fi *FileInfo) UpgradeMissingToNew(fileHash string, branchName string) error
- type FileUpdate
- type FilesRequest
- type RejectReason
- type UpdateRequest
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileAlreadyClaimed = errors.New("file already claimed") ErrFileOutOfDate = errors.New("file out of date") ErrUserNotOwner = errors.New("user not owner") ErrInvalidClaimMode = errors.New("invalid claim mode") ErrorFileNotMissing = errors.New("file not missing") ErrFileInfoInvariantBroken = errors.New("file info invariant broken") )
Functions ¶
This section is empty.
Types ¶
type ClaimMode ¶
type ClaimMode int32
Enum for claim mode Should be kept in sync with the protobuf file.
type ClaimRequest ¶
type ClaimRequest interface { FilesRequest GetBranchName() string GetIsSoftClaim() bool GetRequests() []FileClaim }
ClaimRequest is an interface for requests that claim files.
func NewClaimRequest ¶
func NewClaimRequest(branchName string, softClaim bool, requests []FileClaim) ClaimRequest
NewClaimRequest creates a new claim request.
type ColabDatabase ¶
type ColabDatabase interface { Ping() error List(ctx context.Context, logger zerolog.Logger, projectId string, cursor uint64, pageSize int64, folderPath string) ([]*FileInfo, uint64, error) Claim(ctx context.Context, logger zerolog.Logger, userId string, projectId string, request ClaimRequest) ([]*FileInfo, error) Update(ctx context.Context, logger zerolog.Logger, userId string, projectId string, request UpdateRequest) ([]*FileInfo, error) Release(ctx context.Context, logger zerolog.Logger, userId string, projectId string, branchId string, request FilesRequest) ([]*FileInfo, error) }
ColabDatabase is the interface for the database.
type FileInfo ¶
type FileInfo struct {
// contains filtered or unexported fields
}
FileInfo represents a file in the system
TODO: Look into: https://pkg.go.dev/github.com/redis/rueidis/om#section-readme TODO: Look into: https://stackoverflow.com/questions/11126793/json-and-dealing-with-unexported-fields
func NewBlankFileInfo ¶
func NewBlankFileInfo() *FileInfo
NewBlankFileInfo creates a new blank without the need for parameters.
Ideal for creating a new FileInfo that will be populated later on such as unmarshalling from a database.
func NewFileInfo ¶
NewFileInfo creates a new FileInfo that meets the invariants of the struct
func NewFullFileInfo ¶
func NewFullFileInfo(fileId string, fileHash string, userIds []string, branchName string, claimMode ClaimMode, rejectReason RejectReason) (*FileInfo, error)
NewFullFileInfo creates a new FileInfo with all the fields set. Can error if the claim mode is not Unclaimed and there are no user IDs.
func NewMissingFileInfo ¶
NewMissingFileInfo creates a new FileInfo for a file that is missing.
func (*FileInfo) CheckOwner ¶
CheckOwner checks if a user is an owner of a file
func (*FileInfo) GetBranchName ¶
GetBranchName returns the branchName of the FileInfo
func (*FileInfo) GetClaimMode ¶
GetClaimMode returns the claimMode of the FileInfo
func (*FileInfo) GetFileHash ¶
GetFileHash returns the fileHash of the FileInfo
func (*FileInfo) GetRejectReason ¶
func (fi *FileInfo) GetRejectReason() RejectReason
GetRejectReason returns the rejectReason of the FileInfo
func (*FileInfo) GetUserIds ¶
GetUserIds returns the userIds of the FileInfo
type FileUpdate ¶
func NewFileUpdate ¶
func NewFileUpdate(fileId string, fileHash string, oldHash string) FileUpdate
NewFileUpdate creates a new file update request.
type FilesRequest ¶
type FilesRequest interface {
GetFileIDs() []string
}
FilesRequest is an interface for requests that contain lists of files whos IDs can be retrieved.
func NewFilesRequest ¶
func NewFilesRequest(fileIds []string) FilesRequest
NewFilesRequest creates a new files request.
type RejectReason ¶
type RejectReason int32
Enum for reject reason Should be kept in sync with the protobuf file.
const ( RejectReason_None RejectReason = iota RejectReason_AlreadyClaimed RejectReason_OutOfDate RejectReason_NotOwner RejectReason_InvalidClaimMode RejectReason_Missing )
type UpdateRequest ¶
type UpdateRequest interface { FilesRequest GetBranchName() string GetRequests() []FileUpdate }
func NewUpdateRequest ¶
func NewUpdateRequest(branchName string, requests []FileUpdate) UpdateRequest
NewUpdateRequest creates a new update request.