Connecting to a database

#1

Hello,

So I’m trying to figure out how to access a database with multiple clients without opening multiple connections to the database. Allow me to explain: I want multiple application sessions to have access to information in a database but I don’t want the connection to the database to be instantiated every single time a client connects to the router. I want the router to have direct access to the database and allow the clients to work through the router to retrieve the information. In WAMP 1 we did this by calling self.factory and having the database connection defined as part of the factory. How do I do this in WAMP2? Would I set up the connection in the ApplicationSessionFactory or the WampWebSocketClientFactory? How would I access the link? self.factory or self.session? Please ask any questions you may need to get a better grasp on what I’m asking.

Thanks,
Jess

0 Likes

#2

Hi Jess,

Hello,

So I'm trying to figure out how to access a database with multiple
clients without opening multiple connections to the database. Allow me
to explain: I want multiple application sessions to have access to
information in a database but I don't want the connection to the
database to be instantiated every single time a client connects to the
router. I want the router to have direct access to the database and
allow the clients to work through the router to retrieve the
information. In WAMP 1 we did this by calling self.factory and having
the database connection defined as part of the factory. How do I do this
in WAMP2? Would I set up the connection in the ApplicationSessionFactory
or the WampWebSocketClientFactory? How would I access the link?
self.factory or self.session? Please ask any questions you may need to
get a better grasp on what I'm asking.

I have added a complete example here:

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame

To try yourself, please update AutobahnPython to current trunk (I have added a comfort facility I explain in a second):

git clone git@github.com:tavendo/AutobahnPython.git
cd AutobahnPython/autobahn
python setup.py install

Follow https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it ..

···

Am 04.04.2014 22:27, schrieb Jess Updegrove:

==

Now, regarding the code, this will create a single application session instance of

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35

This class contains the backend of the app.

The app uses SQLite as database, put you could easily modify this to work for PostgeSQL. It's based on

https://twistedmatrix.com/documents/current/core/howto/rdbms.html

which is generally the way to access databases directly from Twisted. This stuff runs queries on a background thread pool (which is often necessary, since database drivers are blocking .. and Twisted does not like being blocked).

==

Further, this example is packaged up as a "WAMPlet" .. pls read here

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1

The reason to introduce "WAMPlets" is to make it dead easy to develop those components running them "standalone" (against a WAMP router), and later be able to let e.g. Crossbar host the component. Without any code change of course.

The introduction of the make() factory function also allows you wire up your ApplicationSession instances as you like .. e.g. put a reference to a global singleton on them or such.

==

Please checkout the example and let me know what questions remain for you ..

==

Lastly, above shows _direct_ database access from WAMP app components.

Crossbar.io will soon (have again) the ability to call database stored procedures directly. That means, in above example, the "vote()" RPC endpoint could be implemented directly as a database stored procedure .. running inside the DB. This will work for DBs with stored proc. languages like PostgreSQL .. it won't work for SQLite .. which is why the example will remain useful.

Here is how this will look like:

https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21

