Class: OracleDB::Pool

Inherits:
Object
  • Object
show all
Defined in:
ext/oracledb/rboradb_pool.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'ext/oracledb/rboradb_pool.c', line 59

static VALUE pool_initialize(int argc, VALUE *argv, VALUE self)
{
    Pool_t *pool = To_Pool(self);
    rbOraDBContext *ctxt;
    dpiCommonCreateParams common_params;
    dpiPoolCreateParams pool_params;
    VALUE ctxt_obj, username, password, connstr, params;
    VALUE gc_guard = Qnil;

    rb_scan_args(argc, argv, "41", &ctxt_obj, &username, &password, &connstr, &params);
    ctxt = rboradb_get_rbOraDBContext(ctxt_obj);
    dpiContext_initCommonCreateParams(ctxt->handle, &common_params);
    dpiContext_initPoolCreateParams(ctxt->handle, &pool_params);
    OptExportString(username);
    OptExportString(password);
    OptExportString(connstr);
    if (!NIL_P(params)) {
        gc_guard = rboradb_set_common_and_dpiPoolCreateParams(&common_params, &pool_params, params);
    }

    if (rbOraDBPool_create(ctxt->handle, OPT_RSTRING_PTR(username), OPT_RSTRING_LEN(username),
                         OPT_RSTRING_PTR(password), OPT_RSTRING_LEN(password),
                         OPT_RSTRING_PTR(connstr), OPT_RSTRING_LEN(connstr),
                         &common_params, &pool_params, &pool->handle) != DPI_SUCCESS) {
        rboradb_raise_error(ctxt);
    }
    RB_GC_GUARD(gc_guard);
    rbOraDBContext_addRef(ctxt);
    pool->ctxt = ctxt;
    if (pool_params.outPoolName) {
        pool->pool_name = rb_external_str_new_with_enc(pool_params.outPoolName, pool_params.outPoolNameLength, rb_utf8_encoding());
    }
    return Qnil;
}

Instance Method Details

#acquire_connection(*args) ⇒ Object



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'ext/oracledb/rboradb_pool.c', line 94

