Crossbar native worker examples and API

#1

Hi

I went through the architecture http://crossbar.io/docs/Architecture/ . Its amazing how twisted is getting used and I am in love with it.

One interesting thing is we can write a native worker under crossbar instance which would be controlled by node controller.

Is there an illustration how to write a simple native worker which starts as crossbar starts. Say I want to start publishing my CPU usage as soon as crossbar starts and I dont want to run separate wamp python code for that ?

I cant find any documentation or API on how to proceed on it, one thing I know is if I write my code in Python using WAMP applicaiton component, I can hook to the crossbar, but I am not looking for this.

What I am looking for is having custom host application as part of native worker coded in twisted which can be dynamically spawned by crossbar controller based on some rules. I am sure this can be achieved based on architecture diagram.

Thanks

Priyank

0 Likes

#2

Hi!

I’m not sure I understand your question fully.

Native workers are Python/Twisted code which is started based on the Crossbar.io node configuration. There is no dynamic spawning of these at present - and any such spawning will, in the future, be via the management API, not via any triggers within Crossbar.io itself.

The “custom host application” and not wanting a WAMP application component seems to suggest you want something which forms a direct part of the node controller. Workers, whether native or containers, communicate with the node controller using WAMP, and we do not provide any other way - or think that such an other way is required.

BTW, your example of publishing the CPU usage is something that the upcoming management API will cover.

Regards,

Alex

···

Am Freitag, 25. September 2015 00:56:34 UTC+2 schrieb Priyank Kumar:

Hi

I went through the architecture http://crossbar.io/docs/Architecture/ . Its amazing how twisted is getting used and I am in love with it.

One interesting thing is we can write a native worker under crossbar instance which would be controlled by node controller.

Is there an illustration how to write a simple native worker which starts as crossbar starts. Say I want to start publishing my CPU usage as soon as crossbar starts and I dont want to run separate wamp python code for that ?

I cant find any documentation or API on how to proceed on it, one thing I know is if I write my code in Python using WAMP applicaiton component, I can hook to the crossbar, but I am not looking for this.

What I am looking for is having custom host application as part of native worker coded in twisted which can be dynamically spawned by crossbar controller based on some rules. I am sure this can be achieved based on architecture diagram.

Thanks

Priyank

0 Likes

#3

Hi Alexander,
Thanks.

I am looking how to write a native worker worker?

As in article its stated:

  1. How to write this special process container in twisted python. Any example here which can run at crossbar, or its any WAMP python code (application runner) which connects to crossbar. As I believe internal workers communicate with internal IPC on Unix socket, but wamp application component is over a transport and connect over web/tcp socket

  2. Here I am looking at the block diagram and trying to understand how should I write some native python code which can do some processing at crossbar router (not at the client), and it seems to me that architecture supports it, like u have templates and static webserver

  3. So I need help in writing such middleware at the crossbar running machine itself (say a server) using the native container worker

From the documentation:

Crossbar.io can work as a component host or component container for WAMP application components - regardless in which language they are written or under which run-time they run. You can host mixed language or run-time application component sets.

Crossbar.io Node

Native Python application components are hosted in special worker processes called Containers.

···

On Friday, September 25, 2015 at 3:54:18 AM UTC-7, Alexander Gödde wrote:

Hi!

I’m not sure I understand your question fully.

Native workers are Python/Twisted code which is started based on the Crossbar.io node configuration. There is no dynamic spawning of these at present - and any such spawning will, in the future, be via the management API, not via any triggers within Crossbar.io itself.

The “custom host application” and not wanting a WAMP application component seems to suggest you want something which forms a direct part of the node controller. Workers, whether native or containers, communicate with the node controller using WAMP, and we do not provide any other way - or think that such an other way is required.

BTW, your example of publishing the CPU usage is something that the upcoming management API will cover.

Regards,

Alex

Am Freitag, 25. September 2015 00:56:34 UTC+2 schrieb Priyank Kumar:

Hi

I went through the architecture http://crossbar.io/docs/Architecture/ . Its amazing how twisted is getting used and I am in love with it.

One interesting thing is we can write a native worker under crossbar instance which would be controlled by node controller.

Is there an illustration how to write a simple native worker which starts as crossbar starts. Say I want to start publishing my CPU usage as soon as crossbar starts and I dont want to run separate wamp python code for that ?

I cant find any documentation or API on how to proceed on it, one thing I know is if I write my code in Python using WAMP applicaiton component, I can hook to the crossbar, but I am not looking for this.

What I am looking for is having custom host application as part of native worker coded in twisted which can be dynamically spawned by crossbar controller based on some rules. I am sure this can be achieved based on architecture diagram.

Thanks

Priyank

0 Likes

#4

Hello!

To clarify: native workers of type container are components which are written using the same technologies as Crossbar.io itself (Python + Twisted). They are, however, still regular WAMP components, just with a bit tighter integration with Crossbar.io. One difference is e.g. that the Crossbar.io config contains the connection data.

At a WAMP level, they are no different from other components, whether these run hosted by Crossbar.io, otherwise on the same machine, or anywhere else with a network connection. They communicate via WAMP, and over a transport. (Of course, with containers you get much lower latency than with an internet connection.)

For a simple example of a component which is run as a native worker, see the https://github.com/crossbario/crossbarexamples/tree/master/hello/python

The native worker is started and connected via the Crossbar configuration - https://github.com/crossbario/crossbarexamples/blob/master/hello/python/.crossbar/config.json

The component itself is here - https://github.com/crossbario/crossbarexamples/blob/master/hello/python/hello/hello.py

···

Am Freitag, 25. September 2015 17:53:36 UTC+2 schrieb Priyank Kumar:

Hi Alexander,
Thanks.

I am looking how to write a native worker worker?

As in article its stated:

  1. How to write this special process container in twisted python. Any example here which can run at crossbar, or its any WAMP python code (application runner) which connects to crossbar. As I believe internal workers communicate with internal IPC on Unix socket, but wamp application component is over a transport and connect over web/tcp socket
  1. Here I am looking at the block diagram and trying to understand how should I write some native python code which can do some processing at crossbar router (not at the client), and it seems to me that architecture supports it, like u have templates and static webserver
  1. So I need help in writing such middleware at the crossbar running machine itself (say a server) using the native container worker

From the documentation:

Crossbar.io can work as a component host or component container for WAMP application components - regardless in which language they are written or under which run-time they run. You can host mixed language or run-time application component sets.

Native Python application components are hosted in special worker processes called Containers.

On Friday, September 25, 2015 at 3:54:18 AM UTC-7, Alexander Gödde wrote:

Hi!

I’m not sure I understand your question fully.

Native workers are Python/Twisted code which is started based on the Crossbar.io node configuration. There is no dynamic spawning of these at present - and any such spawning will, in the future, be via the management API, not via any triggers within Crossbar.io itself.

The “custom host application” and not wanting a WAMP application component seems to suggest you want something which forms a direct part of the node controller. Workers, whether native or containers, communicate with the node controller using WAMP, and we do not provide any other way - or think that such an other way is required.

BTW, your example of publishing the CPU usage is something that the upcoming management API will cover.

Regards,

Alex

Am Freitag, 25. September 2015 00:56:34 UTC+2 schrieb Priyank Kumar:

Hi

I went through the architecture http://crossbar.io/docs/Architecture/ . Its amazing how twisted is getting used and I am in love with it.

One interesting thing is we can write a native worker under crossbar instance which would be controlled by node controller.

Is there an illustration how to write a simple native worker which starts as crossbar starts. Say I want to start publishing my CPU usage as soon as crossbar starts and I dont want to run separate wamp python code for that ?

I cant find any documentation or API on how to proceed on it, one thing I know is if I write my code in Python using WAMP applicaiton component, I can hook to the crossbar, but I am not looking for this.

What I am looking for is having custom host application as part of native worker coded in twisted which can be dynamically spawned by crossbar controller based on some rules. I am sure this can be achieved based on architecture diagram.

Thanks

Priyank

0 Likes

#5

Priyank,

sorry for late reply ..

Hi Alexander,
Thanks.

I am looking how to write a native worker worker?