[this example was for the predessor of Crossbar.io, and is for Oracle. It'll essentially look the same once that feature is again in Crossbar.io. For PostgreSQL, you will be able to write the stored proc. in any stored proc. language supported .. e.g. also JavaScript].

Realistically, it'll be another couple of weeks until we are there .. oh mei. So much still to do ..

Thanks,
Jess

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#3

I got your example to run and it looks good. Will this work with a Riak database also?

Jess

···

On Saturday, April 5, 2014 12:36:02 PM UTC-4, Tobias Oberstein wrote:

Hi Jess,

Am 04.04.2014 22:27, schrieb Jess Updegrove:

Hello,

So I’m trying to figure out how to access a database with multiple

clients without opening multiple connections to the database. Allow me

to explain: I want multiple application sessions to have access to

information in a database but I don’t want the connection to the

database to be instantiated every single time a client connects to the

router. I want the router to have direct access to the database and

allow the clients to work through the router to retrieve the

information. In WAMP 1 we did this by calling self.factory and having

the database connection defined as part of the factory. How do I do this

in WAMP2? Would I set up the connection in the ApplicationSessionFactory

or the WampWebSocketClientFactory? How would I access the link?

self.factory or self.session? Please ask any questions you may need to

get a better grasp on what I’m asking.

I have added a complete example here:

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame

To try yourself, please update AutobahnPython to current trunk (I have
added a comfort facility I explain in a second):

git clone git@github.com:tavendo/AutobahnPython.git

cd AutobahnPython/autobahn

python setup.py install

Follow
https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it

==

Now, regarding the code, this will create a single application session
instance of

https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35

This class contains the backend of the app.

The app uses SQLite as database, put you could easily modify this to
work for PostgeSQL. It’s based on

https://twistedmatrix.com/documents/current/core/howto/rdbms.html

which is generally the way to access databases directly from Twisted.
This stuff runs queries on a background thread pool (which is often
necessary, since database drivers are blocking … and Twisted does not
like being blocked).

==

Further, this example is packaged up as a “WAMPlet” … pls read here

https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1

The reason to introduce “WAMPlets” is to make it dead easy to develop
those components running them “standalone” (against a WAMP router), and
later be able to let e.g. Crossbar host the component. Without any code
change of course.

The introduction of the make() factory function also allows you wire up
your ApplicationSession instances as you like … e.g. put a reference to
a global singleton on them or such.

==

Please checkout the example and let me know what questions remain for you …

==

Lastly, above shows direct database access from WAMP app components.

Crossbar.io will soon (have again) the ability to call database stored
procedures directly. That means, in above example, the “vote()” RPC
endpoint could be implemented directly as a database stored procedure …
running inside the DB. This will work for DBs with stored proc.
languages like PostgreSQL … it won’t work for SQLite … which is why
the example will remain useful.

Here is how this will look like:

https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21

[this example was for the predessor of Crossbar.io, and is for Oracle.
It’ll essentially look the same once that feature is again in
Crossbar.io. For PostgreSQL, you will be able to write the stored proc.
in any stored proc. language supported … e.g. also JavaScript].

Realistically, it’ll be another couple of weeks until we are there … oh
mei. So much still to do …

Thanks,

Jess

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+...@googlegroups.com

mailto:autobahnws+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#4

I got your example to run and it looks good. Will this work with a Riak
database also?

Twisted adbapi is for database drivers that follow the Python DBI standard (PEP 249). That is relational databases. So it's not for Riak. I would look out for an asynchronous Riak driver, probably

https://github.com/calston/riakasaurus

Btw: PostgreSQL can work as a plain Key-Value store too.

···

Am 07.04.2014 23:46, schrieb Jess Updegrove:

Jess

On Saturday, April 5, 2014 12:36:02 PM UTC-4, Tobias Oberstein wrote:

    Hi Jess,

    Am 04.04.2014 22:27, schrieb Jess Updegrove:
     > Hello,
     >
     > So I'm trying to figure out how to access a database with multiple
     > clients without opening multiple connections to the database.
    Allow me
     > to explain: I want multiple application sessions to have access to
     > information in a database but I don't want the connection to the
     > database to be instantiated every single time a client connects
    to the
     > router. I want the router to have direct access to the database and
     > allow the clients to work through the router to retrieve the
     > information. In WAMP 1 we did this by calling self.factory and
    having
     > the database connection defined as part of the factory. How do I
    do this
     > in WAMP2? Would I set up the connection in the
    ApplicationSessionFactory
     > or the WampWebSocketClientFactory? How would I access the link?
     > self.factory or self.session? Please ask any questions you may
    need to
     > get a better grasp on what I'm asking.

    I have added a complete example here:

    https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame>

    To try yourself, please update AutobahnPython to current trunk (I have
    added a comfort facility I explain in a second):

    git clone git@github.com:tavendo/AutobahnPython.git
    cd AutobahnPython/autobahn
    python setup.py install

    Follow
    https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it>

    ..

    ==

    Now, regarding the code, this will create a single application session
    instance of

    https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35
    <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35>

    This class contains the backend of the app.

    The app uses SQLite as database, put you could easily modify this to
    work for PostgeSQL. It's based on

    https://twistedmatrix.com/documents/current/core/howto/rdbms.html
    <https://twistedmatrix.com/documents/current/core/howto/rdbms.html>

    which is generally the way to access databases directly from Twisted.
    This stuff runs queries on a background thread pool (which is often
    necessary, since database drivers are blocking .. and Twisted does not
    like being blocked).

    ==

    Further, this example is packaged up as a "WAMPlet" .. pls read here

    https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1>

    The reason to introduce "WAMPlets" is to make it dead easy to develop
    those components running them "standalone" (against a WAMP router), and
    later be able to let e.g. Crossbar host the component. Without any code
    change of course.

    The introduction of the make() factory function also allows you wire up
    your ApplicationSession instances as you like .. e.g. put a
    reference to
    a global singleton on them or such.

    ==

    Please checkout the example and let me know what questions remain
    for you ..

    ==

    Lastly, above shows _direct_ database access from WAMP app components.

    Crossbar.io will soon (have again) the ability to call database stored
    procedures directly. That means, in above example, the "vote()" RPC
    endpoint could be implemented directly as a database stored
    procedure ..
    running inside the DB. This will work for DBs with stored proc.
    languages like PostgreSQL .. it won't work for SQLite .. which is why
    the example will remain useful.

    Here is how this will look like:

    https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21
    <https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21>

    [this example was for the predessor of Crossbar.io, and is for Oracle.
    It'll essentially look the same once that feature is again in
    Crossbar.io. For PostgreSQL, you will be able to write the stored proc.
    in any stored proc. language supported .. e.g. also JavaScript].

    Realistically, it'll be another couple of weeks until we are there
    .. oh
    mei. So much still to do ..

     >
     > Thanks,
     > Jess
     >
     > --
     > You received this message because you are subscribed to the Google
     > Groups "Autobahn" group.
     > To unsubscribe from this group and stop receiving emails from it,
    send
     > an email to autobah...@googlegroups.com <javascript:>
     > <mailto:autobahnws+...@googlegroups.com <javascript:>>.
     > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#5

Looks good, thank you!

···

On Tuesday, April 8, 2014 5:21:46 AM UTC-4, Tobias Oberstein wrote:

Am 07.04.2014 23:46, schrieb Jess Updegrove:

I got your example to run and it looks good. Will this work with a Riak

database also?

Twisted adbapi is for database drivers that follow the Python DBI
standard (PEP 249). That is relational databases. So it’s not for Riak.
I would look out for an asynchronous Riak driver, probably

https://github.com/calston/riakasaurus

Btw: PostgreSQL can work as a plain Key-Value store too.

Jess

On Saturday, April 5, 2014 12:36:02 PM UTC-4, Tobias Oberstein wrote:

Hi Jess,
Am 04.04.2014 22:27, schrieb Jess Updegrove:
 > Hello,
 >
 > So I'm trying to figure out how to access a database with multiple
 > clients without opening multiple connections to the database.
Allow me
 > to explain: I want multiple application sessions to have access to
 > information in a database but I don't want the connection to the
 > database to be instantiated every single time a client connects
to the
 > router. I want the router to have direct access to the database and
 > allow the clients to work through the router to retrieve the
 > information. In WAMP 1 we did this by calling self.factory and
having
 > the database connection defined as part of the factory. How do I
do this
 > in WAMP2? Would I set up the connection in the
ApplicationSessionFactory
 > or the WampWebSocketClientFactory? How would I access the link?
 > self.factory or self.session? Please ask any questions you may
need to
 > get a better grasp on what I'm asking.
I have added a complete example here:
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)>
To try yourself, please update AutobahnPython to current trunk (I have
added a comfort facility I explain in a second):
git clone git@github.com:tavendo/AutobahnPython.git
cd AutobahnPython/autobahn
python setup.py install
Follow
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)>
..
==
Now, regarding the code, this will create a single application session
instance of
[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)
<[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)>
This class contains the backend of the app.
The app uses SQLite as database, put you could easily modify this to
work for PostgeSQL. It's based on
[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)
<[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)>
which is generally the way to access databases directly from Twisted.
This stuff runs queries on a background thread pool (which is often
necessary, since database drivers are blocking .. and Twisted does not
like being blocked).
==
Further, this example is packaged up as a "WAMPlet" .. pls read here
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)>
The reason to introduce "WAMPlets" is to make it dead easy to develop
those components running them "standalone" (against a WAMP router), and
later be able to let e.g. Crossbar host the component. Without any code
change of course.
The introduction of the make() factory function also allows you wire up
your ApplicationSession instances as you like .. e.g. put a
reference to
a global singleton on them or such.
==
Please checkout the example and let me know what questions remain
for you ..
==
Lastly, above shows _direct_ database access from WAMP app components.
Crossbar.io will soon (have again) the ability to call database stored
procedures directly. That means, in above example, the "vote()" RPC
endpoint could be implemented directly as a database stored
procedure ..
running inside the DB. This will work for DBs with stored proc.
languages like PostgreSQL .. it won't work for SQLite .. which is why
the example will remain useful.
Here is how this will look like:
[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)
<[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)>
[this example was for the predessor of Crossbar.io, and is for Oracle.
It'll essentially look the same once that feature is again in
Crossbar.io. For PostgreSQL, you will be able to write the stored proc.
in any stored proc. language supported .. e.g. also JavaScript].
Realistically, it'll be another couple of weeks until we are there
.. oh
mei. So much still to do ..
 >
 > Thanks,
 > Jess
 >
 > --
 > You received this message because you are subscribed to the Google
 > Groups "Autobahn" group.
 > To unsubscribe from this group and stop receiving emails from it,
