cb_publish in PostgreSQLDatabasePublisher

#1

Hi,

I see that the PostgreSQLDatabasePublisher class references a cb_publish function:

https://github.com/crossbario/crossbar/blob/7d42ac9f63b5b330fe09a887059528d0cc63d286/crossbar/crossbar/adapter/postgres/publisher.py#L62

However, I couldn’t find a definition of this function in the code. Additionally, the examples use syntax that are only available in the PostgreSQL beta and not the current released version. I tried to implement a basic version of cb_publish myself to provide this functionality to my tools:

CREATE OR REPLACE FUNCTION cb_publish(
topic VARCHAR,
args JSON DEFAULT ‘[]’,
kwargs JSON DEFAULT ‘{}’
)
RETURNS VOID
AS
$$
BEGIN
PERFORM
pg_notify(
‘crossbar_pubsub_event’,
row_to_json(x) :: VARCHAR
)
FROM
(SELECT
‘direct’ AS “type”,
topic AS topic,
args AS args,
kwargs AS kwargs
) x;
END;
$$
LANGUAGE plpgsql;

``

Does this look like it would work as expected, or am I missing something?

Thanks,

Jimmy Jia

0 Likes

#2

Not sure what happened with this email - I wrote it a few days ago - it didn’t send initially, and I decided to ask the same question on another thread instead. Please ignore this.

···

On Fri, Nov 21, 2014, 09:47 Jimmy Jia tes...@gmail.com wrote:

Hi,

I see that the PostgreSQLDatabasePublisher class references a cb_publish function:

https://github.com/crossbario/crossbar/blob/7d42ac9f63b5b330fe09a887059528d0cc63d286/crossbar/crossbar/adapter/postgres/publisher.py#L62

However, I couldn’t find a definition of this function in the code. Additionally, the examples use syntax that are only available in the PostgreSQL beta and not the current released version. I tried to implement a basic version of cb_publish myself to provide this functionality to my tools:

CREATE OR REPLACE FUNCTION cb_publish(
topic VARCHAR,
args JSON DEFAULT ‘[]’,
kwargs JSON DEFAULT ‘{}’
)
RETURNS VOID
AS
$$
BEGIN
PERFORM
pg_notify(
‘crossbar_pubsub_event’,
row_to_json(x) :: VARCHAR
)
FROM
(SELECT
‘direct’ AS “type”,
topic AS topic,
args AS args,
kwargs AS kwargs
) x;
END;
$$
LANGUAGE plpgsql;

``

Does this look like it would work as expected, or am I missing something?

Thanks,

Jimmy Jia

You received this message because you are subscribed to a topic in the Google Groups “Autobahn” group.

To unsubscribe from this topic, visit https://groups.google.com/d/topic/autobahnws/D2gukCYaEG4/unsubscribe.

To unsubscribe from this group and all its topics, send an email to autobahnws+...@googlegroups.com.

To post to this group, send email to autob...@googlegroups.com.

To view this discussion on the web visit https://groups.google.com/d/msgid/autobahnws/a07696c5-0ffa-4f5b-8c50-afd44f5d8b81%40googlegroups.com.

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

0 Likes

#3

Not sure what happened with this email - I wrote it a few days ago - it
didn't send initially, and I decided to ask the same question on another
thread instead. Please ignore this.

Hi Jimmy,

Google Groups occasionally decides that a post would be spam. I now released 2 posts of you that got stuck in the spam queue and marked your mail address as "never spam" (the latter however still sometimes does not work as expected).

Tobias

···

Am 21.11.2014 15:49, schrieb Jimmy Jia:

On Fri, Nov 21, 2014, 09:47 Jimmy Jia <tes...@gmail.com > <mailto:tes...@gmail.com>> wrote:

    Hi,

    I see that the PostgreSQLDatabasePublisher class references a
    cb_publish function:

    https://github.com/crossbario/crossbar/blob/7d42ac9f63b5b330fe09a887059528d0cc63d286/crossbar/crossbar/adapter/postgres/publisher.py#L62

    However, I couldn't find a definition of this function in the code.
    Additionally, the examples use syntax that are only available in the
    PostgreSQL beta and not the current released version. I tried to
    implement a basic version of cb_publish myself to provide this
    functionality to my tools:

    >
    CREATE OR REPLACE FUNCTION cb_publish(
       topic VARCHAR,
       args JSON DEFAULT '[]',
       kwargs JSON DEFAULT '{}'
    )
       RETURNS VOID
    AS
       $$
    BEGIN
         PERFORM
           pg_notify(
    'crossbar_pubsub_event',
               row_to_json(x)::VARCHAR
    )
         FROM
    (SELECT
    'direct'AS "type",
              topic AS topic,
              args AS args,
              kwargs AS kwargs
    )x;
    END;
       $$
    LANGUAGE plpgsql;
    >

    Does this look like it would work as expected, or am I missing
    something?

    Thanks,
    Jimmy Jia

    --
    You received this message because you are subscribed to a topic in
    the Google Groups "Autobahn" group.
    To unsubscribe from this topic, visit
    https://groups.google.com/d/topic/autobahnws/D2gukCYaEG4/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to
    autobahnws+...@googlegroups.com
    <mailto:autobahnws+...@googlegroups.com>.
    To post to this group, send email to autob...@googlegroups.com
    <mailto:autob...@googlegroups.com>.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/autobahnws/a07696c5-0ffa-4f5b-8c50-afd44f5d8b81%40googlegroups.com
    <https://groups.google.com/d/msgid/autobahnws/a07696c5-0ffa-4f5b-8c50-afd44f5d8b81%40googlegroups.com?utm_medium=email&utm_source=footer>.
    For more options, visit 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>.
To post to this group, send email to autob...@googlegroups.com
<mailto:autob...@googlegroups.com>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/autobahnws/CALFTs%3DdPAxADoPToA5%2B%2B%3D5P-_nPvpiqFvjkBYb5WqaTmZ4eTuQ%40mail.gmail.com
<https://groups.google.com/d/msgid/autobahnws/CALFTs%3DdPAxADoPToA5%2B%2B%3D5P-_nPvpiqFvjkBYb5WqaTmZ4eTuQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

0 Likes