@@ -18,9 +18,18 @@ use iroh_base::hash::{BlobFormat, HashAndFormat};
18
18
use iroh_io:: AsyncSliceReader ;
19
19
use proto:: {
20
20
blobs:: {
21
- AddPathRequest , AddPathResponse , AddStreamRequest , AddStreamResponse , AddStreamUpdate , BatchAddPathRequest , BatchAddPathResponse , BatchAddStreamRequest , BatchAddStreamResponse , BatchAddStreamUpdate , BatchCreateRequest , BatchCreateResponse , BatchCreateTempTagRequest , BatchUpdate , BlobStatusRequest , BlobStatusResponse , ConsistencyCheckRequest , CreateCollectionRequest , CreateCollectionResponse , DeleteRequest , DownloadResponse , ExportRequest , ExportResponse , ListIncompleteRequest , ListRequest , ReadAtRequest , ReadAtResponse , ValidateRequest
21
+ AddPathRequest , AddPathResponse , AddStreamRequest , AddStreamResponse , AddStreamUpdate ,
22
+ BatchAddPathRequest , BatchAddPathResponse , BatchAddStreamRequest , BatchAddStreamResponse ,
23
+ BatchAddStreamUpdate , BatchCreateRequest , BatchCreateResponse , BatchCreateTempTagRequest ,
24
+ BatchUpdate , BlobStatusRequest , BlobStatusResponse , ConsistencyCheckRequest ,
25
+ CreateCollectionRequest , CreateCollectionResponse , DeleteRequest , DownloadResponse ,
26
+ ExportRequest , ExportResponse , ListIncompleteRequest , ListRequest , ReadAtRequest ,
27
+ ReadAtResponse , ValidateRequest ,
28
+ } ,
29
+ tags:: {
30
+ CreateRequest as TagsCreateRequest , DeleteRequest as TagDeleteRequest ,
31
+ ListRequest as TagListRequest , SetRequest as TagsSetRequest , SyncMode ,
22
32
} ,
23
- tags:: SyncMode ,
24
33
RpcError , RpcResult ,
25
34
} ;
26
35
use quic_rpc:: server:: { RpcChannel , RpcServerError } ;
@@ -38,10 +47,6 @@ use crate::{
38
47
} ,
39
48
Tag ,
40
49
} ;
41
- use proto:: tags:: {
42
- CreateRequest as TagsCreateRequest , DeleteRequest as TagDeleteRequest ,
43
- ListRequest as TagListRequest , SetRequest as TagsSetRequest ,
44
- } ;
45
50
pub mod client;
46
51
pub mod proto;
47
52
@@ -51,15 +56,15 @@ const RPC_BLOB_GET_CHUNK_SIZE: usize = 1024 * 64;
51
56
const RPC_BLOB_GET_CHANNEL_CAP : usize = 2 ;
52
57
53
58
impl < D : crate :: store:: Store > Blobs < D > {
54
-
55
59
/// Handle an RPC request
56
- pub async fn handle_rpc_request < S , C > ( self : Arc < Self > ,
60
+ pub async fn handle_rpc_request < S , C > (
61
+ self : Arc < Self > ,
57
62
msg : crate :: rpc:: proto:: Request ,
58
- chan : RpcChannel < crate :: rpc:: proto:: RpcService , C , S >
63
+ chan : RpcChannel < crate :: rpc:: proto:: RpcService , C , S > ,
59
64
) -> std:: result:: Result < ( ) , RpcServerError < C > >
60
- where
61
- S : quic_rpc:: Service ,
62
- C : quic_rpc:: ServiceEndpoint < S > ,
65
+ where
66
+ S : quic_rpc:: Service ,
67
+ C : quic_rpc:: ServiceEndpoint < S > ,
63
68
{
64
69
use crate :: rpc:: proto:: Request :: * ;
65
70
match msg {
@@ -72,11 +77,11 @@ impl<D: crate::store::Store> Blobs<D> {
72
77
pub async fn handle_tags_request < S , C > (
73
78
self : Arc < Self > ,
74
79
msg : proto:: tags:: Request ,
75
- chan : RpcChannel < proto:: RpcService , C , S >
80
+ chan : RpcChannel < proto:: RpcService , C , S > ,
76
81
) -> std:: result:: Result < ( ) , RpcServerError < C > >
77
- where
78
- S : quic_rpc:: Service ,
79
- C : quic_rpc:: ServiceEndpoint < S > ,
82
+ where
83
+ S : quic_rpc:: Service ,
84
+ C : quic_rpc:: ServiceEndpoint < S > ,
80
85
{
81
86
use proto:: tags:: Request :: * ;
82
87
match msg {
@@ -91,46 +96,46 @@ impl<D: crate::store::Store> Blobs<D> {
91
96
pub async fn handle_blobs_request < Sv , C > (
92
97
self : Arc < Self > ,
93
98
msg : proto:: blobs:: Request ,
94
- chan : RpcChannel < proto:: RpcService , C , Sv >
99
+ chan : RpcChannel < proto:: RpcService , C , Sv > ,
95
100
) -> std:: result:: Result < ( ) , RpcServerError < C > >
96
- where
97
- Sv : quic_rpc:: Service ,
98
- C : quic_rpc:: ServiceEndpoint < Sv > ,
101
+ where
102
+ Sv : quic_rpc:: Service ,
103
+ C : quic_rpc:: ServiceEndpoint < Sv > ,
99
104
{
100
105
use proto:: blobs:: Request :: * ;
101
- match msg {
102
- List ( msg) => chan. server_streaming ( msg, self , Self :: blob_list) . await ,
103
- ListIncomplete ( msg) => {
104
- chan. server_streaming ( msg, self , Self :: blob_list_incomplete)
105
- . await
106
- }
107
- CreateCollection ( msg) => chan. rpc ( msg, self , Self :: create_collection) . await ,
108
- Delete ( msg) => chan. rpc ( msg, self , Self :: blob_delete_blob) . await ,
109
- AddPath ( msg) => {
110
- chan. server_streaming ( msg, self , Self :: blob_add_from_path)
111
- . await
112
- }
113
- Download ( msg) => chan. server_streaming ( msg, self , Self :: blob_download) . await ,
114
- Export ( msg) => chan. server_streaming ( msg, self , Self :: blob_export) . await ,
115
- Validate ( msg) => chan. server_streaming ( msg, self , Self :: blob_validate) . await ,
116
- Fsck ( msg) => {
117
- chan. server_streaming ( msg, self , Self :: blob_consistency_check)
118
- . await
119
- }
120
- ReadAt ( msg) => chan. server_streaming ( msg, self , Self :: blob_read_at) . await ,
121
- AddStream ( msg) => chan. bidi_streaming ( msg, self , Self :: blob_add_stream) . await ,
122
- AddStreamUpdate ( _msg) => Err ( RpcServerError :: UnexpectedUpdateMessage ) ,
123
- BlobStatus ( msg) => chan. rpc ( msg, self , Self :: blob_status) . await ,
124
- BatchCreate ( msg) => chan. bidi_streaming ( msg, self , Self :: batch_create) . await ,
125
- BatchUpdate ( _) => Err ( RpcServerError :: UnexpectedStartMessage ) ,
126
- BatchAddStream ( msg) => chan. bidi_streaming ( msg, self , Self :: batch_add_stream) . await ,
127
- BatchAddStreamUpdate ( _) => Err ( RpcServerError :: UnexpectedStartMessage ) ,
128
- BatchAddPath ( msg) => {
129
- chan. server_streaming ( msg, self , Self :: batch_add_from_path)
130
- . await
106
+ match msg {
107
+ List ( msg) => chan. server_streaming ( msg, self , Self :: blob_list) . await ,
108
+ ListIncomplete ( msg) => {
109
+ chan. server_streaming ( msg, self , Self :: blob_list_incomplete)
110
+ . await
111
+ }
112
+ CreateCollection ( msg) => chan. rpc ( msg, self , Self :: create_collection) . await ,
113
+ Delete ( msg) => chan. rpc ( msg, self , Self :: blob_delete_blob) . await ,
114
+ AddPath ( msg) => {
115
+ chan. server_streaming ( msg, self , Self :: blob_add_from_path)
116
+ . await
117
+ }
118
+ Download ( msg) => chan. server_streaming ( msg, self , Self :: blob_download) . await ,
119
+ Export ( msg) => chan. server_streaming ( msg, self , Self :: blob_export) . await ,
120
+ Validate ( msg) => chan. server_streaming ( msg, self , Self :: blob_validate) . await ,
121
+ Fsck ( msg) => {
122
+ chan. server_streaming ( msg, self , Self :: blob_consistency_check)
123
+ . await
124
+ }
125
+ ReadAt ( msg) => chan. server_streaming ( msg, self , Self :: blob_read_at) . await ,
126
+ AddStream ( msg) => chan. bidi_streaming ( msg, self , Self :: blob_add_stream) . await ,
127
+ AddStreamUpdate ( _msg) => Err ( RpcServerError :: UnexpectedUpdateMessage ) ,
128
+ BlobStatus ( msg) => chan. rpc ( msg, self , Self :: blob_status) . await ,
129
+ BatchCreate ( msg) => chan. bidi_streaming ( msg, self , Self :: batch_create) . await ,
130
+ BatchUpdate ( _) => Err ( RpcServerError :: UnexpectedStartMessage ) ,
131
+ BatchAddStream ( msg) => chan. bidi_streaming ( msg, self , Self :: batch_add_stream) . await ,
132
+ BatchAddStreamUpdate ( _) => Err ( RpcServerError :: UnexpectedStartMessage ) ,
133
+ BatchAddPath ( msg) => {
134
+ chan. server_streaming ( msg, self , Self :: batch_add_from_path)
135
+ . await
136
+ }
137
+ BatchCreateTempTag ( msg) => chan. rpc ( msg, self , Self :: batch_create_temp_tag) . await ,
131
138
}
132
- BatchCreateTempTag ( msg) => chan. rpc ( msg, self , Self :: batch_create_temp_tag) . await ,
133
- }
134
139
}
135
140
136
141
async fn blob_status ( self : Arc < Self > , msg : BlobStatusRequest ) -> RpcResult < BlobStatusResponse > {
@@ -236,7 +241,10 @@ impl<D: crate::store::Store> Blobs<D> {
236
241
Ok ( ( ) )
237
242
}
238
243
239
- fn blob_list_tags ( self : Arc < Self > , msg : TagListRequest ) -> impl Stream < Item = TagInfo > + Send + ' static {
244
+ fn blob_list_tags (
245
+ self : Arc < Self > ,
246
+ msg : TagListRequest ,
247
+ ) -> impl Stream < Item = TagInfo > + Send + ' static {
240
248
tracing:: info!( "blob_list_tags" ) ;
241
249
let blobs = self ;
242
250
Gen :: new ( |co| async move {
@@ -353,7 +361,10 @@ impl<D: crate::store::Store> Blobs<D> {
353
361
Ok ( tag)
354
362
}
355
363
356
- fn blob_download ( self : Arc < Self > , msg : BlobDownloadRequest ) -> impl Stream < Item = DownloadResponse > {
364
+ fn blob_download (
365
+ self : Arc < Self > ,
366
+ msg : BlobDownloadRequest ,
367
+ ) -> impl Stream < Item = DownloadResponse > {
357
368
let ( sender, receiver) = async_channel:: bounded ( 1024 ) ;
358
369
let endpoint = self . endpoint ( ) . clone ( ) ;
359
370
let progress = AsyncChannelProgressSender :: new ( sender) ;
@@ -518,7 +529,10 @@ impl<D: crate::store::Store> Blobs<D> {
518
529
Ok ( ( ) )
519
530
}
520
531
521
- async fn batch_create_temp_tag ( self : Arc < Self > , msg : BatchCreateTempTagRequest ) -> RpcResult < ( ) > {
532
+ async fn batch_create_temp_tag (
533
+ self : Arc < Self > ,
534
+ msg : BatchCreateTempTagRequest ,
535
+ ) -> RpcResult < ( ) > {
522
536
let blobs = self ;
523
537
let tag = blobs. store ( ) . temp_tag ( msg. content ) ;
524
538
blobs. batches ( ) . await . store ( msg. batch , tag) ;
@@ -813,7 +827,6 @@ impl<D: crate::store::Store> Blobs<D> {
813
827
. into_stream ( )
814
828
}
815
829
816
-
817
830
async fn create_collection (
818
831
self : Arc < Self > ,
819
832
req : CreateCollectionRequest ,
0 commit comments