Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Dunitrust
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
nodes
rust
Dunitrust
Commits
879cdfdd
Commit
879cdfdd
authored
6 years ago
by
Éloïs
Browse files
Options
Downloads
Patches
Plain Diff
[feat] conf: add method default_sync_module() & use it for sync command
parent
fbd9381e
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!151
Resolve "Allow several network modules"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/core/conf/src/lib.rs
+8
-2
8 additions, 2 deletions
lib/core/conf/src/lib.rs
lib/core/core/src/lib.rs
+62
-53
62 additions, 53 deletions
lib/core/core/src/lib.rs
lib/core/module/src/lib.rs
+2
-0
2 additions, 0 deletions
lib/core/module/src/lib.rs
with
72 additions
and
55 deletions
lib/core/conf/src/lib.rs
+
8
−
2
View file @
879cdfdd
...
...
@@ -221,20 +221,26 @@ pub enum DuRsGlobalConf {
}
impl
DursGlobalConfTrait
for
DuRsGlobalConf
{
/// Get currency
fn
currency
(
&
self
)
->
CurrencyName
{
match
*
self
{
DuRsGlobalConf
::
V1
(
ref
conf_v1
)
=>
conf_v1
.currency
.clone
(),
DuRsGlobalConf
::
V2
(
ref
conf_v2
)
=>
conf_v2
.currency
.clone
(),
}
}
/// Get node id
fn
my_node_id
(
&
self
)
->
u32
{
match
*
self
{
DuRsGlobalConf
::
V1
(
ref
conf_v1
)
=>
conf_v1
.my_node_id
,
DuRsGlobalConf
::
V2
(
ref
conf_v2
)
=>
conf_v2
.my_node_id
,
}
}
fn
default_sync_module
(
&
self
)
->
ModuleName
{
match
*
self
{
DuRsGlobalConf
::
V1
(
_
)
=>
{
fatal_error!
(
"Feature default_sync_module not exist in durs conf v1 !"
)
}
DuRsGlobalConf
::
V2
(
ref
conf_v2
)
=>
conf_v2
.default_sync_module
.clone
(),
}
}
}
impl
Default
for
DuRsConf
{
...
...
This diff is collapsed.
Click to expand it.
lib/core/core/src/lib.rs
+
62
−
53
View file @
879cdfdd
...
...
@@ -347,6 +347,14 @@ impl DursCore<DuRsConf> {
if
enabled
{
self
.network_modules_count
+=
1
;
if
let
Some
(
ServerMode
::
_Sync
(
ref
network_sync
))
=
self
.server_command
{
if
NM
::
name
()
.0
==
self
.soft_meta_datas
.conf
.get_global_conf
()
.default_sync_module
()
.0
{
// Start module in a new thread
let
router_sender
=
self
.router_sender
...
...
@@ -397,6 +405,10 @@ impl DursCore<DuRsConf> {
self
.modules_names
.push
(
NM
::
name
());
info!
(
"Success to load {} module."
,
NM
::
name
()
.to_string
());
Ok
(())
}
else
{
debug!
(
"Module '{}' not used for sync."
,
NM
::
name
());
Ok
(())
}
}
else
{
self
.plug_
::
<
NM
>
(
true
)
}
...
...
@@ -453,11 +465,8 @@ impl DursCore<DuRsConf> {
required_keys
,
module_conf
,
router_sender_clone
,
false
,
)
.unwrap_or_else
(|
_
|
{
fatal_error!
(
"Fail to load module '{}' !"
,
M
::
name
())
});
.unwrap_or_else
(|
e
|
fatal_error!
(
"Module '{}': {}"
,
M
::
name
(),
e
));
})
.map_err
(|
e
|
PlugModuleError
::
FailSpawnModuleThread
{
module_name
:
M
::
name
(),
...
...
This diff is collapsed.
Click to expand it.
lib/core/module/src/lib.rs
+
2
−
0
View file @
879cdfdd
...
...
@@ -108,6 +108,8 @@ pub trait DursGlobalConfTrait:
fn
currency
(
&
self
)
->
CurrencyName
;
/// Get node id
fn
my_node_id
(
&
self
)
->
u32
;
/// Get default sync module
fn
default_sync_module
(
&
self
)
->
ModuleName
;
}
/// Durs configuration trait
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment