E.53. lt_t3sdk

E.53.1. 安装
E.53.2. 概述
E.53.3. 函数
E.53.4. 例子

这个LightDB扩展实现了JRES的T3请求

E.53.1. 安装

要安装t3sdk, 需要使用CRES的C客户端库,默认版本是CRES2.0.V202302.00.000。这个库可以是从恒生下载

下载CRES的SDK并解压,目录如下:

            acm/
            dev/
                client_demo/T3SDK/c++/linux.x64/lib/libt3sdk.so
                client_demo/T3SDK_C/linux.x64/lib/libt3sdk_c.so
            docker/
            instance/
            tools/
        

CRES SDK的libt3sdk.so and libt3sdk_c.so 必须添加到 LD_LIBRARY_PATH.

如果你首次安装, 使用 CREATE EXTENSION t3sdk.

如果你已经安装了一个之前的版本,并且仅仅想要升级则使用 ALTER EXTENSION t3sdk UPDATE.

E.53.2. 概述

每一个T3调用都是由VARCHAR请求列表和t3sdk_response应答组成.

每次向T3的服务请求时,后端进程都会保持连接,直到该进程退出。键是服务器地址和端口,值是连接句柄。

                                                                                                              List of functions
         Schema |    Name    | Result data type |                                                                             Argument data types                                                                             | Type
        --------+------------+------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------+------
         public | t3sdk_send | t3sdk_response   | t_address character varying, groups character varying, service character varying, version character varying, function_id character varying, function_args character varying | func


                    Composite type "public.t3sdk_response"
         Column  |       Type        | Collation | Nullable | Default
        ---------+-------------------+-----------+----------+---------
         content | character varying |           |          |
        

E.53.3. 函数

  • t3sdk_send(t_address VARCHAR, groups VARCHAR, service VARCHAR, version VARCHAR, function_id VARCHAR, function_args VARCHAR) returns t3sdk_response

默认情况下,发送请求的超时时间为60秒。如果需要不同的超时时间,可以使用毫秒设置以下GUC变量:

            t3sdk.t3_send_timeout_msec = 60000
        

默认情况下,为请求的接收设置了60秒的超时时间。如果需要不同的超时时间,可以使用毫秒设置以下GUC变量:

            t3sdk.t3_recv_timeout_msec = 60000
        

如果需要不同T3的许可证,可以使用以下GUC变量进行设置:

            t3sdk.t3_license_no = 'HS-HUNDSUN001-FBASE2-0000-4ePWxzscBVtY9ZKdgDKhSyk2'
        

E.53.4. 例子

            -- 发送t3请求
            select * from  t3sdk_send('10.20.30.193:18082', 'g', 'repo-app', 'v', 'getExpressInfoNdb', '');
                                                                                                                                content

            ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
            ----------------------------------------
             {"result":[{"express_id":"a","order_id":"1","express_no":"123456789","company":"测试公司1","create_datetime":"20230407010201","status":"0"},{"express_id":"b","order_id":"2","express_no":"123456789","company":"测试公司2","create_dat
            etime":"20230407010201","status":"0"}]}
            (1 row)