File: Worker.pm

package info (click to toggle)
munin 2.0.76-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,064 kB
  • sloc: perl: 11,684; java: 1,924; sh: 1,632; makefile: 636; javascript: 365; python: 267
file content (69 lines) | stat: -rw-r--r-- 986 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package Munin::Master::Worker;

use warnings;
use strict;

use Scalar::Util qw(refaddr);


use overload q{""} => 'to_string';


sub new {
    my ($class, $identity) = @_;

    my $self = bless {}, $class;

    $identity = refaddr($self) unless defined $identity;
    $self->{ID} = $identity;

    return $self;
}


sub to_string {
    my ($self) = @_;

    return sprintf("%s<%s>", ref $self, $self->{ID});
}


1;


__END__

=head1 NAME

Munin::Master::Worker - Abstract base class for workers.

=head1 SYNOPSIS

See L<Munin::Master::ProcessManager>.

=head1 METHODS

=over

=item B<new>

  Munin::Master::Worker->new($identity);

Constructor.  This is an abstract class, so this shouldn't be called directly.

The optional $identity argument should be a unique identifier for the process.

=item B<to_string>

  print $worker->string;

  # Stringifies too
  print "Worker $worker just died";

Returns a unique string representation of the worker.

=back

=cut

# vim: ts=4 : sw=4 : et