Documentation ¶
Index ¶
- type CreateClientParams
- type CreateClientRow
- type DBTX
- type DownloadFileBulkGetLatestRow
- type DownloadFileDataWithFilePathRow
- type DownloadFileStepOneGetLatestDataRow
- type DownloadStoreBulkRow
- type FileDatum
- type FileMetadatum
- type FileTracker
- type GetFilesListRow
- type NullPeerRoleType
- type PeerDir
- type PeerRoleType
- type PeersTable
- type Queries
- func (q *Queries) CheckChangesStepOne(ctx context.Context, db DBTX) error
- func (q *Queries) ConnectClient(ctx context.Context, db DBTX, peerID pgtype.UUID) ([]*PeersTable, error)
- func (q *Queries) CreateClient(ctx context.Context, db DBTX, arg *CreateClientParams) (*CreateClientRow, error)
- func (q *Queries) DBCurrentStorageSize(ctx context.Context, db DBTX) (int64, error)
- func (q *Queries) DBTotalStorageSize(ctx context.Context, db DBTX) (int64, error)
- func (q *Queries) DownloadFileBulkGetLatest(ctx context.Context, db DBTX) ([]*DownloadFileBulkGetLatestRow, error)
- func (q *Queries) DownloadFileDataWithFilePath(ctx context.Context, db DBTX, filePath string) (*DownloadFileDataWithFilePathRow, error)
- func (q *Queries) DownloadFileStepOneGetLatestData(ctx context.Context, db DBTX, fileHash *string) (*DownloadFileStepOneGetLatestDataRow, error)
- func (q *Queries) DownloadStoreBulk(ctx context.Context, db DBTX, peerID uuid.UUID) ([]*DownloadStoreBulkRow, error)
- func (q *Queries) GetFilesList(ctx context.Context, db DBTX) ([]*GetFilesListRow, error)
- func (q *Queries) GetPEMs(ctx context.Context, db DBTX) ([][]byte, error)
- func (q *Queries) UpdateFileTracker(ctx context.Context, db DBTX, arg *UpdateFileTrackerParams) error
- func (q *Queries) UpdateFileTrackerMarkDownloaded(ctx context.Context, db DBTX, arg *UpdateFileTrackerMarkDownloadedParams) error
- func (q *Queries) UpdateFileTrackerMarkStored(ctx context.Context, db DBTX, arg *UpdateFileTrackerMarkStoredParams) error
- func (q *Queries) UpdateFileTrackerMarkUploaded(ctx context.Context, db DBTX, arg *UpdateFileTrackerMarkUploadedParams) error
- func (q *Queries) UploadFilesStepOneUploadData(ctx context.Context, db DBTX, arg *UploadFilesStepOneUploadDataParams) (*UploadFilesStepOneUploadDataRow, error)
- func (q *Queries) UploadFilesStepTwoUploadMetadata(ctx context.Context, db DBTX, arg *UploadFilesStepTwoUploadMetadataParams) (int32, error)
- func (q *Queries) UploadStoreStepOnePeerDir(ctx context.Context, db DBTX, arg *UploadStoreStepOnePeerDirParams) (int32, error)
- func (q *Queries) UploadStoreStepThreeUpdateMetadata(ctx context.Context, db DBTX, arg *UploadStoreStepThreeUpdateMetadataParams) (int32, error)
- func (q *Queries) UploadStoreStepTwoUploadFile(ctx context.Context, db DBTX, arg *UploadStoreStepTwoUploadFileParams) (*UploadStoreStepTwoUploadFileRow, error)
- type UpdateFileTrackerMarkDownloadedParams
- type UpdateFileTrackerMarkStoredParams
- type UpdateFileTrackerMarkUploadedParams
- type UpdateFileTrackerParams
- type UploadFilesStepOneUploadDataParams
- type UploadFilesStepOneUploadDataRow
- type UploadFilesStepTwoUploadMetadataParams
- type UploadStoreStepOnePeerDirParams
- type UploadStoreStepThreeUpdateMetadataParams
- type UploadStoreStepTwoUploadFileParams
- type UploadStoreStepTwoUploadFileRow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateClientParams ¶
type CreateClientRow ¶
type CreateClientRow struct { PeerID pgtype.UUID `json:"peer_id"` PeerRole NullPeerRoleType `json:"peer_role"` }
type DownloadFileBulkGetLatestRow ¶
type DownloadFileBulkGetLatestRow struct { FilePath string `json:"file_path"` DirID *int32 `json:"dir_id"` FileHash *string `json:"file_hash"` ModTime pgtype.Timestamptz `json:"mod_time"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` FileMetadataID int32 `json:"file_metadata_id"` FileType string `json:"file_type"` FileState string `json:"file_state"` FileDataID int32 `json:"file_data_id"` FileMode int32 `json:"file_mode"` }
type DownloadFileDataWithFilePathRow ¶
type DownloadFileDataWithFilePathRow struct { ID int32 `json:"id"` FileHash *string `json:"file_hash"` ModTime pgtype.Timestamptz `json:"mod_time"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` CreationTime pgtype.Timestamptz `json:"creation_time"` FileMetadataID int32 `json:"file_metadata_id"` DirID *int32 `json:"dir_id"` FilePath string `json:"file_path"` FileType string `json:"file_type"` FileState string `json:"file_state"` FileDataID int32 `json:"file_data_id"` FileMode int32 `json:"file_mode"` ModTime_2 pgtype.Timestamptz `json:"mod_time_2"` CreationTime_2 pgtype.Timestamptz `json:"creation_time_2"` }
type DownloadFileStepOneGetLatestDataRow ¶
type DownloadFileStepOneGetLatestDataRow struct { ID int32 `json:"id"` FileHash *string `json:"file_hash"` ModTime pgtype.Timestamptz `json:"mod_time"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` CreationTime pgtype.Timestamptz `json:"creation_time"` FileMetadataID int32 `json:"file_metadata_id"` DirID *int32 `json:"dir_id"` FilePath string `json:"file_path"` FileType string `json:"file_type"` FileState string `json:"file_state"` FileDataID int32 `json:"file_data_id"` FileMode int32 `json:"file_mode"` ModTime_2 pgtype.Timestamptz `json:"mod_time_2"` CreationTime_2 pgtype.Timestamptz `json:"creation_time_2"` }
type DownloadStoreBulkRow ¶
type DownloadStoreBulkRow struct { ID int32 `json:"id"` DirID *int32 `json:"dir_id"` FilePath string `json:"file_path"` FileType string `json:"file_type"` FileState string `json:"file_state"` FileDataID int32 `json:"file_data_id"` FileMode int32 `json:"file_mode"` ModTime pgtype.Timestamptz `json:"mod_time"` CreationTime pgtype.Timestamptz `json:"creation_time"` ID_2 int32 `json:"id_2"` PeerID uuid.UUID `json:"peer_id"` FileMetaID int32 `json:"file_meta_id"` CurrentHashID int32 `json:"current_hash_id"` FileState_2 string `json:"file_state_2"` LogTime pgtype.Timestamptz `json:"log_time"` ID_3 int32 `json:"id_3"` FileHash *string `json:"file_hash"` ModTime_2 pgtype.Timestamptz `json:"mod_time_2"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` CreationTime_2 pgtype.Timestamptz `json:"creation_time_2"` }
type FileDatum ¶
type FileDatum struct { ID int32 `json:"id"` FileHash *string `json:"file_hash"` ModTime pgtype.Timestamptz `json:"mod_time"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` CreationTime pgtype.Timestamptz `json:"creation_time"` }
type FileMetadatum ¶
type FileMetadatum struct { ID int32 `json:"id"` DirID *int32 `json:"dir_id"` FilePath string `json:"file_path"` FileType string `json:"file_type"` FileState string `json:"file_state"` FileDataID int32 `json:"file_data_id"` FileMode int32 `json:"file_mode"` ModTime pgtype.Timestamptz `json:"mod_time"` CreationTime pgtype.Timestamptz `json:"creation_time"` }
type FileTracker ¶
type GetFilesListRow ¶
type GetFilesListRow struct { FilePath string `json:"file_path"` DirID *int32 `json:"dir_id"` FileType string `json:"file_type"` FileState string `json:"file_state"` ID int32 `json:"id"` FileMetadataID int32 `json:"file_metadata_id"` FileMode int32 `json:"file_mode"` ModTime pgtype.Timestamptz `json:"mod_time"` FileHash *string `json:"file_hash"` FileSize int32 `json:"file_size"` }
type NullPeerRoleType ¶
type NullPeerRoleType struct { PeerRoleType PeerRoleType `json:"peer_role_type"` Valid bool `json:"valid"` // Valid is true if PeerRoleType is not NULL }
func (*NullPeerRoleType) Scan ¶
func (ns *NullPeerRoleType) Scan(value interface{}) error
Scan implements the Scanner interface.
type PeerRoleType ¶
type PeerRoleType string
const ( PeerRoleTypeClient PeerRoleType = "client" PeerRoleTypeStorage PeerRoleType = "storage" PeerRoleTypeServer PeerRoleType = "server" )
func (*PeerRoleType) Scan ¶
func (e *PeerRoleType) Scan(src interface{}) error
type PeersTable ¶
type PeersTable struct { ID int32 `json:"id"` PeerID pgtype.UUID `json:"peer_id"` IpAddress string `json:"ip_address"` PeerRole NullPeerRoleType `json:"peer_role"` PeerName *string `json:"peer_name"` CreationTime pgtype.Timestamptz `json:"creation_time"` Pem []byte `json:"pem"` PeerConfig []byte `json:"peer_config"` }
type Queries ¶
type Queries struct { }
func (*Queries) CheckChangesStepOne ¶
CheckChangesStepOne
SELECT DISTINCT file_metadata.file_path, file_metadata.file_data_id, file_data.file_hash,file_metadata.mod_time FROM file_metadata JOIN file_data ON file_metadata.file_data_id = file_data.id ORDER BY file_metadata.file_data_id DESC, file_metadata.mod_time DESC
func (*Queries) ConnectClient ¶
func (q *Queries) ConnectClient(ctx context.Context, db DBTX, peerID pgtype.UUID) ([]*PeersTable, error)
ConnectClient
SELECT id, peer_id, ip_address, peer_role, peer_name, creation_time, pem, peer_config FROM peers_table WHERE peer_id = $1 LIMIT 1
func (*Queries) CreateClient ¶
func (q *Queries) CreateClient(ctx context.Context, db DBTX, arg *CreateClientParams) (*CreateClientRow, error)
CreateClient
INSERT INTO peers_table(ip_address,peer_name,pem) VALUES ($1,$2,$3) RETURNING peer_id, peer_role
func (*Queries) DBCurrentStorageSize ¶
DBCurrentStorageSize
SELECT SUM(file_size) FROM file_metadata JOIN file_data ON file_metadata.file_data_id = file_data.id WHERE file_metadata.file_state = 'current'
func (*Queries) DownloadFileBulkGetLatest ¶
func (q *Queries) DownloadFileBulkGetLatest(ctx context.Context, db DBTX) ([]*DownloadFileBulkGetLatestRow, error)
DownloadFileBulkGetLatest
SELECT DISTINCT file_path, dir_id, file_hash, file_data.mod_time, file_size, file_data_b, file_metadata.id AS file_metadata_id, file_type, file_state, file_data_id, file_mode FROM file_metadata JOIN file_data ON file_data.id = file_metadata.file_data_id WHERE file_state = 'current'
func (*Queries) DownloadFileDataWithFilePath ¶
func (q *Queries) DownloadFileDataWithFilePath(ctx context.Context, db DBTX, filePath string) (*DownloadFileDataWithFilePathRow, error)
DownloadFileDataWithFilePath
SELECT file_data.id, file_hash, file_data.mod_time, file_size, file_data_b, file_data.creation_time, file_metadata.id AS file_metadata_id, dir_id, file_path, file_type, file_state, file_data_id, file_mode, file_metadata.mod_time, file_metadata.creation_time from file_data JOIN file_metadata ON file_metadata.file_data_id = file_data.id where file_metadata.file_path = $1
func (*Queries) DownloadFileStepOneGetLatestData ¶
func (q *Queries) DownloadFileStepOneGetLatestData(ctx context.Context, db DBTX, fileHash *string) (*DownloadFileStepOneGetLatestDataRow, error)
DownloadFileStepOneGetLatestData
SELECT file_data.id, file_hash, file_data.mod_time, file_size, file_data_b, file_data.creation_time, file_metadata.id AS file_metadata_id, dir_id, file_path, file_type, file_state, file_data_id, file_mode, file_metadata.mod_time, file_metadata.creation_time from file_data JOIN file_metadata ON file_metadata.file_data_id = file_data.id WHERE file_data.file_hash = $1
func (*Queries) DownloadStoreBulk ¶
func (q *Queries) DownloadStoreBulk(ctx context.Context, db DBTX, peerID uuid.UUID) ([]*DownloadStoreBulkRow, error)
DownloadStoreBulk
SELECT file_metadata.id, dir_id, file_path, file_type, file_metadata.file_state, file_data_id, file_mode, file_metadata.mod_time, file_metadata.creation_time, file_tracker.id, peer_id, file_meta_id, current_hash_id, file_tracker.file_state, log_time, file_data.id, file_hash, file_data.mod_time, file_size, file_data_b, file_data.creation_time from file_metadata JOIN file_tracker on file_tracker.file_meta_id = file_metadata.id JOIN file_data on file_tracker.current_hash_id = file_data.id WHERE current_hash_id NOT IN ( SELECT current_hash_id from file_metadata where file_state = 'stored' AND peer_id = $1 )
func (*Queries) GetFilesList ¶
GetFilesList
SELECT DISTINCT file_path, dir_id, file_type, file_state, file_data.id, file_metadata.id as file_metadata_id,file_mode, file_metadata.mod_time, file_data.file_hash, file_data.file_size FROM file_metadata JOIN file_data ON file_metadata.file_data_id = file_data.id WHERE file_state = 'current' ORDER BY file_metadata.mod_time DESC
func (*Queries) UpdateFileTracker ¶
func (q *Queries) UpdateFileTracker(ctx context.Context, db DBTX, arg *UpdateFileTrackerParams) error
UpdateFileTracker
INSERT INTO file_tracker ( peer_id, file_meta_id, current_hash_id, file_state ) VALUES ($1, $2, $3, $4)
func (*Queries) UpdateFileTrackerMarkDownloaded ¶
func (q *Queries) UpdateFileTrackerMarkDownloaded(ctx context.Context, db DBTX, arg *UpdateFileTrackerMarkDownloadedParams) error
UpdateFileTrackerMarkDownloaded
INSERT INTO file_tracker ( peer_id, file_meta_id, current_hash_id, file_state ) VALUES ($1, $2, $3, 'downloaded')
func (*Queries) UpdateFileTrackerMarkStored ¶
func (q *Queries) UpdateFileTrackerMarkStored(ctx context.Context, db DBTX, arg *UpdateFileTrackerMarkStoredParams) error
UpdateFileTrackerMarkStored
INSERT INTO file_tracker ( peer_id, file_meta_id, current_hash_id, file_state ) VALUES ($1, $2, $3, 'stored')
func (*Queries) UpdateFileTrackerMarkUploaded ¶
func (q *Queries) UpdateFileTrackerMarkUploaded(ctx context.Context, db DBTX, arg *UpdateFileTrackerMarkUploadedParams) error
UpdateFileTrackerMarkUploaded
INSERT INTO file_tracker ( peer_id, file_meta_id, current_hash_id, file_state ) VALUES ($1, $2, $3, 'uploaded')
func (*Queries) UploadFilesStepOneUploadData ¶
func (q *Queries) UploadFilesStepOneUploadData(ctx context.Context, db DBTX, arg *UploadFilesStepOneUploadDataParams) (*UploadFilesStepOneUploadDataRow, error)
UploadFilesStepOneUploadData
INSERT INTO file_data( mod_time, file_size, file_data_b ) VALUES ($1, $2, $3) ON CONFLICT (file_hash) DO NOTHING RETURNING id, file_hash
func (*Queries) UploadFilesStepTwoUploadMetadata ¶
func (q *Queries) UploadFilesStepTwoUploadMetadata(ctx context.Context, db DBTX, arg *UploadFilesStepTwoUploadMetadataParams) (int32, error)
UploadFilesStepTwoUploadMetadata
INSERT INTO file_metadata( file_path, -- relative file_type, file_state, file_data_id, -- file_data(id) file_mode, mod_time ) VALUES ($1,$2,'current',$3,$4, $5) ON CONFLICT (file_path) DO UPDATE SET file_data_id = $4, mod_time = $6 RETURNING id
func (*Queries) UploadStoreStepOnePeerDir ¶
func (q *Queries) UploadStoreStepOnePeerDir(ctx context.Context, db DBTX, arg *UploadStoreStepOnePeerDirParams) (int32, error)
UploadStoreStepOnePeerDir
INSERT INTO peer_dirs(peer_id,dir_path) VALUES ($1, $2) ON CONFLICT (uniq_dirs) DO NOTHING RETURNING id
func (*Queries) UploadStoreStepThreeUpdateMetadata ¶
func (q *Queries) UploadStoreStepThreeUpdateMetadata(ctx context.Context, db DBTX, arg *UploadStoreStepThreeUpdateMetadataParams) (int32, error)
UploadStoreStepThreeUpdateMetadata
INSERT INTO file_metadata( file_path, -- relative file_type, file_state, file_data_id, -- file_data(id) file_mode, mod_time, dir_id ) VALUES ($1,$2,'store',$3,$4, $5, $6) ON CONFLICT (file_path) DO UPDATE SET file_data_id = $4, mod_time = $6, file_state = 'store' RETURNING id
func (*Queries) UploadStoreStepTwoUploadFile ¶
func (q *Queries) UploadStoreStepTwoUploadFile(ctx context.Context, db DBTX, arg *UploadStoreStepTwoUploadFileParams) (*UploadStoreStepTwoUploadFileRow, error)
UploadStoreStepTwoUploadFile
INSERT INTO file_data( mod_time, file_size, file_data_b ) VALUES ($1, $2, $3) ON CONFLICT (file_hash) DO NOTHING RETURNING id, file_hash
type UpdateFileTrackerParams ¶
type UploadFilesStepOneUploadDataParams ¶
type UploadFilesStepOneUploadDataParams struct { ModTime pgtype.Timestamptz `json:"mod_time"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` }
type UploadFilesStepTwoUploadMetadataParams ¶
type UploadFilesStepTwoUploadMetadataParams struct { FilePath string `json:"file_path"` FileType string `json:"file_type"` FileDataID int32 `json:"file_data_id"` FileMode int32 `json:"file_mode"` ModTime pgtype.Timestamptz `json:"mod_time"` ModTime_2 pgtype.Timestamptz `json:"mod_time_2"` }
type UploadStoreStepTwoUploadFileParams ¶
type UploadStoreStepTwoUploadFileParams struct { ModTime pgtype.Timestamptz `json:"mod_time"` FileSize int32 `json:"file_size"` FileDataB []byte `json:"file_data_b"` }
Click to show internal directories.
Click to hide internal directories.