DConf 2013 Day 2 Talk 4: Web Development in D by Vladimir Panteleev

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Mon Jun 3 15:37:25 PDT 2013


On Mon, 3 Jun 2013 18:11:37 -0400
Nick Sabalausky <SeeWebsiteToContactMe at semitwist.com> wrote:

> Referring to the last question: Hibernate-D is *not* based on Vibe.d.
> But I have already been looking into the idea of using Hibernate-D and
> Vibe.d together. In fact, my recent commits to mysql-native adding
> support for Phobos sockets was a big part of that.
> 
> The main issue is that Vibe.d programs should be using Vibe.d
> sockets instead of ordinary sockets (I don't know what would happen if
> you don't use Vibe.d sockets. My guess is it just wouldn't happen
> asynchronously, but Sonke could answer that better). But Hibernate-D
> aims to be usable even without Vibe.d, so it uses Phobos sockets for
> MySQL (via a modified fork of an older mysql-native), and for
> PostgreSQL and SQLite it just uses the C libs.
> 
> I've already converted mysql-native to support both Vibe.d and Phobos
> sockets, and I've already created a branch of Hibernate-D that makes
> Hibernate-D use the new official mysql-native and therefore
> automatically switch to Vibe.d sockets whenever Vibe.d is being used
> (detected by -version=Have_vibe_d, which is automatically added by DUB
> is you're using both Vibe.d and DUB). But G^DF*^@CKD*#MMIT I *just
> now* noticed that commit (and the pull request I could have sworn I
> made) seems to have completely disappeared without a trace...Shit, I
> gotta figure out what happened and where the hell it went...
> 
> Ugh, anyway, I've been digging through Hibernate-D's source the last
> couple days checking out what else might be needed. As long as I get
> my magical disappearing commit resurrected, it *looks* to me like the
> only other thing that might be needed is to bypass Hibernate-D's
> built-in connection pool. Even that might still work as-is (I haven't
> tried), but it's not really necessary for Vibe.d users since Vibe.d
> has its own fiber-safe connection pool system. But it's pretty easy to
> bypass Hibernate-D's connection pool in favor of Vibe.D's
> connection pool in user-code without even patching Hibernate-D.
> 
> AFAICT so far, it looks like everything else in Hibernate-D should
> work fine with Vibe.d.
> 
> tl;dr:
> 
> Hibernate-D does not use Vibe.d, but I have personal interest
> in using them together and I've been checking into it. Not sure what
> can be done about PostgreSQL and SQLite (I *think* they'll work but
> just not asynchronously - not sure what else can/should be done, I'd
> have to ask Sonke). But for MySQL, all you *should* need is a patch or
> two that I've been working on.
> 

Oh wait, I totally forgot:

DDBC was moved out of HibernateD into a separate project, and *that's*
where the "missing" commit was. I was looking for it in the wrong
project.

Anyway, here are my branches:

https://github.com/Abscissa/hibernated/commits/misc
https://github.com/Abscissa/ddbc/commits/misc

And here's the DDBC pull request to make DDBC (the low-level DB
abstraction lib used by Hibernate-D) use the official "Vibe.d- and
Phobos-compatible" mysql-native:

https://github.com/buggins/ddbc/pull/1

So all you *should* need (for MySQL anyway) is that pull request (or my
full "misc" branches above), and then bypass Hibernate-D's
connection pool in favor of Vibe.d's by changing this part of your code
from:

SessionFactory factory = new SessionFactoryImpl(mySchema, myDialect,
myDataSource);

to something like:

class MyDataSource : DataSource {
    static mysql.db.MysqlDB vibePool;
    override Connection getConnection() {
        if(!vibePool)
            vibePool = new mysql.db.MysqlDB(/+ connection info +/);

        return vibePool.lockConnection();
    }
}

SessionFactory factory = new SessionFactoryImpl(mySchema, myDialect,
new MyDataSource());




More information about the Digitalmars-d-announce mailing list