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
e6aaa459
Commit
e6aaa459
authored
1 year ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
feat: .proc_runtime_info
parent
573aec7b
No related branches found
No related tags found
1 merge request
!840
Info proc API
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/info.rs
+58
-0
58 additions, 0 deletions
src/info.rs
test/int/test_basics.py
+23
-0
23 additions, 0 deletions
test/int/test_basics.py
with
81 additions
and
0 deletions
src/info.rs
+
58
−
0
View file @
e6aaa459
...
@@ -4,6 +4,8 @@ use crate::replicaset::ReplicasetId;
...
@@ -4,6 +4,8 @@ use crate::replicaset::ReplicasetId;
use
crate
::
traft
::
error
::
Error
;
use
crate
::
traft
::
error
::
Error
;
use
crate
::
traft
::
node
;
use
crate
::
traft
::
node
;
use
crate
::
traft
::
RaftId
;
use
crate
::
traft
::
RaftId
;
use
crate
::
traft
::
RaftIndex
;
use
crate
::
traft
::
RaftTerm
;
use
std
::
borrow
::
Cow
;
use
std
::
borrow
::
Cow
;
use
tarantool
::
proc
;
use
tarantool
::
proc
;
...
@@ -180,3 +182,59 @@ pub fn proc_raft_info() -> Result<RaftInfo, Error> {
...
@@ -180,3 +182,59 @@ pub fn proc_raft_info() -> Result<RaftInfo, Error> {
Ok
(
RaftInfo
::
get
(
node
))
Ok
(
RaftInfo
::
get
(
node
))
}
}
////////////////////////////////////////////////////////////////////////////////
// InternalInfo
////////////////////////////////////////////////////////////////////////////////
#[derive(Clone,
Debug,
::serde::Serialize,
::serde::Deserialize)]
pub
struct
InternalInfo
<
'a
>
{
pub
main_loop_status
:
Cow
<
'a
,
str
>
,
pub
governor_loop_status
:
Cow
<
'a
,
str
>
,
}
impl
tarantool
::
tuple
::
Encode
for
InternalInfo
<
'_
>
{}
impl
InternalInfo
<
'static
>
{
pub
fn
get
(
node
:
&
node
::
Node
)
->
Self
{
InternalInfo
{
main_loop_status
:
node
.status
()
.main_loop_status
.into
(),
governor_loop_status
:
node
.governor_loop.status
.get
()
.governor_loop_status
.into
(),
}
}
}
////////////////////////////////////////////////////////////////////////////////
// RuntimeInfo
////////////////////////////////////////////////////////////////////////////////
/// Info returned from [`.proc_runtime_info`].
///
/// [`.proc_runtime_info`]: proc_runtime_info
#[derive(Clone,
Debug,
::serde::Serialize,
::serde::Deserialize)]
pub
struct
RuntimeInfo
<
'a
>
{
pub
raft
:
RaftInfo
,
pub
internal
:
InternalInfo
<
'a
>
,
}
impl
tarantool
::
tuple
::
Encode
for
RuntimeInfo
<
'_
>
{}
impl
RuntimeInfo
<
'static
>
{
pub
fn
try_get
(
node
:
&
node
::
Node
)
->
Result
<
Self
,
Error
>
{
Ok
(
RuntimeInfo
{
raft
:
RaftInfo
::
get
(
node
),
internal
:
InternalInfo
::
get
(
node
),
})
}
}
////////////////////////////////////////////////////////////////////////////////
// .proc_runtime_info
////////////////////////////////////////////////////////////////////////////////
#[proc]
pub
fn
proc_runtime_info
()
->
Result
<
RuntimeInfo
<
'static
>
,
Error
>
{
let
node
=
node
::
global
()
?
;
RuntimeInfo
::
try_get
(
node
)
}
This diff is collapsed.
Click to expand it.
test/int/test_basics.py
+
23
−
0
View file @
e6aaa459
...
@@ -390,3 +390,26 @@ def test_proc_raft_info(instance: Instance):
...
@@ -390,3 +390,26 @@ def test_proc_raft_info(instance: Instance):
leader_id
=
1
,
leader_id
=
1
,
state
=
"
Leader
"
,
state
=
"
Leader
"
,
)
)
def
test_proc_runtime_info
(
instance
:
Instance
):
info
=
instance
.
call
(
"
.proc_runtime_info
"
)
assert
isinstance
(
info
[
"
raft
"
][
"
applied
"
],
int
)
# This field is super volatile, don't want to be updating it every time we
# add a bootstrap entry.
info
[
"
raft
"
][
"
applied
"
]
=
69
assert
info
==
dict
(
raft
=
dict
(
id
=
1
,
term
=
2
,
applied
=
69
,
leader_id
=
1
,
state
=
"
Leader
"
,
),
internal
=
dict
(
main_loop_status
=
"
idle
"
,
governor_loop_status
=
"
idle
"
,
),
)
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