Convos::Core::Backend - Convos storage backend

  1. DESCRIPTION
  2. ATTRIBUTES
  3. METHODS
    1. connections_p
    2. delete_messages_p
    3. delete_object_p
    4. emit_to_class_p
    5. load_object_p
    6. on
    7. messages_p
    8. new
    9. notifications_p
    10. save_object_p
    11. users_p
  4. SEE ALSO

DESCRIPTION

Convos::Core::Backend is a base class for storage backends. See Convos::Core::Backend::File for code that actually perist data.

ATTRIBUTES

Convos::Core::Backend inherits all attributes from Mojo::EventEmitter and implements the following new ones.

METHODS

Convos::Core::Backend inherits all methods from Mojo::EventEmitter and implements the following new ones.

connections_p

$p = $backend->connections($user)->then(sub { my $connections = shift });

Used to find a list of connection names for a given $user.

delete_messages_p

$p = $backend->delete_object_p($obj)->then(sub { my $obj = shift });

This method will delete all messages for a given conversation.

delete_object_p

$p = $backend->delete_object_p($obj)->then(sub { my $obj = shift });

This method is called to remove a given object from persistent storage.

emit_to_class_p

$p = $backend->emit_to_class_p($name => @params);

Used instead of "emit" in Mojo::EventEmitter when you want to call a method in a class, registered with "on".

# Register a handler
$backend->on(message_to_paste => "Convos::Plugin::Files::File");

# Dispatch to the handler
# Will call Convos::Plugin::Files::File->handle_message_to_paste_p()
# with arguments ("Convos::Plugin::Files::File", $backend, @args)
$backend->emit_to_class_p(message_to_paste => @args);

See "handle_message_to_paste_p" in Convos::Plugin::Files::File for example handler.

load_object_p

$p = $backend->load_object_p($obj)->then(sub { my $obj = shift });

This method will load $data for $obj.

on

$backend->on(event_name => sub { my ($backend, @args) = @_ });
$backend->on(event_name => "Some::Class::Name");

Used to register either a class or callback to be used on an event.

See "on" in Mojo::EventEmitter for the callback version, and "emit_to_class_p" for the class version.

messages_p

$p = $backend->messages_p(\%query)->then(sub { my $res = shift; });

Used to search for messages stored in backend. The callback will be called with the messages found.

Possible %query:

{
  after  => $datetime, # find messages after a given ISO 8601 timestamp
  before => $datetime, # find messages before a given ISO 8601 timestamp
  level  => $str,      # debug, info (default), warn, error
  limit  => $int,      # max number of messages to retrieve
  match  => $regexp,   # filter messages by a regexp
}

$res will contain:

{
  end      => true,
  messages => [...],
}

new

Will also call _setup() after the object is created.

notifications_p

$p = $backend->notifications_p($user, \%query)->then(sub { my $res = shift; });

This method will return notifications, in the same structure as "messages".

save_object_p

$backend->save_object_p($obj)->then(sub { my $obj = shift });

This method is called to save a given object to persistent storage.

users_p

$backend = $backend->users_p->then(sub { my $users = shift });

Used to find a list of user emails.

SEE ALSO

Convos::Core