Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
b5977243
提交
b5977243
authored
8月 25, 2021
作者:
Nazar Mokrynskyi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make dump and stats responses non-generic, will be useful for future changes
上级
93c9367e
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
48 行增加
和
44 行删除
+48
-44
messages.rs
rust/src/messages.rs
+5
-31
direct_transport.rs
rust/src/router/direct_transport.rs
+10
-2
pipe_transport.rs
rust/src/router/pipe_transport.rs
+10
-2
plain_transport.rs
rust/src/router/plain_transport.rs
+10
-2
transport.rs
rust/src/router/transport.rs
+3
-5
webrtc_transport.rs
rust/src/router/webrtc_transport.rs
+10
-2
没有找到文件。
rust/src/messages.rs
浏览文件 @
b5977243
...
@@ -28,8 +28,8 @@ use crate::worker::{WorkerDump, WorkerUpdateSettings};
...
@@ -28,8 +28,8 @@ use crate::worker::{WorkerDump, WorkerUpdateSettings};
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
use
serde
::
de
::
DeserializeOwned
;
use
serde
::
de
::
DeserializeOwned
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_json
::
Value
;
use
std
::
fmt
::
Debug
;
use
std
::
fmt
::
Debug
;
use
std
::
marker
::
PhantomData
;
use
std
::
net
::
IpAddr
;
use
std
::
net
::
IpAddr
;
use
std
::
num
::
NonZeroU16
;
use
std
::
num
::
NonZeroU16
;
...
@@ -149,32 +149,6 @@ macro_rules! request_response {
...
@@ -149,32 +149,6 @@ macro_rules! request_response {
};
};
}
}
macro_rules!
request_response_generic
{
(
$method
:
literal
,
$request_struct_name
:
ident
{
$
(
$request_field_name
:
ident
:
$request_field_type
:
ty
$
(,)
?
)
*
},
$generic_response
:
ident
,
)
=>
{
#[derive(Debug,
Serialize)]
pub
(
crate
)
struct
$request_struct_name
<
$generic_response
>
where
$generic_response
:
Debug
+
DeserializeOwned
,
{
$
(
pub
(
crate
)
$request_field_name
:
$request_field_type
,
)
*
#[serde(skip)]
pub
(
crate
)
phantom_data
:
PhantomData
<
$generic_response
>
,
}
impl
<
$generic_response
:
Debug
+
DeserializeOwned
>
Request
for
$request_struct_name
<
$generic_response
>
{
type
Response
=
$generic_response
;
fn
as_method
(
&
self
)
->
&
'static
str
{
$method
}
}
};
}
request_response!
(
"worker.close"
,
WorkerCloseRequest
{});
request_response!
(
"worker.close"
,
WorkerCloseRequest
{});
request_response!
(
"worker.dump"
,
WorkerDumpRequest
{},
WorkerDump
);
request_response!
(
"worker.dump"
,
WorkerDumpRequest
{},
WorkerDump
);
...
@@ -446,20 +420,20 @@ request_response!(
...
@@ -446,20 +420,20 @@ request_response!(
},
},
);
);
request_response
_generic
!
(
request_response!
(
"transport.dump"
,
"transport.dump"
,
TransportDumpRequest
{
TransportDumpRequest
{
internal
:
TransportInternal
,
internal
:
TransportInternal
,
},
},
Dump
,
Value
,
);
);
request_response
_generic
!
(
request_response!
(
"transport.getStats"
,
"transport.getStats"
,
TransportGetStatsRequest
{
TransportGetStatsRequest
{
internal
:
TransportInternal
,
internal
:
TransportInternal
,
},
},
Stats
,
Value
,
);
);
#[derive(Debug,
Serialize)]
#[derive(Debug,
Serialize)]
...
...
rust/src/router/direct_transport.rs
浏览文件 @
b5977243
...
@@ -395,7 +395,11 @@ impl TransportGeneric for DirectTransport {
...
@@ -395,7 +395,11 @@ impl TransportGeneric for DirectTransport {
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
debug!
(
"dump()"
);
debug!
(
"dump()"
);
self
.dump_impl
()
.await
serde_json
::
from_value
(
self
.dump_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
/// Returns current RTC statistics of the transport.
/// Returns current RTC statistics of the transport.
...
@@ -405,7 +409,11 @@ impl TransportGeneric for DirectTransport {
...
@@ -405,7 +409,11 @@ impl TransportGeneric for DirectTransport {
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
debug!
(
"get_stats()"
);
debug!
(
"get_stats()"
);
self
.get_stats_impl
()
.await
serde_json
::
from_value
(
self
.get_stats_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
}
}
...
...
rust/src/router/pipe_transport.rs
浏览文件 @
b5977243
...
@@ -422,13 +422,21 @@ impl TransportGeneric for PipeTransport {
...
@@ -422,13 +422,21 @@ impl TransportGeneric for PipeTransport {
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
debug!
(
"dump()"
);
debug!
(
"dump()"
);
self
.dump_impl
()
.await
serde_json
::
from_value
(
self
.dump_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
debug!
(
"get_stats()"
);
debug!
(
"get_stats()"
);
self
.get_stats_impl
()
.await
serde_json
::
from_value
(
self
.get_stats_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
}
}
...
...
rust/src/router/plain_transport.rs
浏览文件 @
b5977243
...
@@ -447,13 +447,21 @@ impl TransportGeneric for PlainTransport {
...
@@ -447,13 +447,21 @@ impl TransportGeneric for PlainTransport {
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
debug!
(
"dump()"
);
debug!
(
"dump()"
);
self
.dump_impl
()
.await
serde_json
::
from_value
(
self
.dump_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
debug!
(
"get_stats()"
);
debug!
(
"get_stats()"
);
self
.get_stats_impl
()
.await
serde_json
::
from_value
(
self
.get_stats_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
}
}
...
...
rust/src/router/transport.rs
浏览文件 @
b5977243
...
@@ -27,9 +27,9 @@ use log::{error, warn};
...
@@ -27,9 +27,9 @@ use log::{error, warn};
use
parking_lot
::
Mutex
;
use
parking_lot
::
Mutex
;
use
serde
::
de
::
DeserializeOwned
;
use
serde
::
de
::
DeserializeOwned
;
use
serde
::{
Deserialize
,
Serialize
};
use
serde
::{
Deserialize
,
Serialize
};
use
serde_json
::
Value
;
use
std
::
collections
::
HashMap
;
use
std
::
collections
::
HashMap
;
use
std
::
fmt
::
Debug
;
use
std
::
fmt
::
Debug
;
use
std
::
marker
::
PhantomData
;
use
std
::
sync
::
atomic
::{
AtomicUsize
,
Ordering
};
use
std
::
sync
::
atomic
::{
AtomicUsize
,
Ordering
};
use
std
::
sync
::
Arc
;
use
std
::
sync
::
Arc
;
use
thiserror
::
Error
;
use
thiserror
::
Error
;
...
@@ -395,26 +395,24 @@ pub(super) trait TransportImpl: TransportGeneric {
...
@@ -395,26 +395,24 @@ pub(super) trait TransportImpl: TransportGeneric {
}
}
}
}
async
fn
dump_impl
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
async
fn
dump_impl
(
&
self
)
->
Result
<
Value
,
RequestError
>
{
self
.channel
()
self
.channel
()
.request
(
TransportDumpRequest
{
.request
(
TransportDumpRequest
{
internal
:
TransportInternal
{
internal
:
TransportInternal
{
router_id
:
self
.router
()
.id
(),
router_id
:
self
.router
()
.id
(),
transport_id
:
self
.id
(),
transport_id
:
self
.id
(),
},
},
phantom_data
:
PhantomData
{},
})
})
.await
.await
}
}
async
fn
get_stats_impl
(
&
self
)
->
Result
<
V
ec
<
Self
::
Stat
>
,
RequestError
>
{
async
fn
get_stats_impl
(
&
self
)
->
Result
<
V
alue
,
RequestError
>
{
self
.channel
()
self
.channel
()
.request
(
TransportGetStatsRequest
{
.request
(
TransportGetStatsRequest
{
internal
:
TransportInternal
{
internal
:
TransportInternal
{
router_id
:
self
.router
()
.id
(),
router_id
:
self
.router
()
.id
(),
transport_id
:
self
.id
(),
transport_id
:
self
.id
(),
},
},
phantom_data
:
PhantomData
{},
})
})
.await
.await
}
}
...
...
rust/src/router/webrtc_transport.rs
浏览文件 @
b5977243
...
@@ -507,13 +507,21 @@ impl TransportGeneric for WebRtcTransport {
...
@@ -507,13 +507,21 @@ impl TransportGeneric for WebRtcTransport {
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
async
fn
dump
(
&
self
)
->
Result
<
Self
::
Dump
,
RequestError
>
{
debug!
(
"dump()"
);
debug!
(
"dump()"
);
self
.dump_impl
()
.await
serde_json
::
from_value
(
self
.dump_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
async
fn
get_stats
(
&
self
)
->
Result
<
Vec
<
Self
::
Stat
>
,
RequestError
>
{
debug!
(
"get_stats()"
);
debug!
(
"get_stats()"
);
self
.get_stats_impl
()
.await
serde_json
::
from_value
(
self
.get_stats_impl
()
.await
?
)
.map_err
(|
error
|
{
RequestError
::
FailedToParse
{
error
:
error
.to_string
(),
}
})
}
}
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论