The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
DJabberd::Cluster
     void    ->send_message($barejid, $cluster_message)
              - most important
              (has a default implementation that connects directly to everybody found in star topology)

  (abstract) @locations = ->find_barejid_locations($barejid)
                  void    ->send_message($barejid, $cluster_message)
                     (has a default implementation that connects directly, star topology)

   DJabberd::Cluster::Naive
           find_barejid_locations doing polling the star
           or just send the message to all peers!

   DJabberd::Cluster::LiveJournal
         - override find_barejid_locations w/ database lookup (in subprocess/gearman)
         - keep default start topology delivery

   DJabberd::Cluster::Spread
         - probably only does send_message, with $barejid being the message group


DJabberd::ClusterMessage  (IQ-style tagged message/response)
  -- must serialize itself to/from storable and Cluster's transport can choose to encode atop that.

  DJabberd::ClusterMessage::RosterPush       response = OK
  DJabberd::ClusterMessage::BareJIDLookup    response = @locations
  DJabberd::ClusterMessage::StanzaDelivery   response = OK


CREATE TABLE jidmap (
    barejid   VARCHAR,
    resource  VARCHAR,
    PRIMARY KEY (barejid, resource),
    server    VARCHAR
);

# when logging off,
delete from jidmap where bare=..., res=..., and server=....;  (delete all 3 fields)

# when logging on,
REPLACE INTO jidmap (..., ..., ...)  (insert all three, blowing away)