send
 > an email to autobahnws+...@googlegroups.com <javascript:>
 > <mailto:autobahnws+unsub...@googlegroups.com <javascript:>>.
 > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout)
<[https://groups.google.com/d/optout](https://groups.google.com/d/optout)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+...@googlegroups.com

mailto:autobahnws+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#6

So just a few questions.

  1. In this example, does ApplicationRunner replace the Client factory we normally use for connecting clients?

  2. Is there any documentation somewhere for ApplicationRunner that I can take a look at?

  3. Does this connect only the router to the database (since it seems to me like it connects an embedded client with access to the database to the router)?

  4. If I want another client to have access to the database, would I have them call a function in this client (meaning only this embedded client has access and anyone that wants to put or get values into the database must ask this client to do it for them)?

Thanks,
Jess

···

On Tuesday, April 8, 2014 5:21:46 AM UTC-4, Tobias Oberstein wrote:

Am 07.04.2014 23:46, schrieb Jess Updegrove:

I got your example to run and it looks good. Will this work with a Riak

database also?

Twisted adbapi is for database drivers that follow the Python DBI
standard (PEP 249). That is relational databases. So it’s not for Riak.
I would look out for an asynchronous Riak driver, probably

https://github.com/calston/riakasaurus

Btw: PostgreSQL can work as a plain Key-Value store too.

Jess

On Saturday, April 5, 2014 12:36:02 PM UTC-4, Tobias Oberstein wrote:

Hi Jess,
Am 04.04.2014 22:27, schrieb Jess Updegrove:
 > Hello,
 >
 > So I'm trying to figure out how to access a database with multiple
 > clients without opening multiple connections to the database.
Allow me
 > to explain: I want multiple application sessions to have access to
 > information in a database but I don't want the connection to the
 > database to be instantiated every single time a client connects
to the
 > router. I want the router to have direct access to the database and
 > allow the clients to work through the router to retrieve the
 > information. In WAMP 1 we did this by calling self.factory and
having
 > the database connection defined as part of the factory. How do I
do this
 > in WAMP2? Would I set up the connection in the
ApplicationSessionFactory
 > or the WampWebSocketClientFactory? How would I access the link?
 > self.factory or self.session? Please ask any questions you may
need to
 > get a better grasp on what I'm asking.
I have added a complete example here:
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)>
To try yourself, please update AutobahnPython to current trunk (I have
added a comfort facility I explain in a second):
git clone git@github.com:tavendo/AutobahnPython.git
cd AutobahnPython/autobahn
python setup.py install
Follow
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)>
..
==
Now, regarding the code, this will create a single application session
instance of
[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)
<[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)>
This class contains the backend of the app.
The app uses SQLite as database, put you could easily modify this to
work for PostgeSQL. It's based on
[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)
<[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)>
which is generally the way to access databases directly from Twisted.
This stuff runs queries on a background thread pool (which is often
necessary, since database drivers are blocking .. and Twisted does not
like being blocked).
==
Further, this example is packaged up as a "WAMPlet" .. pls read here
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)>
The reason to introduce "WAMPlets" is to make it dead easy to develop
those components running them "standalone" (against a WAMP router), and
later be able to let e.g. Crossbar host the component. Without any code
change of course.
The introduction of the make() factory function also allows you wire up
your ApplicationSession instances as you like .. e.g. put a
reference to
a global singleton on them or such.
==
Please checkout the example and let me know what questions remain
for you ..
==
Lastly, above shows _direct_ database access from WAMP app components.
Crossbar.io will soon (have again) the ability to call database stored
procedures directly. That means, in above example, the "vote()" RPC
endpoint could be implemented directly as a database stored
procedure ..
running inside the DB. This will work for DBs with stored proc.
languages like PostgreSQL .. it won't work for SQLite .. which is why
the example will remain useful.
Here is how this will look like:
[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)
<[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)>
[this example was for the predessor of Crossbar.io, and is for Oracle.
It'll essentially look the same once that feature is again in
Crossbar.io. For PostgreSQL, you will be able to write the stored proc.
in any stored proc. language supported .. e.g. also JavaScript].
Realistically, it'll be another couple of weeks until we are there
.. oh
mei. So much still to do ..
 >
 > Thanks,
 > Jess
 >
 > --
 > You received this message because you are subscribed to the Google
 > Groups "Autobahn" group.
 > To unsubscribe from this group and stop receiving emails from it,