You can't. Native workers (router and container workers are an implementation detail of Crossbar.io).

As in article its stated:
1) How to write this special process container in twisted python. Any
example here which can run at crossbar, or its any WAMP python code
(application runner) which connects to crossbar. As I believe internal
workers communicate with internal IPC on Unix socket, but wamp
application component is over a transport and connect over web/tcp socket

It works like this:

(1) A WAMP component that you have written in Python using AutobahnPython/Twisted can be deployed in more variants than
(2) a WAMP component written in some other WAMP supported language.

(1) can be run in Crossbar.io

a) embedded in a router worker - it will then talk to the router over a pseudo-transport which simply boils down to function calls

b) in a container worker - it then can talk over any transport support by Crossbar.io (Unix domain sockets is just one)

c) in a regular guest worker - again it can talk over any transport

With a) and b), you can have multiple such components running in the same process/worker. Not with c) - there is only one component (since WAMP currently does not support multiplexed transports).

2) Here I am looking at the block diagram and trying to understand how
should I write some native python code which can do some processing at
crossbar router (not at the client), and it seems to me that
architecture supports it, like u have templates and static webserver

No, you can't. A component like (1) above can be _deployed_ in more variants (see above), but it can't _do_ anything more than any other WAMP component.

In particular, you cannot modify or directly call into the router internals.

This is by design: router code and app code MUST NOT be mixed.

3) So I need help in writing such middleware at the crossbar running
machine itself (say a server) using the native container worker

You can open a listening port in any WAMP component as you like.

Hope this helps,

/Tobias

···

Am 25.09.2015 um 17:53 schrieb Priyank Kumar:

From the documentation:

Crossbar.io can work as a component host or component container for WAMP
application components - regardless in which language they are written
or under which run-time they run. You can host mixed language or
run-time application component sets.

Crossbar.io Node

Native Python application components are hosted in special worker
processes called /Containers/.

On Friday, September 25, 2015 at 3:54:18 AM UTC-7, Alexander Gödde wrote:

    Hi!

    I'm not sure I understand your question fully.

    Native workers are Python/Twisted code which is started based on the
    Crossbar.io node configuration. There is no dynamic spawning of
    these at present - and any such spawning will, in the future, be via
    the management API, not via any triggers within Crossbar.io itself.

    The "custom host application" and not wanting a WAMP application
    component seems to suggest you want something which forms a direct
    part of the node controller. Workers, whether native or containers,
    communicate with the node controller using WAMP, and we do not
    provide any other way - or think that such an other way is required.

    BTW, your example of publishing the CPU usage is something that the
    upcoming management API will cover.

    Regards,

    Alex

    Am Freitag, 25. September 2015 00:56:34 UTC+2 schrieb Priyank Kumar:

        Hi

        I went through the architecture
        http://crossbar.io/docs/Architecture/
        <http://crossbar.io/docs/Architecture/> . Its amazing how
        twisted is getting used and I am in love with it.

        One interesting thing is we can write a native worker under
        crossbar instance which would be controlled by node controller.

        Is there an illustration how to write a simple native worker
        which starts as crossbar starts. Say I want to start publishing
        my CPU usage as soon as crossbar starts and I dont want to run
        separate wamp python code for that ?
        I cant find any documentation or API on how to proceed on it,
        one thing I know is if I write my code in Python using WAMP
        applicaiton component, I can hook to the crossbar, but I am not
        looking for this.
        What I am looking for is having custom host application as part
        of native worker coded in twisted which can be dynamically
        spawned by crossbar controller based on some rules. I am sure
        this can be achieved based on architecture diagram.

        Thanks
        Priyank

--
You received this message because you are subscribed to the Google
Groups "Crossbar" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to crossbario+...@googlegroups.com
<mailto:crossbario+...@googlegroups.com>.
To post to this group, send email to cross...@googlegroups.com
<mailto:cross...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/crossbario/35fe8161-d398-4c72-a30a-9a68c45f6e2d%40googlegroups.com
<https://groups.google.com/d/msgid/crossbario/35fe8161-d398-4c72-a30a-9a68c45f6e2d%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

0 Likes