Documentation
¶
Index ¶
- Variables
- type AddDirForPeerBatchResults
- type AddDirForPeerParams
- type ConnectClientParams
- type CreateClientParams
- type DBTX
- type DownloadFileDataBatchResults
- type DownloadFileDataParams
- type DownloadFileDataRow
- type DownloadFilesRow
- type FileChangeLog
- type FileDatum
- type FileMetadatum
- type FileStatusType
- type FileTransfMsgTable
- type GetFileDataRow
- type GetFilesRow
- type InsertFileParams
- type InsertFileRow
- type MarkFileDeletedParams
- type NullFileStatusType
- type NullPeerRoleType
- type PeerDir
- type PeerRoleType
- type PeersTable
- type Queries
- func (q *Queries) AddDirForPeer(ctx context.Context, db DBTX, arg []*AddDirForPeerParams) *AddDirForPeerBatchResults
- func (q *Queries) ConnectClient(ctx context.Context, db DBTX, peerID pgtype.UUID) (*PeersTable, error)
- func (q *Queries) CountIfStored(ctx context.Context, db DBTX, fileHash *string) (int64, error)
- func (q *Queries) CreateClient(ctx context.Context, db DBTX, arg *CreateClientParams) (*PeersTable, error)
- func (q *Queries) DownloadFileData(ctx context.Context, db DBTX, arg []*DownloadFileDataParams) *DownloadFileDataBatchResults
- func (q *Queries) DownloadFiles(ctx context.Context, db DBTX, peerID uuid.UUID) ([]*DownloadFilesRow, error)
- func (q *Queries) GetAllPem(ctx context.Context, db DBTX) ([][]byte, error)
- func (q *Queries) GetCountOfStoragePeers(ctx context.Context, db DBTX) (int64, error)
- func (q *Queries) GetFileData(ctx context.Context, db DBTX, fileHash *string) ([]*GetFileDataRow, error)
- func (q *Queries) GetFiles(ctx context.Context, db DBTX, peerID uuid.UUID) ([]*GetFilesRow, error)
- func (q *Queries) InsertFile(ctx context.Context, db DBTX, arg *InsertFileParams) (*InsertFileRow, error)
- func (q *Queries) MarkFileDeleted(ctx context.Context, db DBTX, arg *MarkFileDeletedParams) error
- func (q *Queries) UpdateFileLog(ctx context.Context, db DBTX, arg *UpdateFileLogParams) error
- func (q *Queries) UpdatePeerRole(ctx context.Context, db DBTX, arg *UpdatePeerRoleParams) error
- func (q *Queries) UploadFile(ctx context.Context, db DBTX, arg []*UploadFileParams) *UploadFileBatchResults
- func (q *Queries) UploadMetadata(ctx context.Context, db DBTX, arg []*UploadMetadataParams) *UploadMetadataBatchResults
- type UpdateFileLogParams
- type UpdatePeerRoleParams
- type UploadFileBatchResults
- type UploadFileParams
- type UploadFileRow
- type UploadMetadataBatchResults
- type UploadMetadataParams
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrBatchAlreadyClosed = errors.New("batch already closed")
)
Functions ¶
This section is empty.
Types ¶
type AddDirForPeerBatchResults ¶
type AddDirForPeerBatchResults struct {
// contains filtered or unexported fields
}
func (*AddDirForPeerBatchResults) Close ¶
func (b *AddDirForPeerBatchResults) Close() error
type AddDirForPeerParams ¶
type ConnectClientParams ¶
type CreateClientParams ¶
type CreateClientParams struct {
PeerRole NullPeerRoleType `json:"peer_role"`
PeerName *string `json:"peer_name"`
Pem []byte `json:"pem"`
PeerConfig []byte `json:"peer_config"`
IpAddress string `json:"ip_address"`
}
type DownloadFileDataBatchResults ¶
type DownloadFileDataBatchResults struct {
// contains filtered or unexported fields
}
func (*DownloadFileDataBatchResults) Close ¶
func (b *DownloadFileDataBatchResults) Close() error
func (*DownloadFileDataBatchResults) Query ¶
func (b *DownloadFileDataBatchResults) Query(f func(int, []*DownloadFileDataRow, error))
type DownloadFileDataParams ¶
type DownloadFileDataRow ¶
type DownloadFileDataRow struct {
FileDataID int32 `json:"file_data_id"`
FileHash *string `json:"file_hash"`
PrevFileHash *int32 `json:"prev_file_hash"`
FileStatus NullFileStatusType `json:"file_status"`
ModificationDate pgtype.Timestamp `json:"modification_date"`
CreationTime pgtype.Timestamptz `json:"creation_time"`
FileData []byte `json:"file_data"`
ID int32 `json:"id"`
PeerID pgtype.UUID `json:"peer_id"`
DirID *int32 `json:"dir_id"`
FileDataID_2 *int32 `json:"file_data_id_2"`
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
FileType string `json:"file_type"`
CreationDay pgtype.Date `json:"creation_day"`
CreationTime_2 pgtype.Timestamptz `json:"creation_time_2"`
}
type DownloadFilesRow ¶
type FileChangeLog ¶
type FileChangeLog struct {
ID int32 `json:"id"`
PeerID pgtype.UUID `json:"peer_id"`
PrevFileState NullFileStatusType `json:"prev_file_state"`
CurrFileState NullFileStatusType `json:"curr_file_state"`
FileHashID *int32 `json:"file_hash_id"`
Messagef string `json:"messagef"`
JsonLog []byte `json:"json_log"`
}
type FileDatum ¶
type FileDatum struct {
FileDataID int32 `json:"file_data_id"`
FileHash *string `json:"file_hash"`
PrevFileHash *int32 `json:"prev_file_hash"`
FileStatus NullFileStatusType `json:"file_status"`
ModificationDate pgtype.Timestamp `json:"modification_date"`
CreationTime pgtype.Timestamptz `json:"creation_time"`
FileData []byte `json:"file_data"`
}
type FileMetadatum ¶
type FileMetadatum struct {
ID int32 `json:"id"`
PeerID pgtype.UUID `json:"peer_id"`
DirID *int32 `json:"dir_id"`
FileDataID *int32 `json:"file_data_id"`
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
FileType string `json:"file_type"`
CreationDay pgtype.Date `json:"creation_day"`
CreationTime pgtype.Timestamptz `json:"creation_time"`
}
type FileStatusType ¶
type FileStatusType string
const ( FileStatusTypeCreated FileStatusType = "created" FileStatusTypeModified FileStatusType = "modified" FileStatusTypeDeleted FileStatusType = "deleted" )
func (*FileStatusType) Scan ¶
func (e *FileStatusType) Scan(src interface{}) error
type FileTransfMsgTable ¶
type FileTransfMsgTable struct {
ID int32 `json:"id"`
PeerReqing uuid.UUID `json:"peer_reqing"`
FileHash int32 `json:"file_hash"`
ReqTime pgtype.Timestamptz `json:"req_time"`
PeerResponding pgtype.UUID `json:"peer_responding"`
ResTime pgtype.Timestamptz `json:"res_time"`
}
type GetFileDataRow ¶
type GetFileDataRow struct {
PeerID uuid.UUID `json:"peer_id"`
FileState NullFileStatusType `json:"file_state"`
FileData []byte `json:"file_data"`
}
type GetFilesRow ¶
type GetFilesRow struct {
FilePath string `json:"file_path"`
FileName string `json:"file_name"`
FileType string `json:"file_type"`
ModificationDate pgtype.Timestamp `json:"modification_date"`
FileState NullFileStatusType `json:"file_state"`
FileHash *string `json:"file_hash"`
PrevFileHash *string `json:"prev_file_hash"`
}
type InsertFileParams ¶
type InsertFileParams struct {
PeerID uuid.UUID `json:"peer_id"`
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
FileType string `json:"file_type"`
ModificationDate pgtype.Timestamp `json:"modification_date"`
FileState NullFileStatusType `json:"file_state"`
FileData []byte `json:"file_data"`
}
type InsertFileRow ¶
type MarkFileDeletedParams ¶
type NullFileStatusType ¶
type NullFileStatusType struct {
FileStatusType FileStatusType `json:"file_status_type"`
Valid bool `json:"valid"` // Valid is true if FileStatusType is not NULL
}
func (*NullFileStatusType) Scan ¶
func (ns *NullFileStatusType) Scan(value interface{}) error
Scan implements the Scanner interface.
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) AddDirForPeer ¶
func (q *Queries) AddDirForPeer(ctx context.Context, db DBTX, arg []*AddDirForPeerParams) *AddDirForPeerBatchResults
AddDirForPeer
INSERT INTO peer_dirs(
peer_id,
dir_path
) VALUES ($1, $2)
RETURNING id, peer_id, creation_time, dir_path
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
func (*Queries) CountIfStored ¶
CountIfStored
SELECT COUNT(*) FROM file_storage
WHERE
(
file_hash = $1
OR
prev_file_hash = $1
)
AND
file_state = 'stored'
func (*Queries) CreateClient ¶
func (q *Queries) CreateClient(ctx context.Context, db DBTX, arg *CreateClientParams) (*PeersTable, error)
CreateClient
INSERT INTO peers_table(peer_id,peer_role,peer_name,pem, peer_config,ip_address) VALUES (default, $1, $2, $3, $4, $5) RETURNING id, peer_id, ip_address, peer_role, peer_name, creation_time, pem, peer_config
func (*Queries) DownloadFileData ¶
func (q *Queries) DownloadFileData(ctx context.Context, db DBTX, arg []*DownloadFileDataParams) *DownloadFileDataBatchResults
DownloadFileData
SELECT
file_data.file_data_id, file_hash, prev_file_hash, file_status, modification_date, file_data.creation_time, file_data, id, peer_id, dir_id, file_metadata.file_data_id, file_name, file_path, file_type, creation_day, file_metadata.creation_time
FROM
file_data
INNER JOIN file_metadata USING (file_data_id)
WHERE
file_metadata.peer_id = $1
AND file_data.file_data IS NOT NULL
AND file_data.modification_date >= $2
ORDER BY
modification_date DESC
func (*Queries) DownloadFiles ¶
func (q *Queries) DownloadFiles(ctx context.Context, db DBTX, peerID uuid.UUID) ([]*DownloadFilesRow, error)
DownloadFiles
SELECT
file_hash,
file_name,
file_data,
modification_date
FROM file_storage
WHERE
peer_id = $1
AND
file_state != 'deleted'
AND
file_data IS NOT NULL
func (*Queries) GetCountOfStoragePeers ¶
GetCountOfStoragePeers
SELECT COUNT(*) FROM peers_table WHERE peer_role = 'storage'
func (*Queries) GetFileData ¶
func (q *Queries) GetFileData(ctx context.Context, db DBTX, fileHash *string) ([]*GetFileDataRow, error)
GetFileData
SELECT
peer_id,
file_state,
file_data
FROM file_storage
WHERE file_hash = $1
LIMIT 1
func (*Queries) GetFiles ¶
GetFiles
SELECT
DISTINCT file_path,
file_name,
file_type,
modification_date,
file_state,
file_hash,
prev_file_hash
FROM file_storage
WHERE peer_id = $1
ORDER BY modification_date DESC
func (*Queries) InsertFile ¶
func (q *Queries) InsertFile(ctx context.Context, db DBTX, arg *InsertFileParams) (*InsertFileRow, error)
InsertFile
INSERT INTO file_storage (
peer_id,
file_name,
file_path,
file_type,
modification_date,
file_state,
file_data
) VALUES (
$1, $2, $3, $4, $5, $6, $7
) RETURNING
id,
file_hash
func (*Queries) MarkFileDeleted ¶
MarkFileDeleted
UPDATE file_storage
SET
file_state = 'deleted'
WHERE
peer_id = $1
AND
file_hash = $2
AND
file_state != 'deleted'
func (*Queries) UpdateFileLog ¶
UpdateFileLog
INSERT INTO file_log (
peer_id,
file_hash,
current_file_status,
old_file_status
) VALUES
($1, $2, $3, $4)
func (*Queries) UpdatePeerRole ¶
UpdatePeerRole
UPDATE peers_table
SET
peer_role = $2
WHERE
peer_id = $1
func (*Queries) UploadFile ¶
func (q *Queries) UploadFile(ctx context.Context, db DBTX, arg []*UploadFileParams) *UploadFileBatchResults
UploadFile
INSERT INTO file_data(
file_status,
file_data,
modification_date
) VALUES ($1, $2,$3)
ON CONFLICT (file_hash)
DO UPDATE
SET
file_data = $2
RETURNING
file_data_id, file_hash
func (*Queries) UploadMetadata ¶
func (q *Queries) UploadMetadata(ctx context.Context, db DBTX, arg []*UploadMetadataParams) *UploadMetadataBatchResults
UploadMetadata
INSERT INTO file_metadata(
peer_id,
dir_id,
file_data_id,
file_name,
file_path,
file_type
) VALUES($1, $2, $3, $4, $5, $6)
RETURNING id
type UpdateFileLogParams ¶
type UpdateFileLogParams struct {
PeerID uuid.UUID `json:"peer_id"`
FileHash string `json:"file_hash"`
CurrentFileStatus NullFileStatusType `json:"current_file_status"`
OldFileStatus NullFileStatusType `json:"old_file_status"`
}
type UpdatePeerRoleParams ¶
type UpdatePeerRoleParams struct {
PeerID pgtype.UUID `json:"peer_id"`
PeerRole NullPeerRoleType `json:"peer_role"`
}
type UploadFileBatchResults ¶
type UploadFileBatchResults struct {
// contains filtered or unexported fields
}
func (*UploadFileBatchResults) Close ¶
func (b *UploadFileBatchResults) Close() error
func (*UploadFileBatchResults) QueryRow ¶
func (b *UploadFileBatchResults) QueryRow(f func(int, *UploadFileRow, error))
type UploadFileParams ¶
type UploadFileParams struct {
FileStatus NullFileStatusType `json:"file_status"`
FileData []byte `json:"file_data"`
ModificationDate pgtype.Timestamp `json:"modification_date"`
}
type UploadFileRow ¶
type UploadMetadataBatchResults ¶
type UploadMetadataBatchResults struct {
// contains filtered or unexported fields
}
func (*UploadMetadataBatchResults) Close ¶
func (b *UploadMetadataBatchResults) Close() error
Click to show internal directories.
Click to hide internal directories.