send
 > an email to autobahnws+...@googlegroups.com <javascript:>
 > <mailto:autobahnws+unsub...@googlegroups.com <javascript:>>.
 > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout)
<[https://groups.google.com/d/optout](https://groups.google.com/d/optout)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+...@googlegroups.com

mailto:autobahnws+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#7

So just a few questions.

1) In this example, does ApplicationRunner replace the Client factory we
normally use for connecting clients?

Yes, this (optional) ApplicationRunner variant just takes care of a couple of steps otherwise done with somewhat boring code ..

2) Is there any documentation somewhere for ApplicationRunner that I can
take a look at?

Sorry, not yet. But you can have a look at the code which is really just a couple of dozen lines:

https://github.com/tavendo/AutobahnPython/blob/master/autobahn/autobahn/twisted/wamp.py#L63

3) Does this connect only the router to the database (since it seems to
me like it connects an embedded client with access to the database to
the router)?

Not sure if I get you .. probably yes. In this example, the ApplicationRunner employs a WAMP-over-WebSocket transport client and connects an application component to a WAMP router.

4) If I want another client to have access to the database, would I have
them call a function in this client (meaning only this embedded client
has access and anyone that wants to put or get values into the database
must ask this client to do it for them)?

Exactly. That's the idea here. Concentrate all database interfacing code in a database access component.

