| 1 | package RWDE::Mapper; | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use RWDE::Gearman::Client; | ||
| 7 | |||
| 8 | use vars qw($AUTOLOAD); | ||
| 9 | use vars qw($VERSION); | ||
| 10 | $VERSION = sprintf "%d", q$Revision: 536 $ =~ /(\d+)/; | ||
| 11 | |||
| 12 | =pod | ||
| 13 | |||
| 14 | =head1 RWDE::Mapper | ||
| 15 | |||
| 16 | Object to handle mapping of RPC namespaces. The mapping object translates the call from | ||
| 17 | the local, imported class to the remote namespace. | ||
| 18 | |||
| 19 | This class is present in order to avoid namespace conflicts while building RPC interfaces, | ||
| 20 | which in our case is Gearman. Specifically it is very easy to cause namespace collisions under | ||
| 21 | these circumstances, so some care is needed while implementing these types of calls. | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | =head2 AUTOLOAD | ||
| 26 | |||
| 27 | Object to handle mapping of namespaces. The mapping object translates the call from | ||
| 28 | the local, imported class to the remote namespace. | ||
| 29 | |||
| 30 | The calling convention is $local::$remote -> $remote::$remote | ||
| 31 | |||
| 32 | =cut | ||
| 33 | |||
| 34 | sub AUTOLOAD { | ||
| 35 | my ($self, $params) = @_; | ||
| 36 | |||
| 37 | $AUTOLOAD =~ m/.*::(.*)::(.*)/; | ||
| 38 | |||
| 39 | my $namespace=$1; | ||
| 40 | my $method=$2; | ||
| 41 | |||
| 42 | $$params{method} = $1 .'::' . $1 .'::'.$method; | ||
| 43 | |||
| 44 | return RWDE::Gearman::Client->Do_task($params); | ||
| 45 | } | ||
| 46 | |||
| 47 | =head2 DESTROY() | ||
| 48 | |||
| 49 | Do nothing. This is here to avoid sending the DESTROY request over RPC | ||
| 50 | |||
| 51 | =cut | ||
| 52 | |||
| 53 | sub DESTROY { | ||
| 54 | |||
| 55 | } | ||
| 56 | |||
| 57 | 1; |