128 lines
4.0 KiB
Go
128 lines
4.0 KiB
Go
package hubrpc
|
|
|
|
import (
|
|
context "context"
|
|
|
|
"gitlink.org.cn/cloudream/jcs-pub/common/pkgs/rpc"
|
|
stgtypes "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage/types"
|
|
jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
|
|
)
|
|
|
|
type PubShardsService interface {
|
|
PubShardsStore(ctx context.Context, msg *PubShardsStore) (*PubShardsStoreResp, *rpc.CodeError)
|
|
PubShardsInfo(ctx context.Context, msg *PubShardsInfo) (*PubShardsInfoResp, *rpc.CodeError)
|
|
PubShardsGC(ctx context.Context, msg *PubShardsGC) (*PubShardsGCResp, *rpc.CodeError)
|
|
PubShardsListAll(ctx context.Context, msg *PubShardsListAll) (*PubShardsListAllResp, *rpc.CodeError)
|
|
PubShardsStats(ctx context.Context, msg *PubShardsStats) (*PubShardsStatsResp, *rpc.CodeError)
|
|
}
|
|
|
|
// 将一个分片纳入公共分片存储
|
|
type PubShardsStore struct {
|
|
// 公共分片存储的ID
|
|
PubShardsID jcstypes.PubShardsID
|
|
Password string
|
|
Path jcstypes.JPath
|
|
Size int64
|
|
Hash jcstypes.FileHash
|
|
}
|
|
type PubShardsStoreResp struct {
|
|
Info stgtypes.FileInfo
|
|
}
|
|
|
|
var _ = TokenAuth(Hub_PubShardsStore_FullMethodName)
|
|
|
|
func (c *Client) PubShardsStore(ctx context.Context, msg *PubShardsStore) (*PubShardsStoreResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*PubShardsStoreResp](c.cli.PubShardsStore, ctx, msg)
|
|
}
|
|
func (s *Server) PubShardsStore(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.PubShardsStore, ctx, msg)
|
|
}
|
|
|
|
// 获取指定分片的信息
|
|
type PubShardsInfo struct {
|
|
PubShardsID jcstypes.PubShardsID
|
|
Password string
|
|
FileHash jcstypes.FileHash
|
|
}
|
|
type PubShardsInfoResp struct {
|
|
Info stgtypes.FileInfo
|
|
}
|
|
|
|
var _ = TokenAuth(Hub_PubShardsInfo_FullMethodName)
|
|
|
|
func (c *Client) PubShardsInfo(ctx context.Context, msg *PubShardsInfo) (*PubShardsInfoResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*PubShardsInfoResp](c.cli.PubShardsInfo, ctx, msg)
|
|
}
|
|
func (s *Server) PubShardsInfo(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.PubShardsInfo, ctx, msg)
|
|
}
|
|
|
|
// 重置本Client的FileHash引用记录
|
|
type PubShardsGC struct {
|
|
PubShardsID jcstypes.PubShardsID
|
|
Password string
|
|
// 新的FileHash引用记录
|
|
FileHashes []jcstypes.FileHash
|
|
}
|
|
type PubShardsGCResp struct{}
|
|
|
|
var _ = TokenAuth(Hub_PubShardsGC_FullMethodName)
|
|
|
|
func (c *Client) PubShardsGC(ctx context.Context, msg *PubShardsGC) (*PubShardsGCResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*PubShardsGCResp](c.cli.PubShardsGC, ctx, msg)
|
|
}
|
|
func (s *Server) PubShardsGC(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.PubShardsGC, ctx, msg)
|
|
}
|
|
|
|
// 获取所有分片的信息
|
|
type PubShardsListAll struct {
|
|
PubShardsID jcstypes.PubShardsID
|
|
Password string
|
|
}
|
|
type PubShardsListAllResp struct {
|
|
Infos []stgtypes.FileInfo
|
|
}
|
|
|
|
var _ = TokenAuth(Hub_PubShardsListAll_FullMethodName)
|
|
|
|
func (c *Client) PubShardsListAll(ctx context.Context, msg *PubShardsListAll) (*PubShardsListAllResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*PubShardsListAllResp](c.cli.PubShardsListAll, ctx, msg)
|
|
}
|
|
func (s *Server) PubShardsListAll(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.PubShardsListAll, ctx, msg)
|
|
}
|
|
|
|
// 获取统计信息
|
|
type PubShardsStats struct {
|
|
PubShardsID jcstypes.PubShardsID
|
|
Password string
|
|
}
|
|
type PubShardsStatsResp struct {
|
|
Stats stgtypes.Stats
|
|
}
|
|
|
|
var _ = TokenAuth(Hub_PubShardsStats_FullMethodName)
|
|
|
|
func (c *Client) PubShardsStats(ctx context.Context, msg *PubShardsStats) (*PubShardsStatsResp, *rpc.CodeError) {
|
|
if c.fusedErr != nil {
|
|
return nil, c.fusedErr
|
|
}
|
|
return rpc.UnaryClient[*PubShardsStatsResp](c.cli.PubShardsStats, ctx, msg)
|
|
}
|
|
func (s *Server) PubShardsStats(ctx context.Context, msg *rpc.Request) (*rpc.Response, error) {
|
|
return rpc.UnaryServer(s.svrImpl.PubShardsStats, ctx, msg)
|
|
}
|