What's missing is Crossbar allow multiple instances of such a database access component register RPC endpoints under _the same_ URI and then let Crossbar load-balance incoming WAMP calls to those component instances.

It's not hard to do. And it'll be neat, since it lets you scale out application components both on a single node, as well as across multiple nodes.

What's harder (and will come later) is scale-out of the routing core itself. Both on a single as well as federated across ...

···

Am 08.04.2014 20:23, schrieb Jess Updegrove:

Thanks,
Jess

On Tuesday, April 8, 2014 5:21:46 AM UTC-4, Tobias Oberstein wrote:

    Am 07.04.2014 23:46, schrieb Jess Updegrove:
     > I got your example to run and it looks good. Will this work with
    a Riak
     > database also?

    Twisted adbapi is for database drivers that follow the Python DBI
    standard (PEP 249). That is relational databases. So it's not for Riak.
    I would look out for an asynchronous Riak driver, probably

    https://github.com/calston/riakasaurus
    <https://github.com/calston/riakasaurus>

    Btw: PostgreSQL can work as a plain Key-Value store too.

     >
     > Jess
     >
     > On Saturday, April 5, 2014 12:36:02 PM UTC-4, Tobias Oberstein > wrote:
     >
     > Hi Jess,
     >
     > Am 04.04.2014 22:27, schrieb Jess Updegrove:
     > > Hello,
     > >
     > > So I'm trying to figure out how to access a database with
    multiple
     > > clients without opening multiple connections to the database.
     > Allow me
     > > to explain: I want multiple application sessions to have
    access to
     > > information in a database but I don't want the connection
    to the
     > > database to be instantiated every single time a client
    connects
     > to the
     > > router. I want the router to have direct access to the
    database and
     > > allow the clients to work through the router to retrieve the
     > > information. In WAMP 1 we did this by calling self.factory
    and
     > having
     > > the database connection defined as part of the factory.
    How do I
     > do this
     > > in WAMP2? Would I set up the connection in the
     > ApplicationSessionFactory
     > > or the WampWebSocketClientFactory? How would I access the
    link?
     > > self.factory or self.session? Please ask any questions you
    may
     > need to
     > > get a better grasp on what I'm asking.
     >
     > I have added a complete example here:
     >
    https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame>

     >
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame>>

     >
     > To try yourself, please update AutobahnPython to current
    trunk (I have
     > added a comfort facility I explain in a second):
     >
     > git clone git@github.com:tavendo/AutobahnPython.git
     > cd AutobahnPython/autobahn
     > python setup.py install
     >
     > Follow
     >
    https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it>

     >
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it>>

     >
     > ..
     >
     > ==
     >
     > Now, regarding the code, this will create a single
    application session
     > instance of
     >
    https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35
    <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35>

     >
    <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35
    <https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35>>

     >
     > This class contains the backend of the app.
     >
     > The app uses SQLite as database, put you could easily modify
    this to
     > work for PostgeSQL. It's based on
     >
     > https://twistedmatrix.com/documents/current/core/howto/rdbms.html
    <https://twistedmatrix.com/documents/current/core/howto/rdbms.html>
     >
    <https://twistedmatrix.com/documents/current/core/howto/rdbms.html
    <https://twistedmatrix.com/documents/current/core/howto/rdbms.html>>
     >
     > which is generally the way to access databases directly from
    Twisted.
     > This stuff runs queries on a background thread pool (which is
    often
     > necessary, since database drivers are blocking .. and Twisted
    does not
     > like being blocked).
     >
     > ==
     >
     > Further, this example is packaged up as a "WAMPlet" .. pls
    read here
     >
    https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1>

     >
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1
    <https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1>>

     >
     > The reason to introduce "WAMPlets" is to make it dead easy to
    develop
     > those components running them "standalone" (against a WAMP
    router), and
     > later be able to let e.g. Crossbar host the component.
    Without any code
     > change of course.
     >
     > The introduction of the make() factory function also allows
    you wire up
     > your ApplicationSession instances as you like .. e.g. put a
     > reference to
     > a global singleton on them or such.
     >
     > ==
     >
     > Please checkout the example and let me know what questions
    remain
     > for you ..
     >
     > ==
     >
     > Lastly, above shows _direct_ database access from WAMP app
    components.
     >
     > Crossbar.io will soon (have again) the ability to call
    database stored
     > procedures directly. That means, in above example, the
    "vote()" RPC
     > endpoint could be implemented directly as a database stored
     > procedure ..
     > running inside the DB. This will work for DBs with stored proc.
     > languages like PostgreSQL .. it won't work for SQLite ..
    which is why
     > the example will remain useful.
     >
     > Here is how this will look like:
     >
    https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21
    <https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21>

     >
    <https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21
    <https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21>>

     >
     > [this example was for the predessor of Crossbar.io, and is
    for Oracle.
     > It'll essentially look the same once that feature is again in
     > Crossbar.io. For PostgreSQL, you will be able to write the
    stored proc.
     > in any stored proc. language supported .. e.g. also JavaScript].
     >
     > Realistically, it'll be another couple of weeks until we are
    there
     > .. oh
     > mei. So much still to do ..
     >
     > >
     > > Thanks,
     > > Jess
     > >
     > > --
     > > You received this message because you are subscribed to
    the Google
     > > Groups "Autobahn" group.
     > > To unsubscribe from this group and stop receiving emails
    from it,
     > send
     > > an email to autobah...@googlegroups.com <javascript:>
     > > <mailto:autobahnws+...@googlegroups.com
    <javascript:> <javascript:>>.
     > > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>
     > <https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>>.
     >
     > --
     > You received this message because you are subscribed to the Google
     > Groups "Autobahn" group.
     > To unsubscribe from this group and stop receiving emails from it,
    send
     > an email to autobah...@googlegroups.com <javascript:>
     > <mailto:autobahnws+...@googlegroups.com <javascript:>>.
     > For more options, visit https://groups.google.com/d/optout
    <https://groups.google.com/d/optout>.

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#8

Yes I was a bit mistaken when I wrote question 3 but I figured it out then haha. All looks good, thank you. I believe this helps me a bunch.

Jess

···

On Tuesday, April 8, 2014 2:50:34 PM UTC-4, Tobias Oberstein wrote:

Am 08.04.2014 20:23, schrieb Jess Updegrove:

So just a few questions.

  1. In this example, does ApplicationRunner replace the Client factory we

normally use for connecting clients?

Yes, this (optional) ApplicationRunner variant just takes care of a
couple of steps otherwise done with somewhat boring code …

  1. Is there any documentation somewhere for ApplicationRunner that I can

take a look at?

Sorry, not yet. But you can have a look at the code which is really just
a couple of dozen lines:

https://github.com/tavendo/AutobahnPython/blob/master/autobahn/autobahn/twisted/wamp.py#L63

  1. Does this connect only the router to the database (since it seems to

me like it connects an embedded client with access to the database to

the router)?

Not sure if I get you … probably yes. In this example, the
ApplicationRunner employs a WAMP-over-WebSocket transport client and
connects an application component to a WAMP router.

  1. If I want another client to have access to the database, would I have

them call a function in this client (meaning only this embedded client

has access and anyone that wants to put or get values into the database

must ask this client to do it for them)?

Exactly. That’s the idea here. Concentrate all database interfacing code
in a database access component.