static VALUE pool_acquire_connection(int argc, VALUE *argv, VALUE self)
{
    Pool_t *pool = To_Pool(self);
    dpiConnCreateParams conn_params;
    VALUE username, password, params;
    VALUE gc_guard = Qnil;
    dpiConn *dpi_conn;

    rb_scan_args(argc, argv, "21", &username, &password, &params);
    OptExportString(username);
    OptExportString(password);
    dpiContext_initConnCreateParams(pool->ctxt->handle, &conn_params);
    if (!NIL_P(params)) {
        gc_guard = rboradb_set_dpiConnCreateParams(&conn_params, params);
    }

    if (rbOraDBPool_acquireConnection(pool->handle,
                                    OPT_RSTRING_PTR(username), OPT_RSTRING_LEN(username),
                                    OPT_RSTRING_PTR(password), OPT_RSTRING_LEN(password),
                                    &conn_params, &dpi_conn) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    RB_GC_GUARD(gc_guard);
    return rboradb_to_conn(pool->ctxt, dpi_conn, &conn_params);
}

#busy_countObject



132
133
134
135
136
137
138
139
140
141
# File 'ext/oracledb/rboradb_pool.c', line 132

static VALUE pool_busy_count(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getBusyCount(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#close(*args) ⇒ Object



120
121
122
123
124
125
126
127
128
129
130
# File 'ext/oracledb/rboradb_pool.c', line 120

static VALUE pool_close(int argc, VALUE *argv, VALUE self)
{
    Pool_t *pool = To_Pool(self);
    VALUE mode;

    rb_scan_args(argc, argv, "01", &mode);
    if (rbOraDBPool_close(pool->handle, rboradb_to_dpiPoolCloseMode(mode)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#get_modeObject



143
144
145
146
147
148
149
150
151
152
# File 'ext/oracledb/rboradb_pool.c', line 143

static VALUE pool_get_mode(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    dpiPoolGetMode value;

    if (dpiPool_getGetMode(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return rboradb_from_dpiPoolGetMode(value);
}

#get_mode=(obj) ⇒ Object



154
155
156
157
158
159
160
161
162
# File 'ext/oracledb/rboradb_pool.c', line 154

static VALUE pool_set_get_mode(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setGetMode(pool->handle, rboradb_to_dpiPoolGetMode(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#max_lifetime_sessionObject



164
165
166
167
168
169
170
171
172
173
# File 'ext/oracledb/rboradb_pool.c', line 164

static VALUE pool_max_lifetime_session(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getMaxLifetimeSession(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#max_lifetime_session=(obj) ⇒ Object



175
176
177
178
179
180
181
182
183
# File 'ext/oracledb/rboradb_pool.c', line 175

static VALUE pool_set_max_lifetime_session(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setMaxLifetimeSession(pool->handle, NUM2UINT(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#max_sessions_per_shardObject



185
186
187
188
189
190
191
192
193
194
# File 'ext/oracledb/rboradb_pool.c', line 185

static VALUE pool_max_sessions_per_shard(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getMaxSessionsPerShard(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#max_sessions_per_shard=(obj) ⇒ Object



196
197
198
199
200
201
202
203
204
# File 'ext/oracledb/rboradb_pool.c', line 196

static VALUE pool_set_max_sessions_per_shard(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setMaxSessionsPerShard(pool->handle, NUM2UINT(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#open_countObject



206
207
208
209
210
211
212
213
214
215
# File 'ext/oracledb/rboradb_pool.c', line 206

static VALUE pool_open_count(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getOpenCount(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#ping_intervalObject



311
312
313
314
315
316
317
318
319
320
# File 'ext/oracledb/rboradb_pool.c', line 311

static VALUE pool_ping_interval(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    int value;

    if (dpiPool_getPingInterval(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return INT2NUM(value);
}

#ping_interval=(obj) ⇒ Object



322
323
324
325
326
327
328
329
330
# File 'ext/oracledb/rboradb_pool.c', line 322

static VALUE pool_set_ping_interval(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setPingInterval(pool->handle, NUM2INT(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#reconfigure(min_sessions, max_sessions, session_increment) ⇒ Object



217
218
219
220
221
222
223
224
225
# File 'ext/oracledb/rboradb_pool.c', line 217

static VALUE pool_reconfigure(VALUE self, VALUE min_sessions, VALUE max_sessions, VALUE session_increment)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_reconfigure(pool->handle, NUM2UINT(min_sessions), NUM2UINT(max_sessions), NUM2UINT(session_increment)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#soda_metadata_cacheObject



227
228
229
230
231
232
233
234
235
236
# File 'ext/oracledb/rboradb_pool.c', line 227

static VALUE pool_soda_metadata_cache(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    int value;

    if (dpiPool_getSodaMetadataCache(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return value ? Qtrue : Qfalse;
}

#soda_metadata_cache=(obj) ⇒ Object



238
239
240
241
242
243
244
245
246
# File 'ext/oracledb/rboradb_pool.c', line 238

static VALUE pool_set_soda_metadata_cache(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setSodaMetadataCache(pool->handle, RTEST(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#stmt_cache_sizeObject



248
249
250
251
252
253
254
255
256
257
# File 'ext/oracledb/rboradb_pool.c', line 248

static VALUE pool_stmt_cache_size(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getStmtCacheSize(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#stmt_cache_size=(obj) ⇒ Object



259
260
261
262
263
264
265
266
267
# File 'ext/oracledb/rboradb_pool.c', line 259

static VALUE pool_set_stmt_cache_size(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setStmtCacheSize(pool->handle, NUM2UINT(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#timeoutObject



269
270
271
272
273
274
275
276
277
278
# File 'ext/oracledb/rboradb_pool.c', line 269

static VALUE pool_timeout(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getTimeout(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#timeout=(obj) ⇒ Object



280
281
282
283
284
285
286
287
288
# File 'ext/oracledb/rboradb_pool.c', line 280

static VALUE pool_set_timeout(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setTimeout(pool->handle, NUM2UINT(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}

#wait_timeoutObject



290
291
292
293
294
295
296
297
298
299
# File 'ext/oracledb/rboradb_pool.c', line 290

static VALUE pool_wait_timeout(VALUE self)
{
    Pool_t *pool = To_Pool(self);
    uint32_t value;

    if (dpiPool_getWaitTimeout(pool->handle, &value) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return UINT2NUM(value);
}

#wait_timeout=(obj) ⇒ Object



301
302
303
304
305
306
307
308
309
# File 'ext/oracledb/rboradb_pool.c', line 301

static VALUE pool_set_wait_timeout(VALUE self, VALUE obj)
{
    Pool_t *pool = To_Pool(self);

    if (dpiPool_setWaitTimeout(pool->handle, NUM2UINT(obj)) != DPI_SUCCESS) {
        rboradb_raise_error(pool->ctxt);
    }
    return Qnil;
}