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
cfdead8e
Commit
cfdead8e
authored
2 years ago
by
Georgy Moshkin
Committed by
Georgy Moshkin
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
wip: vshard config
parent
cc39db60
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!299
Feat/poor mans vshard
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main.rs
+17
-0
17 additions, 0 deletions
src/main.rs
src/traft/rpc/mod.rs
+1
-0
1 addition, 0 deletions
src/traft/rpc/mod.rs
src/traft/rpc/sharding.rs
+63
-0
63 additions, 0 deletions
src/traft/rpc/sharding.rs
with
81 additions
and
0 deletions
src/main.rs
+
17
−
0
View file @
cfdead8e
...
...
@@ -174,6 +174,23 @@ fn picolib_setup(args: &args::Run) {
Ok
(())
}),
);
luamod
.set
(
"vshard_cfg"
,
tlua
::
function0
(||
->
Result
<
traft
::
rpc
::
sharding
::
cfg
::
Cfg
,
Error
>
{
let
node
=
traft
::
node
::
global
()
?
;
traft
::
rpc
::
sharding
::
cfg
::
Cfg
::
from_storage
(
&
node
.storage.peers
)
}),
);
l
.exec
(
"
picolib.test_space = function(name)
local s = box.schema.space.create(name, {is_sync = true, if_not_exists = true})
s:create_index('pk', {if_not_exists = true})
return s
end
"
,
)
.unwrap
();
}
luamod
.set
(
"log"
,
&
[()]);
#[rustfmt::skip]
...
...
This diff is collapsed.
Click to expand it.
src/traft/rpc/mod.rs
+
1
−
0
View file @
cfdead8e
...
...
@@ -5,6 +5,7 @@ use std::fmt::Debug;
use
serde
::
de
::
DeserializeOwned
;
pub
mod
replication
;
pub
mod
sharding
;
/// Types implementing this trait represent an RPC's (remote procedure call)
/// arguments. This trait contains information about the request.
...
...
This diff is collapsed.
Click to expand it.
src/traft/rpc/sharding.rs
0 → 100644
+
63
−
0
View file @
cfdead8e
#[rustfmt::skip]
pub
mod
cfg
{
use
crate
::
traft
::
error
::
Error
;
use
crate
::
traft
::
storage
::
peer_field
;
use
crate
::
traft
::
storage
::
Peers
;
use
::
tarantool
::
tlua
;
use
std
::
collections
::
HashMap
;
#[derive(Default,
Clone,
Debug,
PartialEq,
Eq)]
#[derive(tlua::PushInto,
tlua::Push,
tlua::LuaRead)]
pub
struct
Cfg
{
sharding
:
HashMap
<
String
,
Replicaset
>
,
discovery_mode
:
DiscoveryMode
,
}
#[derive(Default,
Clone,
Debug,
PartialEq,
Eq)]
#[derive(tlua::PushInto,
tlua::Push,
tlua::LuaRead)]
struct
Replicaset
{
replicas
:
HashMap
<
String
,
Replica
>
,
}
#[derive(Default,
Clone,
Debug,
PartialEq,
Eq)]
#[derive(tlua::PushInto,
tlua::Push,
tlua::LuaRead)]
struct
Replica
{
uri
:
String
,
name
:
String
,
master
:
bool
,
}
#[derive(Default,
Copy,
Clone,
Debug,
PartialEq,
Eq)]
#[derive(tlua::PushInto,
tlua::Push,
tlua::LuaRead)]
pub
enum
DiscoveryMode
{
#[default]
Off
,
On
,
Once
,
}
impl
Cfg
{
pub
fn
from_storage
(
peers
:
&
Peers
)
->
Result
<
Self
,
Error
>
{
use
peer_field
::{
InstanceId
,
InstanceUuid
,
PeerAddress
,
ReplicasetUuid
,
IsMaster
};
type
Fields
=
(
InstanceId
,
InstanceUuid
,
PeerAddress
,
ReplicasetUuid
,
IsMaster
);
let
mut
sharding
:
HashMap
<
String
,
Replicaset
>
=
HashMap
::
new
();
for
(
id
,
uuid
,
addr
,
rset
,
is_master
)
in
peers
.peers_fields
::
<
Fields
>
()
?
{
let
replicaset
=
sharding
.entry
(
rset
)
.or_default
();
replicaset
.replicas
.insert
(
uuid
,
Replica
{
uri
:
format!
(
"guest:@{addr}"
),
name
:
id
.into
(),
master
:
is_master
,
},
);
}
Ok
(
Self
{
sharding
,
discovery_mode
:
DiscoveryMode
::
Off
,
})
}
}
}
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