Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
actor-incubator
Commits
0a4764f3
Commit
0a4764f3
authored
Sep 11, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement local path lookup into the registry
parent
f76af85f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
libcaf_net/src/application.cpp
libcaf_net/src/application.cpp
+20
-1
libcaf_net/test/application.cpp
libcaf_net/test/application.cpp
+31
-1
No files found.
libcaf_net/src/application.cpp
View file @
0a4764f3
...
...
@@ -26,6 +26,7 @@
#include "caf/byte.hpp"
#include "caf/defaults.hpp"
#include "caf/detail/network_order.hpp"
#include "caf/detail/parse.hpp"
#include "caf/error.hpp"
#include "caf/expected.hpp"
#include "caf/net/basp/constants.hpp"
...
...
@@ -34,6 +35,7 @@
#include "caf/none.hpp"
#include "caf/sec.hpp"
#include "caf/serializer_impl.hpp"
#include "caf/string_algorithms.hpp"
#include "caf/type_erased_tuple.hpp"
namespace
caf
{
...
...
@@ -49,7 +51,24 @@ expected<std::vector<byte>> application::serialize(actor_system& sys,
return
result
;
}
strong_actor_ptr
application
::
resolve_local_path
(
string_view
)
{
strong_actor_ptr
application
::
resolve_local_path
(
string_view
path
)
{
// We currently support two path formats: `id/<actor_id>` and `name/<atom>`.
static
constexpr
string_view
id_prefix
=
"id/"
;
if
(
starts_with
(
path
,
id_prefix
))
{
path
.
remove_prefix
(
id_prefix
.
size
());
actor_id
aid
;
if
(
auto
err
=
detail
::
parse
(
path
,
aid
))
return
nullptr
;
return
system
().
registry
().
get
(
aid
);
}
static
constexpr
string_view
name_prefix
=
"name/"
;
if
(
starts_with
(
path
,
name_prefix
))
{
path
.
remove_prefix
(
name_prefix
.
size
());
atom_value
name
;
if
(
auto
err
=
detail
::
parse
(
path
,
name
))
return
nullptr
;
return
system
().
registry
().
get
(
name
);
}
return
nullptr
;
}
...
...
libcaf_net/test/application.cpp
View file @
0a4764f3
...
...
@@ -203,7 +203,7 @@ CAF_TEST(resolve request without result) {
handle_handshake
();
consume_handshake
();
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_header
);
MOCK
(
basp
::
message_type
::
resolve_request
,
42
,
std
::
string
{
"
/
foo/bar"
});
MOCK
(
basp
::
message_type
::
resolve_request
,
42
,
std
::
string
{
"foo/bar"
});
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_header
);
actor_id
aid
;
std
::
set
<
std
::
string
>
ifs
;
...
...
@@ -212,6 +212,36 @@ CAF_TEST(resolve request without result) {
CAF_CHECK
(
ifs
.
empty
());
}
CAF_TEST
(
resolve
request
on
id
with
result
)
{
handle_handshake
();
consume_handshake
();
sys
.
registry
().
put
(
self
->
id
(),
self
);
auto
path
=
"id/"
+
std
::
to_string
(
self
->
id
());
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_header
);
MOCK
(
basp
::
message_type
::
resolve_request
,
42
,
path
);
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_header
);
actor_id
aid
;
std
::
set
<
std
::
string
>
ifs
;
RECEIVE
(
basp
::
message_type
::
resolve_response
,
42u
,
aid
,
ifs
);
CAF_CHECK_EQUAL
(
aid
,
self
->
id
());
CAF_CHECK
(
ifs
.
empty
());
}
CAF_TEST
(
resolve
request
on
name
with
result
)
{
handle_handshake
();
consume_handshake
();
sys
.
registry
().
put
(
atom
(
"foo"
),
self
);
std
::
string
path
=
"name/foo"
;
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_header
);
MOCK
(
basp
::
message_type
::
resolve_request
,
42
,
path
);
CAF_CHECK_EQUAL
(
app
.
state
(),
basp
::
connection_state
::
await_header
);
actor_id
aid
;
std
::
set
<
std
::
string
>
ifs
;
RECEIVE
(
basp
::
message_type
::
resolve_response
,
42u
,
aid
,
ifs
);
CAF_CHECK_EQUAL
(
aid
,
self
->
id
());
CAF_CHECK
(
ifs
.
empty
());
}
CAF_TEST
(
heartbeat
message
)
{
handle_handshake
();
consume_handshake
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment