Git Product home page Git Product logo

kiokudb's Introduction

RESOURCES

DESCRIPTION

KiokuDB is a Moose based frontend to various data stores:

Its purpose is to provide persistence for "regular" Perl objects with as little effort as possible, without sacrificing control over how persistence is actually done, especially for harder to serialize objects.

KiokuDB is also non-invasive: it does not use ties, AUTOLOAD, overloading, proxy objects or any other type of trickery.

KiokuDB is meant to solve two related persistence problems:

Transparent persistence

Store arbitrary objects without changing their class definitions or worrying about schema details, and without needing to conform to the limitations of a relational model.

Interoperability

Persisting arbitrary objects in a way that is compatible with existing data/code (for example interoprating with another app using CouchDB with JSPON semantics).

kiokudb's People

Contributors

abh avatar autarch avatar brunov avatar chromatic avatar dgl avatar domm avatar doy avatar dylanwh avatar fcuny avatar gbarr avatar jasonmay avatar ktat avatar melo avatar nothingmuch avatar omega avatar perigrin avatar rafl avatar sartak avatar shlomif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

kiokudb's Issues

filters dropping weak references

When using a filter on a stream coming from kioku, any weak references that the scope is holding on to for me appear to disappear. I have included a test script that demonstrates the problem that I have run into. When running the script as is I get the error "Can't call method "host" on an undefined value at ... line 57". If I remove the filter line the scope holds onto this reference as i would expect.

#!/usr/bin/perl

use lib qw(/home/rt/lib);
use local::lib;

use KiokuDB;

{
 package Host;

 use KiokuDB::Class;

 use KiokuDB::Util qw(set);

 has name => ( is => 'rw', isa => 'Str' );

 has services => (is => 'rw', default => sub {set()}, does => 'KiokuDB::Set');

 package Service;

 use KiokuDB::Class;

 use KiokuDB::Util qw(set);

 has host => (
              is => 'rw',
              isa => 'Host',
              weak_ref => 1
             );

 has name => ( is => 'rw', isa => 'Str' );

 has issues => ( is => 'rw', default => sub {set()}, does => 'KiokuDB::Set');

 package Issue;

 use KiokuDB::Class;

 use KiokuDB::Util qw(set);

 has subject => (
                 isa => 'Str',
                 is  => 'ro',
                 required => 1,
                );

 has status => (
                is => 'ro',
                isa => 'Str',
                default => sub { 'open' },
                required => 1,
               );

 sub belongs_to_host {
     my ($self, $name) = @_;

     if ($self->subject->host->name() eq $name) {
         return 1;
     }
     else {
         return 0;
     }
 }

 package Issue::Service;

 use KiokuDB::Class;

 extends 'Issue';

 has +subject => (
                 isa => 'Service',
                 required => 1,
                 weak_ref => 1,
                 is => 'ro',
                );

}

my $dir = KiokuDB->connect(
                           "dbi:SQLite:dbname=:memory:",
                           create => 1,
                          );

{
my $scope = $dir->new_scope();

my $host = Host->new(name => 'some host');

my $service = Service->new(name => 'some service', host => $host);

my $issue = Issue::Service->new(subject => $service);

$service->issues->insert($issue);

$host->services->insert($service);

$dir->store($host);


$scope = undef;
$host = undef;
$service = undef;
$issue = undef;
}

my $new_scope = $dir->new_scope();

my $issue_stream = $dir->search({class => 'Issue::Service'});
$issue_stream = $issue_stream->filter(sub { return [ grep { $_->status() eq 'open' } @$_ ]; });

my @issues = $issue_stream->all();

for my $issue (@issues) {
    my $issue_id = $dir->object_to_id($issue);

    print "found issue issue: $issue_id\n";

    #print "issue is for service: " . $issue->service->name() . "\n";
    #print "issue is for host: " . $issue->service->host->name() . "\n";

    print "belongs to host some host: " . $issue->belongs_to_host('some host') . "\n";
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.