cotag / libcouchbase

libcouchbase ruby FFI with libuv integration
Other
11 stars 8 forks source link

Possibility to set query timeout ? #18

Open fijemax opened 5 years ago

fijemax commented 5 years ago

Is it possible to set the query timeout on n1ql query ?

stakach commented 5 years ago

I think the only way to do it is via the connection.

                # Configure 90 second timeouts
                # 0, 1, 13, 15, 61, 93 == operations, views, http, v-bucket poll, n1ql, http pool
                handle = ::User.bucket.connection.handle
                ::Libcouchbase::Ext.cntl_setu32(handle, 0, 90_000_000)
                ::Libcouchbase::Ext.cntl_setu32(handle, 1, 90_000_000)
                ::Libcouchbase::Ext.cntl_setu32(handle, 13, 90_000_000)
                ::Libcouchbase::Ext.cntl_setu32(handle, 15, 90_000_000)
                ::Libcouchbase::Ext.cntl_setu32(handle, 61, 90_000_000)
                ::Libcouchbase::Ext.cntl_setu32(handle, 93, 90_000_000)

                # Configure retries
                # LCB_RETRYOPT_CREATE = Proc.new { |mode, policy| ((mode << 16) | policy) }
                # val = LCB_RETRYOPT_CREATE(LCB_RETRY_ON_SOCKERR, LCB_RETRY_CMDS_SAFE);
                # ::Libcouchbase::Ext.cntl_setu32(handle, LCB_CNTL_RETRYMODE, val)
                retry_config = (1 << 16) | 3
                ::Libcouchbase::Ext.cntl_setu32(handle, 0x24, retry_config)

I should probably make this configurable a little easier at the bucket level.

::User is a couchbase orm model begin used to grab the connection handle

fijemax commented 5 years ago

It work thank you. Should not this configuration be set in the couchbase.yml file ?