Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
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
Show more breadcrumbs
core
picodata
Commits
7de556ed
Commit
7de556ed
authored
1 year ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
refactor: stub implementation for box.cfg parameters from config.yaml
parent
8856b1c6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!907
Gmoshkin/config.yaml more box cfg parameters
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/lib.rs
+3
-3
3 additions, 3 deletions
src/lib.rs
src/tarantool.rs
+30
-10
30 additions, 10 deletions
src/tarantool.rs
with
33 additions
and
13 deletions
src/lib.rs
+
3
−
3
View file @
7de556ed
...
...
@@ -620,7 +620,7 @@ fn start_discover(
luamod
::
setup
(
config
);
assert!
(
!
tarantool
::
is_box_configured
());
let
cfg
=
tarantool
::
Cfg
::
for_discovery
(
config
);
let
cfg
=
tarantool
::
Cfg
::
for_discovery
(
config
)
?
;
let
(
storage
,
raft_storage
)
=
init_common
(
config
,
&
cfg
)
?
;
discovery
::
init_global
(
config
.instance
.peers
()
.iter
()
.map
(|
a
|
a
.to_host_port
()));
...
...
@@ -706,7 +706,7 @@ fn start_boot(config: &PicodataConfig) -> Result<(), Error> {
luamod
::
setup
(
config
);
assert!
(
!
tarantool
::
is_box_configured
());
let
cfg
=
tarantool
::
Cfg
::
for_cluster_bootstrap
(
config
,
&
instance
);
let
cfg
=
tarantool
::
Cfg
::
for_cluster_bootstrap
(
config
,
&
instance
)
?
;
let
(
storage
,
raft_storage
)
=
init_common
(
config
,
&
cfg
)
?
;
let
cs
=
raft
::
ConfState
{
...
...
@@ -797,7 +797,7 @@ fn start_join(config: &PicodataConfig, instance_address: String) -> Result<(), E
luamod
::
setup
(
config
);
assert!
(
!
tarantool
::
is_box_configured
());
let
cfg
=
tarantool
::
Cfg
::
for_instance_join
(
config
,
&
resp
);
let
cfg
=
tarantool
::
Cfg
::
for_instance_join
(
config
,
&
resp
)
?
;
let
(
storage
,
raft_storage
)
=
init_common
(
config
,
&
cfg
)
?
;
let
raft_id
=
resp
.instance.raft_id
;
...
...
This diff is collapsed.
Click to expand it.
src/tarantool.rs
+
30
−
10
View file @
7de556ed
use
crate
::
config
::
ElectionMode
;
use
crate
::
config
::
PicodataConfig
;
use
crate
::
instance
::
Instance
;
use
crate
::
introspection
::
Introspection
;
use
crate
::
rpc
::
join
;
use
crate
::
schema
::
PICO_SERVICE_USER_NAME
;
use
crate
::
traft
::
error
::
Error
;
...
...
@@ -109,7 +110,7 @@ impl Cfg {
/// configuration we either will go into discovery phase after which we will
/// rebootstrap and go to the next phase (either boot or join), or if the
/// storage is already initialize we will go into the post join phase.
pub
fn
for_discovery
(
config
:
&
PicodataConfig
)
->
Self
{
pub
fn
for_discovery
(
config
:
&
PicodataConfig
)
->
Result
<
Self
,
Error
>
{
let
mut
res
=
Self
{
// These will either be chosen on the next phase or are already
// chosen and will be restored from the local storage.
...
...
@@ -134,12 +135,15 @@ impl Cfg {
..
Default
::
default
()
};
res
.set_core_parameters
(
config
);
res
res
.set_core_parameters
(
config
)
?
;
Ok
(
res
)
}
/// Initial configuration for the cluster bootstrap phase.
pub
fn
for_cluster_bootstrap
(
config
:
&
PicodataConfig
,
leader
:
&
Instance
)
->
Self
{
pub
fn
for_cluster_bootstrap
(
config
:
&
PicodataConfig
,
leader
:
&
Instance
,
)
->
Result
<
Self
,
Error
>
{
let
mut
res
=
Self
{
// At this point uuids must be valid, it will be impossible to
// change them until the instance is expelled.
...
...
@@ -160,13 +164,16 @@ impl Cfg {
..
Default
::
default
()
};
res
.set_core_parameters
(
config
);
res
res
.set_core_parameters
(
config
)
?
;
Ok
(
res
)
}
/// Initial configuration for the new instance joining to an already
/// initialized cluster.
pub
fn
for_instance_join
(
config
:
&
PicodataConfig
,
resp
:
&
join
::
Response
)
->
Self
{
pub
fn
for_instance_join
(
config
:
&
PicodataConfig
,
resp
:
&
join
::
Response
,
)
->
Result
<
Self
,
Error
>
{
let
mut
replication_cfg
=
Vec
::
with_capacity
(
resp
.box_replication
.len
());
let
password
=
crate
::
pico_service
::
pico_service_password
();
for
address
in
&
resp
.box_replication
{
...
...
@@ -196,11 +203,11 @@ impl Cfg {
..
Default
::
default
()
};
res
.set_core_parameters
(
config
);
res
res
.set_core_parameters
(
config
)
?
;
Ok
(
res
)
}
pub
fn
set_core_parameters
(
&
mut
self
,
config
:
&
PicodataConfig
)
{
pub
fn
set_core_parameters
(
&
mut
self
,
config
:
&
PicodataConfig
)
->
Result
<
(),
Error
>
{
self
.log
=
config
.instance.log
.clone
();
self
.log_level
=
Some
(
config
.instance
.log_level
()
as
_
);
...
...
@@ -208,8 +215,21 @@ impl Cfg {
self
.memtx_dir
=
config
.instance
.data_dir
();
self
.vinyl_dir
=
config
.instance
.data_dir
();
// FIXME: make the loop below work with default values
self
.other_fields
.insert
(
"memtx_memory"
.into
(),
config
.instance
.memtx_memory
()
.into
());
#[rustfmt::skip]
const
MAPPING
:
&
[(
&
str
,
&
str
)]
=
&
[
];
for
(
box_field
,
picodata_field
)
in
MAPPING
{
let
value
=
config
.get_field_as_rmpv
(
picodata_field
)
.map_err
(|
e
|
Error
::
other
(
format!
(
"internal error: {e}"
)))
?
;
self
.other_fields
.insert
((
*
box_field
)
.into
(),
value
);
}
Ok
(())
}
}
...
...
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