Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
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
Operations
Operations
Metrics
Environments
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 Framework
Commits
37c3b185
Commit
37c3b185
authored
Sep 04, 2014
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add caf::io::remote_group
parent
27f426c1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
103 additions
and
7 deletions
+103
-7
libcaf_io/caf/io/remote_group.hpp
libcaf_io/caf/io/remote_group.hpp
+40
-0
libcaf_io/src/publish_local_groups.cpp
libcaf_io/src/publish_local_groups.cpp
+3
-7
libcaf_io/src/remote_group.cpp
libcaf_io/src/remote_group.cpp
+60
-0
No files found.
libcaf_io/caf/io/remote_group.hpp
0 → 100644
View file @
37c3b185
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENCE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_REMOTE_GROUP_HPP
#define CAF_IO_REMOTE_GROUP_HPP
#include "caf/group.hpp"
namespace
caf
{
namespace
io
{
/**
* <group-name>@<host>:<port>
*/
group
remote_group
(
const
std
::
string
&
group_uri
);
group
remote_group
(
const
std
::
string
&
group_identifier
,
const
std
::
string
&
host
,
uint16_t
port
);
}
// namespace io
}
// namespace caf
#endif // CAF_IO_REMOTE_GROUP_HPP
libcaf_io/src/publish_local_groups.cpp
View file @
37c3b185
...
@@ -30,11 +30,8 @@ namespace {
...
@@ -30,11 +30,8 @@ namespace {
struct
group_nameserver
:
event_based_actor
{
struct
group_nameserver
:
event_based_actor
{
behavior
make_behavior
()
override
{
behavior
make_behavior
()
override
{
return
{
return
{
on
(
atom
(
"GET_GROUP"
),
arg_match
)
>>
[](
const
std
::
string
&
name
)
{
on
(
atom
(
"GetGroup"
),
arg_match
)
>>
[](
const
std
::
string
&
name
)
{
return
make_message
(
atom
(
"GROUP"
),
group
::
get
(
"local"
,
name
));
return
make_message
(
atom
(
"Group"
),
group
::
get
(
"local"
,
name
));
},
on
(
atom
(
"SHUTDOWN"
))
>>
[
=
]
{
quit
();
}
}
};
};
}
}
...
@@ -48,8 +45,7 @@ void publish_local_groups(uint16_t port, const char* addr) {
...
@@ -48,8 +45,7 @@ void publish_local_groups(uint16_t port, const char* addr) {
publish
(
gn
,
port
,
addr
);
publish
(
gn
,
port
,
addr
);
}
}
catch
(
std
::
exception
&
)
{
catch
(
std
::
exception
&
)
{
gn
->
enqueue
(
invalid_actor_addr
,
message_id
::
invalid
,
anon_send_exit
(
gn
,
exit_reason
::
user_shutdown
);
make_message
(
atom
(
"SHUTDOWN"
)),
nullptr
);
throw
;
throw
;
}
}
}
}
...
...
libcaf_io/src/remote_group.cpp
0 → 100644
View file @
37c3b185
/******************************************************************************
* ____ _ _____ *
* / ___| / \ | ___| C++ *
* | | / _ \ | |_ Actor *
* | |___ / ___ \| _| Framework *
* \____/_/ \_|_| *
* *
* Copyright (C) 2011 - 2014 *
* Dominik Charousset <dominik.charousset (at) haw-hamburg.de> *
* *
* Distributed under the terms and conditions of the BSD 3-Clause License or *
* (at your option) under the terms and conditions of the Boost Software *
* License 1.0. See accompanying files LICENSE and LICENCE_ALTERNATIVE. *
* *
* If you did not receive a copy of the license files, see *
* http://opensource.org/licenses/BSD-3-Clause and *
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#include "caf/io/remote_group.hpp"
#include "caf/scoped_actor.hpp"
#include "caf/io/remote_actor.hpp"
namespace
caf
{
namespace
io
{
group
remote_group
(
const
std
::
string
&
group_uri
)
{
// format of group_identifier is group@host:port
// a regex would be the natural choice here, but we want to support
// older compilers that don't have <regex> implemented (e.g. GCC < 4.9)
auto
pos1
=
group_uri
.
find
(
'@'
);
auto
pos2
=
group_uri
.
find
(
':'
);
auto
last
=
std
::
string
::
npos
;
if
(
pos1
==
last
||
pos2
==
last
||
pos1
>=
pos2
)
{
throw
std
::
invalid_argument
(
"group_uri has an invalid format"
);
}
auto
name
=
group_uri
.
substr
(
0
,
pos1
);
auto
host
=
group_uri
.
substr
(
pos1
+
1
,
pos2
-
pos1
-
1
);
auto
port
=
static_cast
<
uint16_t
>
(
group_uri
.
substr
(
pos2
+
1
));
return
remote_group
(
name
,
host
,
port
);
}
group
remote_group
(
const
std
::
string
&
group_identifier
,
const
std
::
string
&
host
,
uint16_t
port
)
{
auto
group_server
=
remote_actor
(
host
,
port
);
scoped_actor
self
;
self
->
send
(
group_server
,
atom
(
"GetGroup"
),
group_identifier
);
group
result
;
self
->
receive
(
on
(
atom
(
"Group"
),
arg_match
)
>>
[
&
](
group
&
grp
)
{
result
=
std
::
move
(
grp
);
}
);
return
result
;
}
}
// namespace io
}
// namespace caf
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