mirror of
https://github.com/smallnest/rpcx.git
synced 2025-09-27 04:26:26 +08:00
#755 fix args to put into the pool
This commit is contained in:
@@ -92,7 +92,9 @@ func (s *FileTransferService) TransferFile(ctx context.Context, args *share.File
|
|||||||
reply.Addr = s.FileTransfer.AdvertiseAddr
|
reply.Addr = s.FileTransfer.AdvertiseAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
s.FileTransfer.cachedTokens.Add(string(token), &tokenInfo{token, args})
|
cloned := args.Clone()
|
||||||
|
s.FileTransfer.cachedTokens.Add(string(token), &tokenInfo{token, cloned})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +114,9 @@ func (s *FileTransferService) DownloadFile(ctx context.Context, args *share.Down
|
|||||||
reply.Addr = s.FileTransfer.AdvertiseAddr
|
reply.Addr = s.FileTransfer.AdvertiseAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
s.FileTransfer.cachedTokens.Add(string(token), &downloadTokenInfo{token, args})
|
cloned := args.Clone()
|
||||||
|
s.FileTransfer.cachedTokens.Add(string(token), &downloadTokenInfo{token, cloned})
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -65,6 +65,20 @@ type FileTransferArgs struct {
|
|||||||
Meta map[string]string `json:"meta,omitempty"`
|
Meta map[string]string `json:"meta,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone clones this DownloadFileArgs.
|
||||||
|
func (args FileTransferArgs) Clone() *FileTransferArgs {
|
||||||
|
meta := make(map[string]string)
|
||||||
|
for k, v := range args.Meta {
|
||||||
|
meta[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
return &FileTransferArgs{
|
||||||
|
FileName: args.FileName,
|
||||||
|
FileSize: args.FileSize,
|
||||||
|
Meta: meta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// FileTransferReply response to token and addr to clients.
|
// FileTransferReply response to token and addr to clients.
|
||||||
type FileTransferReply struct {
|
type FileTransferReply struct {
|
||||||
Token []byte `json:"token,omitempty"`
|
Token []byte `json:"token,omitempty"`
|
||||||
@@ -77,6 +91,19 @@ type DownloadFileArgs struct {
|
|||||||
Meta map[string]string `json:"meta,omitempty"`
|
Meta map[string]string `json:"meta,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clone clones this DownloadFileArgs.
|
||||||
|
func (args DownloadFileArgs) Clone() *DownloadFileArgs {
|
||||||
|
meta := make(map[string]string)
|
||||||
|
for k, v := range args.Meta {
|
||||||
|
meta[k] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
return &DownloadFileArgs{
|
||||||
|
FileName: args.FileName,
|
||||||
|
Meta: meta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// StreamServiceArgs is the request type for stream service.
|
// StreamServiceArgs is the request type for stream service.
|
||||||
type StreamServiceArgs struct {
|
type StreamServiceArgs struct {
|
||||||
Meta map[string]string `json:"meta,omitempty"`
|
Meta map[string]string `json:"meta,omitempty"`
|
||||||
|
Reference in New Issue
Block a user