-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Member Roles
doc
#5742
Add Member Roles
doc
#5742
Changes from 3 commits
a81c258
4563c2c
5de627d
210ae39
d7de54a
8529d77
876a5b4
76ff75a
a2374d4
400bec0
66a4b6f
82a4380
6fee097
dbd5dd5
aad9f44
854d723
a300b06
3bc1939
ae9a01f
fca18c5
d16ea43
c8ab363
43d8791
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
uid: member-roles | ||
title: Member Roles | ||
--- | ||
|
||
# Why Are Roles Important | ||
|
||
A cluster can have multiple Akka.NET applications in it, "roles" help to distinguish different Akka.NET applications within a cluster! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Diagram would be useful here |
||
|
||
# How Can Roles Help | ||
|
||
Not all Akka.NET applications in a cluster need to perform the same function. For example, there might be one sub-set which runs the web front-end, one which runs the data access layer and one for the number-crunching. | ||
Choosing which actors to start on each node, for example cluster-aware routers, can take member roles into account to achieve this distribution of responsibilities. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something needs to be said about usage of roles being a best practice. There isn't a good reason not to do it. Just come out and say this along the following lines:
|
||
|
||
# Usage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this to right after your opening sentence in the document, drop the |
||
|
||
The member roles are defined in the configuration property named `akka.cluster.roles`: | ||
|
||
``` | ||
akka { | ||
cluster { | ||
roles = ["backend"] | ||
} | ||
} | ||
``` | ||
|
||
and typically defined in the start script as a system property or environment variable. | ||
|
||
``` | ||
var settings = ClusterShardingSettings | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wrong thing. This is showing how roles can be consumed from Akka.Cluster sharding. Has nothing to do with how they're defined in Akka.Cluster. |
||
.Create(_system) | ||
.WithRole(Environment.GetEnvironmentVariable("ROLE")); | ||
``` | ||
|
||
The roles are part of the membership information in `MemberEvent` that you can subscribe to. The roles of the local cluster member are available from the `SelfMember` and that can be used for conditionally starting certain actors: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
```csharp | ||
var selfMember = Cluster.Get(_actorSystem).SelfMember; | ||
if (selfMember.HasRole("backend")) | ||
{ | ||
context.ActorOf(Backend.Prop(), "back"); | ||
} | ||
else if (selfMember.HasRole("front")) | ||
{ | ||
context.ActorOf(Frontend.Prop(), "front"); | ||
} | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,4 +21,6 @@ | |
- name: Distributed Data | ||
href: distributed-data.md | ||
- name: Split Brain Resolver | ||
href: split-brain-resolver.md | ||
href: split-brain-resolver.md | ||
- name: Member Roles | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this much closer to the top - as this is a critical, fundamental concept to clustering. Also, link to this page from the cluster overview early on. |
||
href: member-roles.md |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Title:
Member Roles