Documentation
¶
Index ¶
- type ConnectClientParams
- type CreateClientParams
- type DBTX
- type DownloadFilesRow
- type FileLog
- type FileStatusType
- type FileStorage
- type FileTrackerStatus
- type GetFileDataRow
- type GetFilesRow
- type InsertFileParams
- type InsertFileRow
- type MarkFileDeletedParams
- type NullFileStatusType
- type NullFileTrackerStatus
- type NullPeerRoleType
- type PeerRoleType
- type PeersTable
- type Queries
- func (q *Queries) ConnectClient(ctx context.Context, db DBTX, arg *ConnectClientParams) ([]*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) 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
- type UpdateFileLogParams
- type UpdatePeerRoleParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ConnectClientParams ¶ added in v0.0.3
type CreateClientParams ¶ added in v0.0.2
type CreateClientParams struct {
IpAddress string `json:"ip_address"`
Pem []byte `json:"pem"`
PeerRole NullPeerRoleType `json:"peer_role"`
}
type DownloadFilesRow ¶ added in v0.0.3
type FileLog ¶ added in v0.0.3
type FileLog struct {
ID int32 `json:"id"`
PeerID uuid.UUID `json:"peer_id"`
FileHash string `json:"file_hash"`
CurrentFileStatus NullFileStatusType `json:"current_file_status"`
OldFileStatus NullFileStatusType `json:"old_file_status"`
DeltaTime pgtype.Timestamptz `json:"delta_time"`
}
type FileStatusType ¶
type FileStatusType string
const ( FileStatusTypeNew FileStatusType = "new" FileStatusTypeDeleted FileStatusType = "deleted" FileStatusTypeUpdated FileStatusType = "updated" FileStatusTypeStored FileStatusType = "stored" )
func (*FileStatusType) Scan ¶
func (e *FileStatusType) Scan(src interface{}) error
type FileStorage ¶
type FileStorage struct {
ID int32 `json:"id"`
PeerID uuid.UUID `json:"peer_id"`
FileName string `json:"file_name"`
FilePath string `json:"file_path"`
FileType string `json:"file_type"`
FileHash *string `json:"file_hash"`
PrevFileHash *string `json:"prev_file_hash"`
Creation pgtype.Timestamptz `json:"creation"`
ModificationDate pgtype.Timestamp `json:"modification_date"`
FileState NullFileStatusType `json:"file_state"`
FileData []byte `json:"file_data"`
}
type FileTrackerStatus ¶ added in v0.0.3
type FileTrackerStatus string
const ( FileTrackerStatusRequested FileTrackerStatus = "requested" FileTrackerStatusUploaded FileTrackerStatus = "uploaded" FileTrackerStatusStored FileTrackerStatus = "stored" FileTrackerStatusDeleted FileTrackerStatus = "deleted" )
func (*FileTrackerStatus) Scan ¶ added in v0.0.3
func (e *FileTrackerStatus) Scan(src interface{}) error
type GetFileDataRow ¶ added in v0.0.3
type GetFileDataRow struct {
PeerID uuid.UUID `json:"peer_id"`
FileState NullFileStatusType `json:"file_state"`
FileData []byte `json:"file_data"`
}
type GetFilesRow ¶ added in v0.0.3
type GetFilesRow struct {
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"`
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 ¶ added in v0.0.3
type MarkFileDeletedParams ¶ added in v0.0.3
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 NullFileTrackerStatus ¶ added in v0.0.3
type NullFileTrackerStatus struct {
FileTrackerStatus FileTrackerStatus `json:"file_tracker_status"`
Valid bool `json:"valid"` // Valid is true if FileTrackerStatus is not NULL
}
func (*NullFileTrackerStatus) Scan ¶ added in v0.0.3
func (ns *NullFileTrackerStatus) Scan(value interface{}) error
Scan implements the Scanner interface.
type NullPeerRoleType ¶ added in v0.0.3
type NullPeerRoleType struct {
PeerRoleType PeerRoleType `json:"peer_role_type"`
Valid bool `json:"valid"` // Valid is true if PeerRoleType is not NULL
}
func (*NullPeerRoleType) Scan ¶ added in v0.0.3
func (ns *NullPeerRoleType) Scan(value interface{}) error
Scan implements the Scanner interface.
type PeerRoleType ¶ added in v0.0.3
type PeerRoleType string
const ( PeerRoleTypeClient PeerRoleType = "client" PeerRoleTypeStorage PeerRoleType = "storage" PeerRoleTypeServer PeerRoleType = "server" )
func (*PeerRoleType) Scan ¶ added in v0.0.3
func (e *PeerRoleType) Scan(src interface{}) error
type PeersTable ¶
type Queries ¶
type Queries struct {
}
func (*Queries) ConnectClient ¶ added in v0.0.2
func (q *Queries) ConnectClient(ctx context.Context, db DBTX, arg *ConnectClientParams) ([]*PeersTable, error)
ConnectClient
SELECT id, peer_id, ip_address, peer_role, peer_name, pem FROM peers_table
WHERE (
ip_address = $1
AND
peer_id = $2
)
LIMIT 1
func (*Queries) CountIfStored ¶ added in v0.0.3
CountIfStored
SELECT COUNT(*) FROM file_storage
WHERE
(
file_hash = $1
OR
prev_file_hash = $1
)
AND
file_state = 'stored'
func (*Queries) CreateClient ¶ added in v0.0.2
func (q *Queries) CreateClient(ctx context.Context, db DBTX, arg *CreateClientParams) ([]*PeersTable, error)
CreateClient
INSERT INTO peers_table(peer_id,ip_address, PEM,peer_role) VALUES (default,$1, $2,$3) RETURNING id, peer_id, ip_address, peer_role, peer_name, pem
func (*Queries) DownloadFiles ¶ added in v0.0.3
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 ¶ added in v0.0.3
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
file_name,
file_path,
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 ¶ added in v0.0.3
MarkFileDeleted
UPDATE file_storage
SET
file_state = 'deleted'
WHERE
peer_id = $1
AND
file_hash = $2
AND
file_state != 'deleted'
func (*Queries) UpdateFileLog ¶ added in v0.0.3
UpdateFileLog
INSERT INTO file_log (
peer_id,
file_hash,
current_file_status,
old_file_status
) VALUES
($1, $2, $3, $4)
func (*Queries) UpdatePeerRole ¶ added in v0.0.3
UpdatePeerRole
UPDATE peers_table
SET
peer_role = $2
WHERE
peer_id = $1
type UpdateFileLogParams ¶ added in v0.0.3
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 ¶ added in v0.0.3
type UpdatePeerRoleParams struct {
PeerID pgtype.UUID `json:"peer_id"`
PeerRole NullPeerRoleType `json:"peer_role"`
}
Click to show internal directories.
Click to hide internal directories.