Skip to content

Commit df9167d

Browse files
Extract a function
1 parent 8592212 commit df9167d

File tree

2 files changed

+42
-52
lines changed

2 files changed

+42
-52
lines changed

src/api.rs

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,39 +1378,13 @@ where
13781378
pub async fn declare_amqp091_shovel(&self, params: Amqp091ShovelParams<'_>) -> Result<()> {
13791379
let runtime_param = RuntimeParameterDefinition::from(params);
13801380

1381-
let _response = self
1382-
.http_put(
1383-
path!(
1384-
"parameters",
1385-
SHOVEL_COMPONENT,
1386-
runtime_param.vhost,
1387-
runtime_param.name
1388-
),
1389-
&runtime_param,
1390-
None,
1391-
None,
1392-
)
1393-
.await?;
1394-
Ok(())
1381+
self.declare_shovel_parameters(&runtime_param).await
13951382
}
13961383

13971384
pub async fn declare_amqp10_shovel(&self, params: Amqp10ShovelParams<'_>) -> Result<()> {
13981385
let runtime_param = RuntimeParameterDefinition::from(params);
13991386

1400-
let _response = self
1401-
.http_put(
1402-
path!(
1403-
"parameters",
1404-
SHOVEL_COMPONENT,
1405-
runtime_param.vhost,
1406-
runtime_param.name
1407-
),
1408-
&runtime_param,
1409-
None,
1410-
None,
1411-
)
1412-
.await?;
1413-
Ok(())
1387+
self.declare_shovel_parameters(&runtime_param).await
14141388
}
14151389

14161390
pub async fn delete_shovel(&self, vhost: &str, name: &str, idempotently: bool) -> Result<()> {
@@ -1651,6 +1625,26 @@ where
16511625
// Implementation
16521626
//
16531627

1628+
async fn declare_shovel_parameters(
1629+
&self,
1630+
runtime_param: &RuntimeParameterDefinition<'_>,
1631+
) -> Result<()> {
1632+
let _response = self
1633+
.http_put(
1634+
path!(
1635+
"parameters",
1636+
SHOVEL_COMPONENT,
1637+
runtime_param.vhost,
1638+
runtime_param.name
1639+
),
1640+
&runtime_param,
1641+
None,
1642+
None,
1643+
)
1644+
.await?;
1645+
Ok(())
1646+
}
1647+
16541648
async fn health_check_alarms(&self, path: &str) -> Result<()> {
16551649
// we expect that StatusCode::SERVICE_UNAVAILABLE may be return and ignore
16561650
// it here to provide a custom error type later

src/blocking_api.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,35 +1211,13 @@ where
12111211
pub fn declare_amqp091_shovel(&self, params: Amqp091ShovelParams<'_>) -> Result<()> {
12121212
let runtime_param = RuntimeParameterDefinition::from(params);
12131213

1214-
let _response = self.http_put(
1215-
path!(
1216-
"parameters",
1217-
SHOVEL_COMPONENT,
1218-
runtime_param.vhost,
1219-
runtime_param.name
1220-
),
1221-
&runtime_param,
1222-
None,
1223-
None,
1224-
)?;
1225-
Ok(())
1214+
self.declare_shovel_parameter(&runtime_param)
12261215
}
12271216

12281217
pub fn declare_amqp10_shovel(&self, params: Amqp10ShovelParams<'_>) -> Result<()> {
12291218
let runtime_param = RuntimeParameterDefinition::from(params);
12301219

1231-
let _response = self.http_put(
1232-
path!(
1233-
"parameters",
1234-
SHOVEL_COMPONENT,
1235-
runtime_param.vhost,
1236-
runtime_param.name
1237-
),
1238-
&runtime_param,
1239-
None,
1240-
None,
1241-
)?;
1242-
Ok(())
1220+
self.declare_shovel_parameter(&runtime_param)
12431221
}
12441222

12451223
pub fn delete_shovel(&self, vhost: &str, name: &str, idempotently: bool) -> Result<()> {
@@ -1451,6 +1429,24 @@ where
14511429
// Implementation
14521430
//
14531431

1432+
fn declare_shovel_parameter(
1433+
&self,
1434+
runtime_param: &RuntimeParameterDefinition<'_>,
1435+
) -> Result<()> {
1436+
let _response = self.http_put(
1437+
path!(
1438+
"parameters",
1439+
SHOVEL_COMPONENT,
1440+
runtime_param.vhost,
1441+
runtime_param.name
1442+
),
1443+
&runtime_param,
1444+
None,
1445+
None,
1446+
)?;
1447+
Ok(())
1448+
}
1449+
14541450
fn health_check_alarms(&self, path: &str) -> Result<()> {
14551451
// we expect that StatusCode::SERVICE_UNAVAILABLE may be return and ignore
14561452
// it here to provide a custom error type later

0 commit comments

Comments
 (0)