-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Identity carry over part 2 / Membership package (#189)
This PR is part 2 for identity carry over. In this PR we introduce a stricter interface for what a `Membership` is in a `membership` package. The membership defines an 'observable membership' for the application. Only containing members that are an active part of the membership eg. No `faulty`, `leave` or `tombstone` members will be observable. It introduces what a `Member` is via an interface and makes sure that the `swim.Member` implements it. Lastly it adds an event that is triggered when changes happen to the membership. This event is different from the swim event that contains changes in that it contains the `Before` and `After` state of a `Member` that can be used by the application to respond to.
- Loading branch information
Showing
5 changed files
with
502 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package membership | ||
|
||
// MemberChange shows the state before and after the change of a Member | ||
type MemberChange struct { | ||
// Before is the state of the member before the change, if the | ||
// member is a new member the before state is nil | ||
Before Member | ||
// After is the state of the member after the change, if the | ||
// member left the after state will be nil | ||
After Member | ||
} | ||
|
||
// ChangeEvent indicates that the membership has changed. The event will contain | ||
// a list of changes that will show both the old and the new state of a member. | ||
// It is not guaranteed that any of the observable state of a member has in fact | ||
// changed, it might only be an interal state change for the underlying | ||
// membership. | ||
type ChangeEvent struct { | ||
// Changes is a slice of changes that is related to this event | ||
Changes []MemberChange | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package membership | ||
|
||
// Member defines a member of the membership. It can be used by applications to | ||
// apply specific business logic on Members. Examples are: | ||
// - Get the address of a member for RPC calls, both forwarding of internal | ||
// calls that should target a Member | ||
// - Decissions to include a Member in a query via predicates. | ||
type Member interface { | ||
// GetAddress returns the external address used by the rpc layer to | ||
// communicate to the member. | ||
// | ||
// Note: It is prefixed with Get for legacy reasons and can be removed after | ||
// a refactor of the swim.Member to free up the `Address` name. | ||
GetAddress() string | ||
|
||
// Label reads the label for a given key from the member. It also returns | ||
// wether or not the label was present on the member | ||
Label(key string) (value string, has bool) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.