What’s missing is Crossbar allow multiple instances of such a database
access component register RPC endpoints under the same URI and then
let Crossbar load-balance incoming WAMP calls to those component instances.

It’s not hard to do. And it’ll be neat, since it lets you scale out
application components both on a single node, as well as across multiple
nodes.

What’s harder (and will come later) is scale-out of the routing core
itself. Both on a single as well as federated across …

Thanks,

Jess

On Tuesday, April 8, 2014 5:21:46 AM UTC-4, Tobias Oberstein wrote:

Am 07.04.2014 23:46, schrieb Jess Updegrove:
 > I got your example to run and it looks good. Will this work with
a Riak
 > database also?
Twisted adbapi is for database drivers that follow the Python DBI
standard (PEP 249). That is relational databases. So it's not for Riak.
I would look out for an asynchronous Riak driver, probably
[https://github.com/calston/riakasaurus](https://github.com/calston/riakasaurus)
<[https://github.com/calston/riakasaurus](https://github.com/calston/riakasaurus)>
Btw: PostgreSQL can work as a plain Key-Value store too.
 >
 > Jess
 >
 > On Saturday, April 5, 2014 12:36:02 PM UTC-4, Tobias Oberstein >  > >     wrote:
 >
 >     Hi Jess,
 >
 >     Am 04.04.2014 22:27, schrieb Jess Updegrove:
 >      > Hello,
 >      >
 >      > So I'm trying to figure out how to access a database with
multiple
 >      > clients without opening multiple connections to the database.
 >     Allow me
 >      > to explain: I want multiple application sessions to have
access to
 >      > information in a database but I don't want the connection
to the
 >      > database to be instantiated every single time a client
connects
 >     to the
 >      > router. I want the router to have direct access to the
database and
 >      > allow the clients to work through the router to retrieve the
 >      > information. In WAMP 1 we did this by calling self.factory
and
 >     having
 >      > the database connection defined as part of the factory.
How do I
 >     do this
 >      > in WAMP2? Would I set up the connection in the
 >     ApplicationSessionFactory
 >      > or the WampWebSocketClientFactory? How would I access the
link?
 >      > self.factory or self.session? Please ask any questions you
may
 >     need to
 >      > get a better grasp on what I'm asking.
 >
 >     I have added a complete example here:
 >
 >
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)>
 >
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame)>>
 >
 >
 >     To try yourself, please update AutobahnPython to current
trunk (I have
 >     added a comfort facility I explain in a second):
 >
 >     git clone git@github.com:tavendo/AutobahnPython.git
 >     cd AutobahnPython/autobahn
 >     python setup.py install
 >
 >     Follow
 >
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)>
 >
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/votegame#try-it)>>
 >
 >     ..
 >
 >     ==
 >
 >     Now, regarding the code, this will create a single
application session
 >     instance of
 >
 >
[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)
<[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)>
 >
