# Module cpg_data

- Description
- Data Types
- Function Index
- Function Details

### CPG Data Group Lookups.

All functions in this module are for using cached cpg data without sending messages to the cpg scope process.

Copyright © 2011-2020 Michael Truog

Version: 1.8.1 Nov 26 2020 15:22:42 ------------------------------------------------------------------------

Authors: Michael Truog (`mjtruog at protonmail dot com`).

## Description

### CPG Data Group Lookups.

All functions in this module are for using cached cpg data without sending messages to the cpg scope process. Using this module for cpg group lookups is equivalent to the lazy destination refresh methods in CloudI.

## Data Types

### get_members_return()

`get_members_return() = {ok, cpg:name(), [pid(), ...]} | {error, {no_such_group, cpg:name()}}`

### get_pid_error_reason()

`get_pid_error_reason() = {no_process, cpg:name()} | {no_such_group, cpg:name()}`

### state()

`state() = {DictI::module(), GroupsData::any()}`

## Function Index

get_closest_pid/2 | #### Get a group member, with local pids given priority. .
get_closest_pid/3 | #### Get a group member, with local pids given priority while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_empty_groups/0 | #### Get empty group storage. .
get_furthest_pid/2 | #### Get a group member, with remote pids given priority. .
get_furthest_pid/3 | #### Get a group member, with remote pids given priority while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_groups/0 | #### Get the group storage. This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.
get_groups/1 | #### Get the group storage for a particular scope or after a period of time. This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.
get_groups/2 | #### Get the group storage for a particular scope after a period of time. This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.
get_groups/3 | #### Get the group storage for a particular scope and destination after a period of time. This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.
get_local_members/2 | #### Get only the local members of a specific group. All members are ordered from newest to oldest, based on the join order, not pid creation time.
get_local_members/3 | #### Get only the local members of a specific group while excluding a specific pid. All members are ordered from newest to oldest, based on the join order, not pid creation time.
get_local_newest_pid/2 | #### Get the newest local group member. .
get_local_newest_pid/3 | #### Get the newest local group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_local_oldest_pid/2 | #### Get the oldest local group member. .
get_local_oldest_pid/3 | #### Get the oldest local group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_local_pid/2 | #### Get a local group member. .
get_local_pid/3 | #### Get a local group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_members/2 | #### Get the members of a specific group. All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time).
get_members/3 | #### Get the members of a specific group while excluding a specific pid. All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time).
get_newest_pid/2 | #### Get the newest group member. .
get_newest_pid/3 | #### Get the newest group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_oldest_pid/2 | #### Get the oldest group member. .
get_oldest_pid/3 | #### Get the oldest group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_random_pid/2 | #### Get a group member. .
get_random_pid/3 | #### Get a group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_remote_members/2 | #### Get only the remote members of a specific group. All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time).
get_remote_members/3 | #### Get only the remote members of a specific group while excluding a specific pid. All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time).
get_remote_newest_pid/2 | #### Get the newest remote group member. .
get_remote_newest_pid/3 | #### Get the newest remote group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_remote_oldest_pid/2 | #### Get the oldest remote group member. .
get_remote_oldest_pid/3 | #### Get the oldest remote group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
get_remote_pid/2 | #### Get a remote group member. .
get_remote_pid/3 | #### Get a remote group member while excluding a specific pid. Usually the self() pid is excluded with this function call.
which_groups/1 | #### Get all the groups currently defined. .

## Function Details

### get_closest_pid/2

`get_closest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a group member, with local pids given priority.

### get_closest_pid/3

`get_closest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a group member, with local pids given priority while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_empty_groups/0

`get_empty_groups() -> state()`

#### Get empty group storage.

### get_furthest_pid/2

`get_furthest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a group member, with remote pids given priority.

### get_furthest_pid/3

`get_furthest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a group member, with remote pids given priority while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_groups/0

`get_groups() -> state()`

#### Get the group storage.

This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.

### get_groups/1

`get_groups(Scope::atom() | non_neg_integer()) -> state() | reference()`

#### Get the group storage for a particular scope or after a period of time.

This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.

### get_groups/2

`get_groups(Scope::atom(), Time::non_neg_integer()) -> reference()`

#### Get the group storage for a particular scope after a period of time.

This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.

### get_groups/3

`get_groups(Scope::atom(), Destination::pid() | atom(), Time::non_neg_integer()) -> reference()`

#### Get the group storage for a particular scope and destination after a period of time.

This provides the internal representation of process groups so that requests will not be blocked by the single process managing the scope of the process groups.

### get_local_members/2

`get_local_members(GroupName::cpg:name(), Groups::state()) -> get_members_return()`

#### Get only the local members of a specific group.

All members are ordered from newest to oldest, based on the join order, not pid creation time.

### get_local_members/3

`get_local_members(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> get_members_return()`

#### Get only the local members of a specific group while excluding a specific pid.

All members are ordered from newest to oldest, based on the join order, not pid creation time. Usually the self() pid is excluded with this function call.

### get_local_newest_pid/2

`get_local_newest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the newest local group member.

### get_local_newest_pid/3

`get_local_newest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the newest local group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_local_oldest_pid/2

`get_local_oldest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the oldest local group member.

### get_local_oldest_pid/3

`get_local_oldest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the oldest local group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_local_pid/2

`get_local_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a local group member.

### get_local_pid/3

`get_local_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a local group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_members/2

`get_members(GroupName::cpg:name(), Groups::state()) -> get_members_return()`

#### Get the members of a specific group.

All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time).

### get_members/3

`get_members(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> get_members_return()`

#### Get the members of a specific group while excluding a specific pid.

All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time). Usually the self() pid is excluded with this function call.

### get_newest_pid/2

`get_newest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the newest group member.

### get_newest_pid/3

`get_newest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the newest group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_oldest_pid/2

`get_oldest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the oldest group member.

### get_oldest_pid/3

`get_oldest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the oldest group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_random_pid/2

`get_random_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a group member.

### get_random_pid/3

`get_random_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_remote_members/2

`get_remote_members(GroupName::cpg:name(), Groups::state()) -> get_members_return()`

#### Get only the remote members of a specific group.

All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time).

### get_remote_members/3

`get_remote_members(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> get_members_return()`

#### Get only the remote members of a specific group while excluding a specific pid.

All members are ordered from newest to oldest, based on the group membership surviving netsplits (join order, not pid creation time). Usually the self() pid is excluded with this function call.

### get_remote_newest_pid/2

`get_remote_newest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the newest remote group member.

### get_remote_newest_pid/3

`get_remote_newest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the newest remote group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_remote_oldest_pid/2

`get_remote_oldest_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the oldest remote group member.

### get_remote_oldest_pid/3

`get_remote_oldest_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get the oldest remote group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### get_remote_pid/2

`get_remote_pid(GroupName::cpg:name(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a remote group member.

### get_remote_pid/3

`get_remote_pid(GroupName::cpg:name(), Exclude::pid(), Groups::state()) -> {ok, cpg:name(), pid()} | {error, get_pid_error_reason()}`

#### Get a remote group member while excluding a specific pid.

Usually the self() pid is excluded with this function call.

### which_groups/1

`which_groups(X1::state()) -> [cpg:name()]`

#### Get all the groups currently defined.

Generated by EDoc