NetSDS::Feature(3pm)

πŸ“¦
version 1.301 Β· 2 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute

πŸ’– NetSDS::Feature πŸ’–

okay bestie, gather round, because we're talking about NetSDS::Feature β€” the abstract application feature from the User Contributed Perl Documentation corner of the world. it's giving blueprint energy, it's giving parent class realness, and honestly? iconic. πŸŽ€


✨ NAME ✨

NetSDS::Feature β€” abstract application feature. yeah. that's the whole vibe. it's the superclass, the main character that all the other features inherit from. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

so here's how you actually use it, no cap:

package NetSDS::Feature::DBI;

use DBI;
use base 'NetSDS::Feature';

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

    my $dsn = $self->conf->{dsn};
    my $user = $self->conf->{user};
    my $passwd = $self->conf->{passwd};

    $self->{dbconn} = DBI->connect($dsn, $user, $passwd);

}

# Sample method - DBI::do proxy
sub do {

    my $self = shift @_;
    return $self->{dbconn}->do(@_);
}

1;

look at that. a whole feature, subclassed and ready. the use base 'NetSDS::Feature' line is the moment it all comes together, fr fr. 🌸


🌈 DESCRIPTION 🌈

Application "features" are Perl5 packages with a unified API, and the whole point is to make it easy to integrate some functionality into NetSDS applications infrastructure. lowkey genius. 🧚

The NetSDS::Feature module contains the superclass for application features, and it provides the following common feature functionality:

  • class construction
  • initialization stub
  • logging

that's the starter pack. the essentials. the bare minimum that every feature gets handed for free. πŸ‘‘


⭐ CLASS METHODS ⭐

create($app, $conf) β€” feature constructor

yep, it creates the feature. that's the whole job. 🫢

init() β€” feature initialization

bestie, listen: this method should be rewritten with feature functionality implementation.

like, this is the stub. it's the empty plate waiting for you to cook. and the tea is: it's possibly to use application and configuration handlers at this time. ✨

Example:

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

    $self->{answer} = $self->conf->{answer} || '42';

    my $pid = $self->app->pid();

    if ($self->app->daemon()) {
        $self->log("info", "Seems we are in a daemon mode");
    }
}

see how it's pulling from $self->conf, grabbing the app's pid(), checking daemon()? that's the flow. that's the whole flow. 😭


πŸ’œ OBJECT METHODS πŸ’œ

app() β€” application object

This method allows to use application methods and properties.

print "Feature included from app: " . $self->app->name;

yes bestie, you get to reach into the app and grab its stuff. the app is literally right there. 🀝

conf() β€” feature configuration

This method provides access to feature configuration. your config, your rules. πŸ’–

log($level, $message) β€” implements logging

Example:

# Write log message
$self->log("info", "Application does something interesting.");

See NetSDS::Logger documentation for details. (yes, go read that one too, it's important. iykyk. πŸŽ€)


🌸 EXAMPLES 🌸

See "samples/app_features.pl" script. that's where the real demo lives, go peek at it. πŸ‘€


πŸ”₯ SEE ALSO πŸ”₯

  • NetSDS::App

πŸ‘‘ AUTHOR πŸ‘‘

Michael Bochkaryov <misha@rattler.kiev.ua>

the legend himself. πŸ™Œ


πŸ’€ LICENSE πŸ’€

Copyright (C) 2008-2009 Net Style Ltd.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

⚠️ ok so real talk, that warranty disclaimer is not a joke β€” no warranty, periodt. the license said it, not me. πŸ’…

and that's the whole page, bestie! this lil' gem came to you as perl v5.32.1, dated 2021-12-26, sitting pretty under the NetSDS::Feature(3pm) name in the User Contributed Perl Documentation. now go build a feature, you absolute icon. πŸ¦‹πŸ’–βœ¨