<[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)
<[https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35](https://github.com/tavendo/AutobahnPython/blob/master/examples/twisted/wamp/wamplet/votegame/votegame/backend.py#L35)>>
 >
 >
 >     This class contains the backend of the app.
 >
 >     The app uses SQLite as database, put you could easily modify
this to
 >     work for PostgeSQL. It's based on
 >
 > [https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)
<[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)>
 >
<[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)
<[https://twistedmatrix.com/documents/current/core/howto/rdbms.html](https://twistedmatrix.com/documents/current/core/howto/rdbms.html)>>
 >
 >     which is generally the way to access databases directly from
Twisted.
 >     This stuff runs queries on a background thread pool (which is
often
 >     necessary, since database drivers are blocking .. and Twisted
does not
 >     like being blocked).
 >
 >     ==
 >
 >     Further, this example is packaged up as a "WAMPlet" .. pls
read here
 >
 >
[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)>
 >
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)
<[https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1](https://github.com/tavendo/AutobahnPython/tree/master/examples/twisted/wamp/wamplet/wamplet1)>>
 >
 >
 >     The reason to introduce "WAMPlets" is to make it dead easy to
develop
 >     those components running them "standalone" (against a WAMP
router), and
 >     later be able to let e.g. Crossbar host the component.
Without any code
 >     change of course.
 >
 >     The introduction of the make() factory function also allows
you wire up
 >     your ApplicationSession instances as you like .. e.g. put a
 >     reference to
 >     a global singleton on them or such.
 >
 >     ==
 >
 >     Please checkout the example and let me know what questions
remain
 >     for you ..
 >
 >     ==
 >
 >     Lastly, above shows _direct_ database access from WAMP app
components.
 >
 >     Crossbar.io will soon (have again) the ability to call
database stored
 >     procedures directly. That means, in above example, the
"vote()" RPC
 >     endpoint could be implemented directly as a database stored
 >     procedure ..
 >     running inside the DB. This will work for DBs with stored proc.
 >     languages like PostgreSQL .. it won't work for SQLite ..
which is why
 >     the example will remain useful.
 >
 >     Here is how this will look like:
 >
 >
[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)
<[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)>
 >
<[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)
<[https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21](https://github.com/crossbario/crossbardemo/blob/master/web/demo/vote/sql/pkg_vote_body.sql#L21)>>
 >
 >
 >     [this example was for the predessor of Crossbar.io, and is
for Oracle.
 >     It'll essentially look the same once that feature is again in
 >     Crossbar.io. For PostgreSQL, you will be able to write the
stored proc.
 >     in any stored proc. language supported .. e.g. also JavaScript].
 >
 >     Realistically, it'll be another couple of weeks until we are
there
 >     .. oh
 >     mei. So much still to do ..
 >
 >
 >
 >      >
 >      > Thanks,
 >      > Jess
 >      >
 >      > --
 >      > You received this message because you are subscribed to
the Google
 >      > Groups "Autobahn" group.
 >      > To unsubscribe from this group and stop receiving emails
from it,
 >     send
 >      > an email to autobahnws+...@googlegroups.com <javascript:>
 >      > <mailto:autobahnws+unsub...@googlegroups.com
<javascript:> <javascript:>>.
 >      > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout)
<[https://groups.google.com/d/optout](https://groups.google.com/d/optout)>
 >     <[https://groups.google.com/d/optout](https://groups.google.com/d/optout)
<[https://groups.google.com/d/optout](https://groups.google.com/d/optout)>>.
 >
 > --
 > You received this message because you are subscribed to the Google
 > Groups "Autobahn" group.
 > To unsubscribe from this group and stop receiving emails from it,
send
 > an email to autobahnws+...@googlegroups.com <javascript:>
 > <mailto:autobahnws+unsub...@googlegroups.com <javascript:>>.
 > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout)
<[https://groups.google.com/d/optout](https://groups.google.com/d/optout)>.

You received this message because you are subscribed to the Google

Groups “Autobahn” group.

To unsubscribe from this group and stop receiving emails from it, send

an email to autobahnws+...@googlegroups.com

mailto:autobahnws+unsub...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

0 Likes

#9

Not sure if this is possible, but is there any way to give the router direct access to the database? This example creates a client and gives them access, but I was looking more into the router having direct access. The overall idea would be to have a client connect to the router and then be able to call the router directly to access values in the database. It’s starting to sound like this won’t be possible because of the symmetry of WAMPv2. Or is that the feature Crossbar.io is missing that you were describing?

Jess

0 Likes

#10

Not sure if this is possible, but is there any way to give the router
direct access to the database? This example creates a client and gives
them access, but I was looking more into the router having direct
access. The overall idea would be to have a client connect to the router
and then be able to call the router directly to access values in the
database. It's starting to sound like this won't be possible because of
the symmetry of WAMPv2. Or is that the feature Crossbar.io is missing
that you were describing?

You can have:

Client 1 -> Router -> Client 2 -> DB

And all of Client 1, 2 and Router can live inside the same OS process. Which means, the overhead of a call going from Client 1 through the Router to Client 2 is small compared to the time for the database query or whatever going from Client 2 to DB.

But the Router does not know about any database in that regard. The "database" is some "application thing", and the Router does not and should not care about such stuff. Otherwise this would introduce a coupling between application and infrastructure stuff, and WAMP is more about decoupling.

Sidenote: the Router might employ an _internal_ database, to which the application in turn had no access.

Hope this helps ..

···

Am 08.04.2014 21:09, schrieb Jess Updegrove:

Jess

--
You received this message because you are subscribed to the Google
Groups "Autobahn" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to autobahnws+...@googlegroups.com
<mailto:autobahnws+...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.

0 Likes

#11

Yes, very much so! Thanks!

Jess

0 Likes