CDS

 view release on metacpan or  search on metacpan

lib/CDS.pm  view on Meta::CPAN

	$node005->addDefault($node006);
	$node005->addArrow($node011, 1, 0, 'ACTOR', \&collectActor);
	$node006->addArrow($node006, 1, 0, 'ACCOUNT', \&collectAccount);
	$node006->addArrow($node014, 1, 1, 'ACCOUNT', \&collectAccount);
	$node007->addDefault($node008);
	$node008->addArrow($node008, 1, 0, 'ACTOR', \&collectActor1);
	$node008->addArrow($node013, 1, 0, 'ACTOR', \&collectActor1);
	$node011->addArrow($node012, 1, 0, 'on');
	$node012->addArrow($node014, 1, 0, 'STORE', \&collectStore);
	$node013->addArrow($node015, 1, 0, 'active', \&collectActive);
	$node013->addArrow($node015, 1, 0, 'backup', \&collectBackup);
	$node013->addArrow($node015, 1, 0, 'idle', \&collectIdle);
	$node013->addArrow($node015, 1, 0, 'revoked', \&collectRevoked);
	$node014->addArrow($node016, 1, 0, 'and');
	$node016->addDefault($node005);
}

sub collectAccount {
	my $o = shift;
	my $label = shift;
	my $value = shift;

lib/CDS.pm  view on Meta::CPAN

	my $value = shift;

	push @{$o->{actorHashes}}, $value;
}

sub collectBackup {
	my $o = shift;
	my $label = shift;
	my $value = shift;

	$o->{status} = 'backup';
}

sub collectIdle {
	my $o = shift;
	my $label = shift;
	my $value = shift;

	$o->{status} = 'idle';
}

lib/CDS.pm  view on Meta::CPAN

	my $ui = $o->{ui};
	$ui->space;
	$ui->command('cds show actor group');
	$ui->p('Shows all members of our actor group and the entrusted keys.');
	$ui->space;
	$ui->command('cds join ACCOUNT*');
	$ui->command('cds join ACTOR on STORE');
	$ui->p('Adds a member to our actor group. To complete the association, the new member must join us, too.');
	$ui->space;
	$ui->command('cds set member ACTOR* active');
	$ui->command('cds set member ACTOR* backup');
	$ui->command('cds set member ACTOR* idle');
	$ui->command('cds set member ACTOR* revoked');
	$ui->p('Changes the status of a member to one of the following:');
	$ui->p($ui->bold('Active members'), ' share the group data among themselves, and are advertised to receive messages.');
	$ui->p($ui->bold('Backup members'), ' share the group data (like active members), but are publicly advertised as not processing messages (like idle members). This is suitable for backup actors.');
	$ui->p($ui->bold('Idle members'), ' are part of the group, but advertised as not processing messages. They generally do not have the latest group data, and may have no group data at all. Idle members may reactivate themselves, or get reactivated by ...
	$ui->p($ui->bold('Revoked members'), ' have explicitly been removed from the group, e.g. because their private key (or device) got lost. Revoked members can be reactivated by any active member of the group.');
	$ui->p('Note that changing the status does not start or stop the corresponding actor, but just change how it is regarded by others. The status of each member should reflect its actual behavior.');
	$ui->space;
	$ui->p('After modifying the actor group members, you should "cds announce" yourself to publish the changes.');
	$ui->space;
}

sub show {
	my $o = shift;

lib/CDS.pm  view on Meta::CPAN

sub type {
	my $o = shift;
	my $actorSelector = shift; die 'wrong type '.ref($actorSelector).' for $actorSelector' if defined $actorSelector && ref $actorSelector ne 'CDS::Selector';

	my $groupData = $actorSelector->child('group data')->isSet;
	my $active = $actorSelector->child('active')->isSet;
	my $revoked = $actorSelector->child('revoked')->isSet;
	return
		$revoked ? 'revoked' :
		$active && $groupData ? 'active' :
		$groupData ? 'backup' :
		$active ? 'weird' :
			'idle';
}

sub coloredType7 {
	my $o = shift;
	my $actorSelector = shift; die 'wrong type '.ref($actorSelector).' for $actorSelector' if defined $actorSelector && ref $actorSelector ne 'CDS::Selector';

	my $groupData = $actorSelector->child('group data')->isSet;
	my $active = $actorSelector->child('active')->isSet;
	my $revoked = $actorSelector->child('revoked')->isSet;
	return
		$revoked ? $o->{ui}->red('revoked') :
		$active && $groupData ? $o->{ui}->green('active ') :
		$groupData ? $o->{ui}->blue('backup ') :
		$active ? $o->{ui}->orange('weird  ') :
			$o->{ui}->gray('idle   ');
}

sub joinMember {
	my $o = shift;
	my $cmd = shift;

	$o->{accountTokens} = [];
	$cmd->collect($o);

lib/CDS.pm  view on Meta::CPAN

		my $label = substr($actorHash->bytes, 0, 16);
		my $actorSelector = $selector->child($label);

		my $record = $actorSelector->record;
		my $hash = $record->child('hash')->hashValue;
		if (! $hash) {
			$o->{ui}->pRed($actorHash->hex, ' is not a member of our actor group.');
			next;
		}

		$o->setFlag($actorSelector, 'group data', $o->{status} eq 'active' || $o->{status} eq 'backup');
		$o->setFlag($actorSelector, 'active', $o->{status} eq 'active');
		$o->setFlag($actorSelector, 'revoked', $o->{status} eq 'revoked');
		$o->{ui}->pGreen($actorHash->hex, ' is now ', $o->type($actorSelector), '.');
	}

	# Save
	$o->{actor}->saveOrShowError;
}

# BEGIN AUTOGENERATED



( run in 1.113 second using v1.01-cache-2.11-cpan-49f99fa48dc )