Documentation ¶
Overview ¶
This package provides utility to deal with the group synchronization issue.
The "groups" attribute of the User resource is a readOnly attribute, which shall be updated according to the change of "members" in Group resources. This package provides mere utilities that may be helpful, it does not assume a certain way to resolve this issue.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Diff ¶
type Diff struct {
// contains filtered or unexported fields
}
Diff reports the difference between the members of two group resources.
func Compare ¶
Compare compares the two snapshots of two group resources before and after the modification and reports their differences in membership. At least one of before and after should be non-nil. When before is nil, all members of the after resource are considered to have just joined; when after is nil, all members of the before resource are considered to have just left.
func (*Diff) CountJoined ¶
CountJoined returns the total number of new members that joined the group.
func (*Diff) ForEachJoined ¶
ForEachJoined iterates all member ids that joined the group and invoke the callback.
func (*Diff) ForEachLeft ¶
ForEachLeft iterates all member ids that left the group and invoke the callback.
type SyncService ¶
type SyncService struct {
// contains filtered or unexported fields
}
SyncService synchronizes the user resource's "groups" property.
func NewSyncService ¶
func NewSyncService(groupDB db.DB) *SyncService
NewSyncService returns a new SyncService.
func (*SyncService) SyncGroupPropertyForUser ¶
SyncGroupPropertyForUser updates the user's "groups" property, according to the latest state in Group resources. This method does not save or replace the updated resource with the database. It is up to the caller to do so.
Due to nested membership, this method may search the group database multiple times, which may turn out to be a lengthy process. The ctx context can be used to set a timeline or cancel the processing, this method will respect that at appropriate intervals.