• 11


    #include <stdio.h>
    #include <stdlib.h>

    #include <avis/elvin.h>
    #include <avis/errors.h>
    #include <avis/stdtypes.h>
    #include "errors_private.h"
    #include "avis/attributes.h"
    #include "avis/keys.h"

    void test_subscribe_sub_listener (Subscription *sub,
    Attributes *attributes, bool secure,
    void *user_data)
    {
    Array *data = attributes_get_opaque (attributes, "opaque");
    }

    int main(int argc, char* argv[]) {
    Elvin elvin;
    Subscription *sub;
    Attributes *ntfn = attributes_create ();
    Array data;

    data.item_count = 100 * 1024;
    data.items = malloc (data.item_count);

    memset (data.items, 42, data.item_count);

    /* check invalid subscription is handled */
    sub = elvin_subscribe (&elvin, "size (bogus");

    sub =
    elvin_subscribe
    (&elvin,
    "require (test) && string (message) && int32 == 32 && int64 == 64L");

    elvin_subscription_add_listener (sub, test_subscribe_sub_listener,
    "user_data");

    attributes_set_int32 (ntfn, "test", 1);
    attributes_set_int32 (ntfn, "int32", 32);
    attributes_set_int64 (ntfn, "int64", 64);
    attributes_set_real64 (ntfn, "pi", 3.14);
    attributes_set_string (ntfn, "message", "hello world");
    attributes_set_opaque (ntfn, "opaque", data);

    elvin_send (&elvin, ntfn) && elvin_poll (&elvin);

    //elvin_unsubscribe (&elvin, sub);

    /* test sub change*/
    sub = elvin_subscribe (&elvin, "require (bogus)");

    /*elvin_subscription_add_listener (sub, test_subscribe_sub_listener,
    "user_data");*/

    //elvin_subscription_set_expr (sub, "require (test)");

    elvin_send (&elvin, ntfn) && elvin_poll (&elvin);

    attributes_destroy (ntfn);

    /* test general listener */
    ntfn = attributes_create ();
    attributes_set_int32 (ntfn, "test", 1);

    attributes_destroy (ntfn);

    elvin_unsubscribe (&elvin, sub);

    elvin_close (&elvin);

    system("pause");
    }

  • 相关阅读:
    面试准备
    session
    memcached优化方案实例
    MySQL用户管理
    MySQL事务
    Linux防火墙
    Linux权限体系
    Linux查看日志文件
    查看系统状态
    负载均衡(六)分表分库的负载均衡
  • 原文地址:https://www.cnblogs.com/xiaomaogong/p/3645147.html
Copyright © 2020-2023  润新知