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
9b67367e
Commit
9b67367e
authored
8 months ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
feat: set fiber name when executing plugin RPC handlers
parent
853d9d50
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!973
plugin rpc sdk
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
picoplugin/src/transport/rpc/server.rs
+21
-3
21 additions, 3 deletions
picoplugin/src/transport/rpc/server.rs
src/plugin/rpc/server.rs
+2
-0
2 additions, 0 deletions
src/plugin/rpc/server.rs
with
23 additions
and
3 deletions
picoplugin/src/transport/rpc/server.rs
+
21
−
3
View file @
9b67367e
...
...
@@ -153,6 +153,8 @@ pub struct FfiRpcHandler {
service_name
:
FfiSafeStr
,
/// Points into [`Self::string_storage`].
plugin_version
:
FfiSafeStr
,
/// Points into [`Self::string_storage`].
route_repr
:
FfiSafeStr
,
/// This data is owned by this struct (freed on drop).
/// This slice stores all of the strings above, so that when it's needed to
...
...
@@ -178,9 +180,11 @@ impl FfiRpcHandler {
//
// Store the strings in a contiguous slice of memory and set the pointers appropriately
//
let
total_string_len
=
identifier
.path
.len
()
+
identifier
.plugin
.len
()
let
total_string_len
=
identifier
.plugin
.len
()
// For an extra '.' between plugin and service names
+
1
+
identifier
.service
.len
()
+
identifier
.path
.len
()
+
identifier
.version
.len
();
let
mut
string_storage
=
Vec
::
with_capacity
(
total_string_len
);
let
start
=
string_storage
.as_mut_ptr
();
...
...
@@ -192,10 +196,17 @@ impl FfiRpcHandler {
p
=
p
.add
(
s
.len
());
res
};
let
path
=
push_and_get_slice
(
identifier
.path
);
let
plugin_name
=
push_and_get_slice
(
identifier
.plugin
);
push_and_get_slice
(
"."
.into
());
let
service_name
=
push_and_get_slice
(
identifier
.service
);
let
path
=
push_and_get_slice
(
identifier
.path
);
let
plugin_version
=
push_and_get_slice
(
identifier
.version
);
let
route_repr
=
unsafe
{
FfiSafeStr
::
from_raw_parts
(
NonNull
::
new_unchecked
(
start
),
total_string_len
-
plugin_version
.len
(),
)
};
debug_assert_eq!
(
start
,
...
...
@@ -218,6 +229,7 @@ impl FfiRpcHandler {
plugin_name
,
service_name
,
plugin_version
,
route_repr
,
string_storage
:
string_storage
.into
(),
}
}
...
...
@@ -308,6 +320,12 @@ impl FfiRpcHandler {
unsafe
{
self
.service_name
.as_str
()
}
}
#[inline(always)]
pub
fn
route_repr
(
&
self
)
->
&
str
{
// SAFETY: data is alive for the lifetime of `&self`, and borrow checker does it's thing
unsafe
{
self
.route_repr
.as_str
()
}
}
#[inline(always)]
pub
fn
version
(
&
self
)
->
&
str
{
// SAFETY: data is alive for the lifetime of `&self`, and borrow checker does it's thing
...
...
This diff is collapsed.
Click to expand it.
src/plugin/rpc/server.rs
+
2
−
0
View file @
9b67367e
...
...
@@ -9,6 +9,7 @@ use std::collections::HashMap;
use
tarantool
::
error
::
BoxError
;
use
tarantool
::
error
::
Error
as
TntError
;
use
tarantool
::
error
::
TarantoolErrorCode
;
use
tarantool
::
fiber
;
use
tarantool
::
tuple
::
RawBytes
;
use
tarantool
::
unwrap_ok_or
;
...
...
@@ -75,6 +76,7 @@ pub fn proc_rpc_dispatch(args: &RawBytes) -> Result<&'static RawBytes, TntError>
// TODO: check service is not poisoned
fiber
::
set_name
(
handler
.route_repr
());
let
output
=
handler
.call
(
input
,
&
context
)
.map_err
(|()|
BoxError
::
last
())
?
;
...
...
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