Fluent-LibFluentBit

 view release on metacpan or  search on metacpan

lib/Fluent/LibFluentBit.pm  view on Meta::CPAN

   defined $_ && $_->{started} && $_->stop
      for values %instances;
   %instances= ();
}

# constructor registers the instance
sub new {
   my $class= shift;
   my $self= Fluent::LibFluentBit::flb_create();
   bless $self, $class if $class ne 'Fluent::LibFluentBit';
   Scalar::Util::weaken( $instances{0+$self}= $self );
   $self->configure((@_ == 1 && ref $_[0] eq 'HASH')? %{$_[0]} : @_);
}

# destructor flushes cached messages and unregisters the instance
sub DESTROY {
   my $self= shift;
   delete $instances{0+$self};
   $self->stop;
   # XS calls flb_destroy when the hash goes out of scope
}

lib/Fluent/LibFluentBit/Component.pm  view on Meta::CPAN

sub name    { $_[0]{name} }

sub new {
   my $class= shift;
   my %attrs= @_ == 1 && ref $_[0] eq 'HASH'? %{$_[0]} : @_;
   my $context= delete $attrs{context};
   ref $context or croak "Attribute 'context' is required and must be a LibFluentBit instance";
   my $name= delete $attrs{name};
   defined $name && length $name or croak "Attribute 'name' is required";
   my $self= bless { context => $context, name => $name }, $class;
   Scalar::Util::weaken($self->{context});
   $self->{id}= defined $attrs{id}? delete $attrs{id} : $self->_build_id($name);
   $self->configure(%attrs);
}

sub configure {
   my $self= shift;
   my %conf= @_ == 1 && ref $_[0] eq 'HASH'? %{$_[0]} : @_;

   for (keys %conf) {
      if ($self->_set_attr($_, $conf{$_}) >= 0) {



( run in 0.246 second using v1.01-cache-2.11-cpan-1f129e94a17 )