Off The Moose Track

存储架构 2018-01-01

Well off track again. So I am not going to do my bit on coercion today after all. If anyone out there was actually downloading my code and running my tests you might see this;

Load of Database/Accessor/DAD/ failed:

Error=Can't locate Database/Accessor/DAD/ in @INC (@INC contains: D:GitHubDA-bloglib D:GitHubReplaylib C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .) at (eval 378) line 2.

Database/Accessor/DAD/Types (Database::Accessor::DAD::Types) may not be an Database Accessor Driver (DAD)!

Scrolling by as the test all pass. Now this is does not bother me much as all I see here is my BUILDER code rejecting the load of a non DAD class. To other this may mean that something is going wrong and I am sure, if this project every becomes successful, that I will get all sorts of questions on what is going on here. So it is always better to nip these sort of problems in the bud.

On closer inspection of the above you may notice that it is trying to load the file '/Database/Accessor/DAD/' which is odd as there is no file of that name in that folder. The '' file is in the '/Database/Accessor/' folder.

So things are not going right in my system at all. At first I though it was this regex

 my ($package) = $_package =~ /^([[:word:]]+(?:::[[:word:]]+)*)$/;

So I got out my old standby buddy The Regex Coach
and I tested the expression and it came out all right so it wasn't that one. So onto the the next one then;

$dir =~ s/^.+Database/Accessor///;

and a quick warn on the next line showed me


Then that little light clicked on in my brain and I remembered that I am on a windows box so my '/' part in my regex is not going to work as it would on a Linux box where I had orginally used this code, there it would be


I have a few options none of them very elegant, there is most likely a regex out there that will work for both Windows and Linux but I have yet to find one and my regex skills are mediocre at best So I think I will do the brute force approach and just swap out the '' for '/'. In the end this small change will make my Accessor more portable across OSes and I do not think I will have any problems as Windows doesn't care really between the two, 'dir /foo/bar' and 'dir barfor' and on Linux nothing will change.

Oh by the way I also noticed that I was missing the DAD part on the end of that regex, if you remember in my name-spacestatement from a few posts ago I want all DADs under that name-space , so in the end this is what I came up with;

    $dir =~ s/\///gi;

    $dir =~ s/^.+Database/Accessor/DAD///;


which gives me


and that is what I want. The code that follows is designed to find DADs that are deeper in the name-space than the DAD level. So a path like this '/GitHub/DA-blog/lib/Database/Accessor/DAD/NoSQL/Dimingo,pm would give me the correct class name later on.

Now I also noticed that in my BUILD I also forgot to put the 'DAD' in there so with that change

--grep { -d $_ } map { File::Spec->catdir($_, 'Database','Accessor','DAD' ) } @INC;

++grep { -d $_ } map { File::Spec->catdir($_, 'Database','Accessor' ) } @INC;

and this other typo I missed.

--$classname = join '::', 'DA_SC', 'LSD', $package, $file;

++$classname = join '::', 'Database', 'Accessor', 'DAD', $package, $file; 

I reran my tests no more waring about loading a file that does not exists.

Well at least that is some progress.

责编内容 (源链)。感谢您的支持!


Citus 7.2: CTEs, complex subqueries, set operation... Today, we’re excited to announce our latest release of our distributed database—Citus 7.2. With thi...
最坏的不是面试被拒,而是没面试机会,以面试官视角分析哪些简历至少能有面试机会... 本人在之前的博客里写了很多面试技巧,这是有个前提:至少候选人被面试了,在这个前提下,候选人哪怕失败了,至少也能用实战来检验和校对面试准备的结果,用句比较时髦的话来说就是试错,多试几次之后总能找到...
Using celeryd as a daemon with several django appl... I'm just starting using django-celery and I'd like to set celeryd running as a daemon. The in...
An Object-Oriented Way of Working with Models and ... When we talk about the concept of Models in object-oriented programming, we’re usually referring ...
DDD, Hexagonal, Onion, Clean, CQRS, … How I put it... This post is part of The Software Architecture Chronicles , a series of posts about Software Arc...